Jordan Legg commited on
Commit
6a2ce14
1 Parent(s): eb15eff

added dataset

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +3 -0
  2. .gitignore +1 -0
  3. create-video.ipynb +274 -0
  4. high_quality_output.mov +3 -0
  5. image_metadata_extraction.ipynb +173 -0
  6. train/00455cd0-6372-41e6-9ec0-07e92a0c9a08.png +3 -0
  7. train/0071a8c3-b16d-4de5-932b-d40b5b7661d1.png +3 -0
  8. train/0092e70e-e5d0-416f-a08d-738d823c0263.png +3 -0
  9. train/00b6572d-cddd-401d-971a-6115b71bc71c.png +3 -0
  10. train/00eafd43-d28d-4c33-b28a-899bd47da74a.png +3 -0
  11. train/0154dcbe-9039-412b-af6c-53e25da0a86d.png +3 -0
  12. train/015dd218-e636-44d9-8664-26932c9999b0.png +3 -0
  13. train/015f9c37-62da-4756-b6f5-4e1c9d48f21a.png +3 -0
  14. train/0178de63-7d50-4f3e-9a99-f14a71e07586.png +3 -0
  15. train/01d76e8e-10e6-4926-8c9b-2c23d7a84c5c.png +3 -0
  16. train/02073830-7134-407a-8b6f-c734930164ea.png +3 -0
  17. train/02167913-42d2-4f78-9451-26e118d5270f.png +3 -0
  18. train/025e6153-83c1-4f6c-84eb-3cf176674699.png +3 -0
  19. train/02609d0c-651c-4c18-b027-67a18efcb0e5.png +3 -0
  20. train/02773e2a-3abf-4669-abba-4102b3d9d149.png +3 -0
  21. train/02b3ff90-1780-4ae1-81f9-64723d74a738.png +3 -0
  22. train/02b71c19-e6a8-46e0-975c-66089fdea26d.png +3 -0
  23. train/02c500de-33df-41fb-a39f-c16bfba4a015.png +3 -0
  24. train/02d28798-45ea-4890-9cf6-ecc3077ef93d.png +3 -0
  25. train/03485da8-fb49-4dc9-bbef-e4a2232c0181.png +3 -0
  26. train/034e5c87-f053-4cda-9d46-57652b174de7.png +3 -0
  27. train/042d818e-065e-4e01-86cc-d91c49d7077c.png +3 -0
  28. train/0441a292-e8b8-45ae-9817-efee1e5147e6.png +3 -0
  29. train/04695513-6b7f-41a7-a961-27db5ab03592.png +3 -0
  30. train/04d2ae96-443b-4cbd-873f-e60a769e29a5.png +3 -0
  31. train/04d69896-054c-4762-b8e7-327cdb31503d.png +3 -0
  32. train/04d9fd59-4440-4777-b944-f065d56677cb.png +3 -0
  33. train/04e08d0a-f33a-4355-b45b-d456e1bb555d.png +3 -0
  34. train/0504a319-4408-4d31-b842-5760fec46e7e.png +3 -0
  35. train/0528732a-2f4a-403d-90d1-e7e46d927bb6.png +3 -0
  36. train/05d01729-6ced-4b22-a492-352443dcc74c.png +3 -0
  37. train/0604dbd4-890d-4d99-b3fb-ee5ad4efd3b4.png +3 -0
  38. train/06067581-a0aa-4525-8d36-3c4b329ac151.png +3 -0
  39. train/06625d12-86ba-4028-9a71-097186bbb754.png +3 -0
  40. train/06813f46-dd8f-4421-87c8-322399ac69f5.png +3 -0
  41. train/06ae6eb9-0fda-4964-bc06-43853616a584.png +3 -0
  42. train/07970142-cc85-4a30-9fa6-3bf45f43f32d.png +3 -0
  43. train/0798fb4c-927a-4a11-beb8-538e8c854cd5.png +3 -0
  44. train/07a05d0f-55a9-4728-ab2e-ed069e96fe88.png +3 -0
  45. train/0846f615-28ff-448a-9ad6-2a43ffc6d823.png +3 -0
  46. train/086b80d5-0621-4bb6-b7b6-a3767b2fbc5b.png +3 -0
  47. train/087d553d-bf95-4150-b481-542b473cb223.png +3 -0
  48. train/08eb296e-f91f-4da4-abfb-0015d4340167.png +3 -0
  49. train/092558b5-f573-4882-9184-6a64168878a9.png +3 -0
  50. train/095baeaf-8285-44a4-a573-3283259b8d0c.png +3 -0
.gitattributes CHANGED
@@ -56,3 +56,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
56
  # Video files - compressed
57
  *.mp4 filter=lfs diff=lfs merge=lfs -text
58
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
 
 
56
  # Video files - compressed
57
  *.mp4 filter=lfs diff=lfs merge=lfs -text
58
  *.webm filter=lfs diff=lfs merge=lfs -text
59
+ # Video files
60
+ *.mov filter=lfs diff=lfs merge=lfs -text
61
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .DS_Store
create-video.ipynb ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# Create Video!"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": null,
13
+ "metadata": {},
14
+ "outputs": [],
15
+ "source": [
16
+ "pip install opencv-python-headless # If you do not need GUI features\n"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "markdown",
21
+ "metadata": {},
22
+ "source": [
23
+ "## Creating the demo\n"
24
+ ]
25
+ },
26
+ {
27
+ "cell_type": "code",
28
+ "execution_count": null,
29
+ "metadata": {},
30
+ "outputs": [],
31
+ "source": [
32
+ "import os\n",
33
+ "import subprocess\n",
34
+ "import logging\n",
35
+ "from glob import glob\n",
36
+ "import re\n",
37
+ "\n",
38
+ "# Configure logging\n",
39
+ "logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')\n",
40
+ "logger = logging.getLogger(__name__)\n",
41
+ "\n",
42
+ "def create_near_lossless_h265_video(input_folder, output_file, fps=30, frames_per_image=3, crf=10):\n",
43
+ " if not os.path.exists(input_folder):\n",
44
+ " logger.error(f\"Input folder '{input_folder}' does not exist.\")\n",
45
+ " return\n",
46
+ "\n",
47
+ " png_files = sorted(glob(os.path.join(input_folder, '*.png')))\n",
48
+ " if not png_files:\n",
49
+ " logger.error(f\"No PNG files found in {input_folder}\")\n",
50
+ " return\n",
51
+ "\n",
52
+ " num_images = len(png_files)\n",
53
+ " logger.info(f\"Found {num_images} PNG files.\")\n",
54
+ "\n",
55
+ " # Calculate expected duration\n",
56
+ " expected_duration = (num_images * frames_per_image) / fps\n",
57
+ " logger.info(f\"Expected duration: {expected_duration:.2f} seconds\")\n",
58
+ "\n",
59
+ " # FFmpeg command for near-lossless 10-bit H.265 encoding\n",
60
+ " ffmpeg_command = [\n",
61
+ " 'ffmpeg',\n",
62
+ " '-framerate', f'{1/(frames_per_image/fps)}', # Input framerate\n",
63
+ " '-i', os.path.join(input_folder, '%*.png'), # Input pattern for all PNG files\n",
64
+ " '-fps_mode', 'vfr',\n",
65
+ " '-pix_fmt', 'yuv420p10le', # 10-bit pixel format\n",
66
+ " '-c:v', 'libx265', # Use libx265 encoder\n",
67
+ " '-preset', 'slow', # Slowest preset for best compression efficiency\n",
68
+ " '-crf', str(crf), # Constant Rate Factor (0-51, lower is higher quality)\n",
69
+ " '-profile:v', 'main10', # 10-bit profile\n",
70
+ " '-x265-params', f\"log-level=error:keyint={2*fps}:min-keyint={fps}:scenecut=0\", # Ensure consistent encoding\n",
71
+ " '-tag:v', 'hvc1',\n",
72
+ " '-y',\n",
73
+ " output_file\n",
74
+ " ]\n",
75
+ "\n",
76
+ " try:\n",
77
+ " logger.info(\"Starting near-lossless 10-bit video creation...\")\n",
78
+ " process = subprocess.Popen(ffmpeg_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)\n",
79
+ " \n",
80
+ " encoding_speed = None\n",
81
+ " \n",
82
+ " for line in process.stderr:\n",
83
+ " print(line, end='') # Print FFmpeg output in real-time\n",
84
+ " \n",
85
+ " speed_match = re.search(r'speed=\\s*([\\d.]+)x', line)\n",
86
+ " if speed_match:\n",
87
+ " encoding_speed = float(speed_match.group(1))\n",
88
+ " \n",
89
+ " process.wait()\n",
90
+ " \n",
91
+ " if encoding_speed:\n",
92
+ " logger.info(f\"Encoding speed: {encoding_speed:.2f}x\")\n",
93
+ " \n",
94
+ " if process.returncode == 0:\n",
95
+ " logger.info(f\"Video created successfully: {output_file}\")\n",
96
+ " \n",
97
+ " probe_command = ['ffprobe', '-v', 'error', '-show_entries', 'stream=codec_name,width,height,duration,bit_rate,profile', '-of', 'default=noprint_wrappers=1', output_file]\n",
98
+ " probe_result = subprocess.run(probe_command, capture_output=True, text=True)\n",
99
+ " logger.info(f\"Video properties:\\n{probe_result.stdout}\")\n",
100
+ " \n",
101
+ " duration_command = ['ffprobe', '-v', 'error', '-show_entries', 'format=duration', '-of', 'default=noprint_wrappers=1:nokey=1', output_file]\n",
102
+ " duration_result = subprocess.run(duration_command, capture_output=True, text=True)\n",
103
+ " actual_duration = float(duration_result.stdout.strip())\n",
104
+ " logger.info(f\"Actual video duration: {actual_duration:.2f} seconds\")\n",
105
+ " if abs(actual_duration - expected_duration) > 1:\n",
106
+ " logger.warning(f\"Video duration mismatch. Expected: {expected_duration:.2f}, Actual: {actual_duration:.2f}\")\n",
107
+ " else:\n",
108
+ " logger.info(\"Video duration check passed.\")\n",
109
+ " else:\n",
110
+ " logger.error(f\"Error during video creation. FFmpeg returned code {process.returncode}\")\n",
111
+ "\n",
112
+ " except subprocess.CalledProcessError as e:\n",
113
+ " logger.error(f\"Error during video creation: {e}\")\n",
114
+ " logger.error(f\"FFmpeg error output:\\n{e.stderr}\")\n",
115
+ "\n",
116
+ "if __name__ == \"__main__\":\n",
117
+ " input_folder = 'train'\n",
118
+ " output_file = 'near_lossless_output.mp4'\n",
119
+ " fps = 30\n",
120
+ " frames_per_image = 3\n",
121
+ " crf = 18 # Very low CRF for near-lossless quality (0 is lossless, but often overkill)\n",
122
+ "\n",
123
+ " create_near_lossless_h265_video(input_folder, output_file, fps, frames_per_image, crf)\n"
124
+ ]
125
+ },
126
+ {
127
+ "cell_type": "markdown",
128
+ "metadata": {},
129
+ "source": [
130
+ "## Transfer File"
131
+ ]
132
+ },
133
+ {
134
+ "cell_type": "code",
135
+ "execution_count": null,
136
+ "metadata": {},
137
+ "outputs": [],
138
+ "source": [
139
+ "import os\n",
140
+ "import subprocess\n",
141
+ "import logging\n",
142
+ "from glob import glob\n",
143
+ "import re\n",
144
+ "\n",
145
+ "# Configure logging\n",
146
+ "logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')\n",
147
+ "logger = logging.getLogger(__name__)\n",
148
+ "\n",
149
+ "def create_high_quality_video(input_folder, output_file, fps=60, frames_per_image=3, codec='ffv1'):\n",
150
+ " if not os.path.exists(input_folder):\n",
151
+ " logger.error(f\"Input folder '{input_folder}' does not exist.\")\n",
152
+ " return\n",
153
+ "\n",
154
+ " png_files = sorted(glob(os.path.join(input_folder, '*.png')))\n",
155
+ " if not png_files:\n",
156
+ " logger.error(f\"No PNG files found in {input_folder}\")\n",
157
+ " return\n",
158
+ "\n",
159
+ " num_images = len(png_files)\n",
160
+ " logger.info(f\"Found {num_images} PNG files.\")\n",
161
+ "\n",
162
+ " # Calculate expected duration\n",
163
+ " expected_duration = (num_images * frames_per_image) / fps\n",
164
+ " logger.info(f\"Expected duration: {expected_duration:.2f} seconds\")\n",
165
+ "\n",
166
+ " # Base FFmpeg command\n",
167
+ " ffmpeg_command = [\n",
168
+ " 'ffmpeg',\n",
169
+ " '-framerate', f'{1/(frames_per_image/fps)}', # Input framerate\n",
170
+ " '-i', os.path.join(input_folder, '%*.png'), # Input pattern for all PNG files\n",
171
+ " '-fps_mode', 'vfr',\n",
172
+ " ]\n",
173
+ "\n",
174
+ " # Codec-specific settings\n",
175
+ " if codec == 'ffv1':\n",
176
+ " output_file = output_file.rsplit('.', 1)[0] + '.mkv' # FFV1 is typically used with MKV container\n",
177
+ " ffmpeg_command.extend([\n",
178
+ " '-c:v', 'ffv1',\n",
179
+ " '-level', '3',\n",
180
+ " '-coder', '1',\n",
181
+ " '-context', '1',\n",
182
+ " '-g', '1',\n",
183
+ " '-slices', '24',\n",
184
+ " '-slicecrc', '1'\n",
185
+ " ])\n",
186
+ " logger.info(\"Using FFV1 codec (lossless)\")\n",
187
+ " elif codec == 'prores':\n",
188
+ " output_file = output_file.rsplit('.', 1)[0] + '.mov' # ProRes is typically used with MOV container\n",
189
+ " ffmpeg_command.extend([\n",
190
+ " '-c:v', 'prores_ks',\n",
191
+ " '-profile:v', 'proxy', # Use ProRes 422 Proxy profile\n",
192
+ " '-qscale:v', '11' # Adjust quality scale; higher values mean lower quality. 11 is typical for proxy quality.\n",
193
+ "])\n",
194
+ "\n",
195
+ " logger.info(\"Using ProRes codec (near-lossless)\")\n",
196
+ " else:\n",
197
+ " logger.error(f\"Unsupported codec: {codec}\")\n",
198
+ " return\n",
199
+ "\n",
200
+ " ffmpeg_command.extend(['-y', output_file])\n",
201
+ "\n",
202
+ " try:\n",
203
+ " logger.info(f\"Starting high-quality video creation with {codec} codec...\")\n",
204
+ " process = subprocess.Popen(ffmpeg_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)\n",
205
+ " \n",
206
+ " encoding_speed = None\n",
207
+ " \n",
208
+ " for line in process.stderr:\n",
209
+ " print(line, end='') # Print FFmpeg output in real-time\n",
210
+ " \n",
211
+ " speed_match = re.search(r'speed=\\s*([\\d.]+)x', line)\n",
212
+ " if speed_match:\n",
213
+ " encoding_speed = float(speed_match.group(1))\n",
214
+ " \n",
215
+ " process.wait()\n",
216
+ " \n",
217
+ " if encoding_speed:\n",
218
+ " logger.info(f\"Encoding speed: {encoding_speed:.4f}x\")\n",
219
+ " \n",
220
+ " if process.returncode == 0:\n",
221
+ " logger.info(f\"Video created successfully: {output_file}\")\n",
222
+ " \n",
223
+ " probe_command = ['ffprobe', '-v', 'error', '-show_entries', 'stream=codec_name,width,height,duration,bit_rate', '-of', 'default=noprint_wrappers=1', output_file]\n",
224
+ " probe_result = subprocess.run(probe_command, capture_output=True, text=True)\n",
225
+ " logger.info(f\"Video properties:\\n{probe_result.stdout}\")\n",
226
+ " \n",
227
+ " duration_command = ['ffprobe', '-v', 'error', '-show_entries', 'format=duration', '-of', 'default=noprint_wrappers=1:nokey=1', output_file]\n",
228
+ " duration_result = subprocess.run(duration_command, capture_output=True, text=True)\n",
229
+ " actual_duration = float(duration_result.stdout.strip())\n",
230
+ " logger.info(f\"Actual video duration: {actual_duration:.2f} seconds\")\n",
231
+ " if abs(actual_duration - expected_duration) > 1:\n",
232
+ " logger.warning(f\"Video duration mismatch. Expected: {expected_duration:.2f}, Actual: {actual_duration:.2f}\")\n",
233
+ " else:\n",
234
+ " logger.info(\"Video duration check passed.\")\n",
235
+ " else:\n",
236
+ " logger.error(f\"Error during video creation. FFmpeg returned code {process.returncode}\")\n",
237
+ "\n",
238
+ " except subprocess.CalledProcessError as e:\n",
239
+ " logger.error(f\"Error during video creation: {e}\")\n",
240
+ " logger.error(f\"FFmpeg error output:\\n{e.stderr}\")\n",
241
+ "\n",
242
+ "if __name__ == \"__main__\":\n",
243
+ " input_folder = 'train'\n",
244
+ " output_file = 'high_quality_output.mp4'\n",
245
+ " fps = 60\n",
246
+ " frames_per_image = 3\n",
247
+ " codec = 'prores' # Options: 'ffv1' (lossless) or 'prores' (near-lossless)\n",
248
+ "\n",
249
+ " create_high_quality_video(input_folder, output_file, fps, frames_per_image, codec)"
250
+ ]
251
+ }
252
+ ],
253
+ "metadata": {
254
+ "kernelspec": {
255
+ "display_name": "Python 3",
256
+ "language": "python",
257
+ "name": "python3"
258
+ },
259
+ "language_info": {
260
+ "codemirror_mode": {
261
+ "name": "ipython",
262
+ "version": 3
263
+ },
264
+ "file_extension": ".py",
265
+ "mimetype": "text/x-python",
266
+ "name": "python",
267
+ "nbconvert_exporter": "python",
268
+ "pygments_lexer": "ipython3",
269
+ "version": "3.10.14"
270
+ }
271
+ },
272
+ "nbformat": 4,
273
+ "nbformat_minor": 2
274
+ }
high_quality_output.mov ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fc424361abf95a0d587a9d1b8529a3d378688d3ef770e8eae13eb699a1a0fff1
3
+ size 237462852
image_metadata_extraction.ipynb ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "Dependencies"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": null,
13
+ "metadata": {},
14
+ "outputs": [],
15
+ "source": [
16
+ "pip install pillow datasets pandas pypng uuid\n"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "markdown",
21
+ "metadata": {},
22
+ "source": [
23
+ "Preproccessing"
24
+ ]
25
+ },
26
+ {
27
+ "cell_type": "code",
28
+ "execution_count": null,
29
+ "metadata": {},
30
+ "outputs": [],
31
+ "source": [
32
+ "import os\n",
33
+ "import uuid\n",
34
+ "import shutil\n",
35
+ "\n",
36
+ "def rename_and_move_images(source_dir, target_dir):\n",
37
+ " # Create the target directory if it doesn't exist\n",
38
+ " os.makedirs(target_dir, exist_ok=True)\n",
39
+ "\n",
40
+ " # List of common image file extensions\n",
41
+ " image_extensions = ('.jpg', '.jpeg', '.png', '.gif', '.bmp', '.tiff')\n",
42
+ "\n",
43
+ " # Walk through the source directory and its subdirectories\n",
44
+ " for root, dirs, files in os.walk(source_dir):\n",
45
+ " for file in files:\n",
46
+ " # Check if the file has an image extension\n",
47
+ " if file.lower().endswith(image_extensions):\n",
48
+ " # Generate a new filename with UUID\n",
49
+ " new_filename = str(uuid.uuid4()) + os.path.splitext(file)[1]\n",
50
+ " \n",
51
+ " # Construct full file paths\n",
52
+ " old_path = os.path.join(root, file)\n",
53
+ " new_path = os.path.join(target_dir, new_filename)\n",
54
+ " \n",
55
+ " # Move and rename the file\n",
56
+ " shutil.move(old_path, new_path)\n",
57
+ " print(f\"Moved and renamed: {old_path} -> {new_path}\")\n",
58
+ "\n",
59
+ "# Usage\n",
60
+ "source_directory = \"images\"\n",
61
+ "target_directory = \"train\"\n",
62
+ "\n",
63
+ "rename_and_move_images(source_directory, target_directory)"
64
+ ]
65
+ },
66
+ {
67
+ "cell_type": "markdown",
68
+ "metadata": {},
69
+ "source": [
70
+ "Extract the Metadata"
71
+ ]
72
+ },
73
+ {
74
+ "cell_type": "code",
75
+ "execution_count": null,
76
+ "metadata": {},
77
+ "outputs": [],
78
+ "source": [
79
+ "import os\n",
80
+ "import json\n",
81
+ "import png\n",
82
+ "import pandas as pd\n",
83
+ "\n",
84
+ "# Directory containing images\n",
85
+ "image_dir = 'train'\n",
86
+ "metadata_list = []\n",
87
+ "\n",
88
+ "# Function to extract the JSON data from the tEXt chunk in PNG images\n",
89
+ "def extract_metadata_from_png(image_path):\n",
90
+ " with open(image_path, 'rb') as f:\n",
91
+ " reader = png.Reader(file=f)\n",
92
+ " chunks = reader.chunks()\n",
93
+ " for chunk_type, chunk_data in chunks:\n",
94
+ " if chunk_type == b'tEXt':\n",
95
+ " # Convert bytes to string\n",
96
+ " chunk_text = chunk_data.decode('latin1')\n",
97
+ " if 'prompt' in chunk_text:\n",
98
+ " try:\n",
99
+ " # Extract JSON string after \"prompt\\0\"\n",
100
+ " json_str = chunk_text.split('prompt\\0', 1)[1]\n",
101
+ " json_data = json.loads(json_str)\n",
102
+ " inputs = json_data.get('3', {}).get('inputs', {})\n",
103
+ " seed = inputs.get('seed', 'N/A')\n",
104
+ " positive_prompt = json_data.get('6', {}).get('inputs', {}).get('text', 'N/A')\n",
105
+ " negative_prompt = json_data.get('7', {}).get('inputs', {}).get('text', 'N/A')\n",
106
+ " model = json_data.get('4', {}).get('inputs', {}).get('ckpt_name', 'N/A')\n",
107
+ " steps = inputs.get('steps', 'N/A')\n",
108
+ " cfg = inputs.get('cfg', 'N/A')\n",
109
+ " sampler_name = inputs.get('sampler_name', 'N/A')\n",
110
+ " scheduler = inputs.get('scheduler', 'N/A')\n",
111
+ " denoise = inputs.get('denoise', 'N/A')\n",
112
+ " return {\n",
113
+ " 'seed': seed,\n",
114
+ " 'positive_prompt': positive_prompt,\n",
115
+ " 'negative_prompt': negative_prompt,\n",
116
+ " 'model': model,\n",
117
+ " 'steps': steps,\n",
118
+ " 'cfg': cfg,\n",
119
+ " 'sampler_name': sampler_name,\n",
120
+ " 'scheduler': scheduler,\n",
121
+ " 'denoise': denoise\n",
122
+ " }\n",
123
+ " except json.JSONDecodeError:\n",
124
+ " pass\n",
125
+ " return {}\n",
126
+ "\n",
127
+ "# Loop through all images in the directory\n",
128
+ "for file_name in os.listdir(image_dir):\n",
129
+ " if file_name.endswith('.png'):\n",
130
+ " image_path = os.path.join(image_dir, file_name)\n",
131
+ " metadata = extract_metadata_from_png(image_path)\n",
132
+ " metadata['file_name'] = file_name\n",
133
+ " metadata_list.append(metadata)\n",
134
+ "\n",
135
+ "# Convert metadata to DataFrame\n",
136
+ "metadata_df = pd.DataFrame(metadata_list)\n",
137
+ "\n",
138
+ "# Ensure 'file_name' is the first column\n",
139
+ "columns_order = ['file_name', 'seed', 'positive_prompt', 'negative_prompt', 'model', 'steps', 'cfg', 'sampler_name', 'scheduler', 'denoise']\n",
140
+ "metadata_df = metadata_df[columns_order]\n",
141
+ "\n",
142
+ "# Save metadata to a CSV file\n",
143
+ "metadata_csv_path = 'train/metadata.csv'\n",
144
+ "metadata_df.to_csv(metadata_csv_path, index=False)\n",
145
+ "\n",
146
+ "print(\"Metadata extraction complete. Metadata saved to:\", metadata_csv_path)\n",
147
+ "\n",
148
+ "\n"
149
+ ]
150
+ }
151
+ ],
152
+ "metadata": {
153
+ "kernelspec": {
154
+ "display_name": "Python 3",
155
+ "language": "python",
156
+ "name": "python3"
157
+ },
158
+ "language_info": {
159
+ "codemirror_mode": {
160
+ "name": "ipython",
161
+ "version": 3
162
+ },
163
+ "file_extension": ".py",
164
+ "mimetype": "text/x-python",
165
+ "name": "python",
166
+ "nbconvert_exporter": "python",
167
+ "pygments_lexer": "ipython3",
168
+ "version": "3.10.14"
169
+ }
170
+ },
171
+ "nbformat": 4,
172
+ "nbformat_minor": 2
173
+ }
train/00455cd0-6372-41e6-9ec0-07e92a0c9a08.png ADDED

Git LFS Details

  • SHA256: ae5ffef5c9c1f0294d2c4685e4d95463c1d416d12c6afd6c22f4a3908e0e64c2
  • Pointer size: 132 Bytes
  • Size of remote file: 2.07 MB
train/0071a8c3-b16d-4de5-932b-d40b5b7661d1.png ADDED

Git LFS Details

  • SHA256: 4aeb898def0803557ce3e1591dcc27d53c63f94927dcf25a3dee7bd10b5da5c1
  • Pointer size: 132 Bytes
  • Size of remote file: 2.08 MB
train/0092e70e-e5d0-416f-a08d-738d823c0263.png ADDED

Git LFS Details

  • SHA256: e9a6af7be83db9b913a39895cc997c1aa77308772467f22b68efc81c3b879c6a
  • Pointer size: 132 Bytes
  • Size of remote file: 2.11 MB
train/00b6572d-cddd-401d-971a-6115b71bc71c.png ADDED

Git LFS Details

  • SHA256: 55e8d3761855af02849d6b1a0c8eedf64a48f507d5671897c34e93ba9a4ae14c
  • Pointer size: 132 Bytes
  • Size of remote file: 2.13 MB
train/00eafd43-d28d-4c33-b28a-899bd47da74a.png ADDED

Git LFS Details

  • SHA256: 4a25bba16fec0e71c095f7ed9605f4c5f964cf6fd3ec65d61435af9f6ab67195
  • Pointer size: 132 Bytes
  • Size of remote file: 2.11 MB
train/0154dcbe-9039-412b-af6c-53e25da0a86d.png ADDED

Git LFS Details

  • SHA256: e94aa9fbf2ac0ed4844e35ce2ef31c719b8583657150bf6350940343f7a2137e
  • Pointer size: 132 Bytes
  • Size of remote file: 2.13 MB
train/015dd218-e636-44d9-8664-26932c9999b0.png ADDED

Git LFS Details

  • SHA256: 96571497f1d35b75ffe7a8909839fe06ff8488a990551d2a1f6d6a5717650410
  • Pointer size: 132 Bytes
  • Size of remote file: 2.12 MB
train/015f9c37-62da-4756-b6f5-4e1c9d48f21a.png ADDED

Git LFS Details

  • SHA256: bff84c87425b2be8fc6f622b4324d3ed2e10b6b2f8fbe0129c8273e5fecb110b
  • Pointer size: 132 Bytes
  • Size of remote file: 2.22 MB
train/0178de63-7d50-4f3e-9a99-f14a71e07586.png ADDED

Git LFS Details

  • SHA256: db6767263b73ceb440963698e012c00c9d84a565e56f1ec8803d675abac371bf
  • Pointer size: 132 Bytes
  • Size of remote file: 2.23 MB
train/01d76e8e-10e6-4926-8c9b-2c23d7a84c5c.png ADDED

Git LFS Details

  • SHA256: 20fc09dac8600db65946920101717d5f4fce6d8abb17966a94f0efcb0d345f24
  • Pointer size: 132 Bytes
  • Size of remote file: 2.1 MB
train/02073830-7134-407a-8b6f-c734930164ea.png ADDED

Git LFS Details

  • SHA256: 6225a70b9654a69ea931c748d712442e9df4cf90586a2cb338f2b6e58ae75953
  • Pointer size: 132 Bytes
  • Size of remote file: 2.21 MB
train/02167913-42d2-4f78-9451-26e118d5270f.png ADDED

Git LFS Details

  • SHA256: b6b844705269c74ffbcef4ee8c02884801f4eec1cfbe82c32d27844ccde8bb00
  • Pointer size: 132 Bytes
  • Size of remote file: 1.99 MB
train/025e6153-83c1-4f6c-84eb-3cf176674699.png ADDED

Git LFS Details

  • SHA256: 6f50b486b3e9b2a36713392430b6ce3f2f56c49d0c0361327ed81e352815b573
  • Pointer size: 132 Bytes
  • Size of remote file: 2.12 MB
train/02609d0c-651c-4c18-b027-67a18efcb0e5.png ADDED

Git LFS Details

  • SHA256: 3d81be039b6c4212fff5a978c9ff8f8c8c9469b80f4f8f637008f8c5639799d7
  • Pointer size: 132 Bytes
  • Size of remote file: 2.26 MB
train/02773e2a-3abf-4669-abba-4102b3d9d149.png ADDED

Git LFS Details

  • SHA256: 8932ea1283bbd32f395f2036cc776b4307418f7246a14b523815617a76249cbf
  • Pointer size: 132 Bytes
  • Size of remote file: 2.19 MB
train/02b3ff90-1780-4ae1-81f9-64723d74a738.png ADDED

Git LFS Details

  • SHA256: d7082bcd10caddd45d7015d50752bcc438d1c59a374d1b290756ca904a948da6
  • Pointer size: 132 Bytes
  • Size of remote file: 2.19 MB
train/02b71c19-e6a8-46e0-975c-66089fdea26d.png ADDED

Git LFS Details

  • SHA256: efb035e0f7c6f3019b137badcca7212a6fd924f1fc56b8c53e957df219b5c070
  • Pointer size: 132 Bytes
  • Size of remote file: 2.13 MB
train/02c500de-33df-41fb-a39f-c16bfba4a015.png ADDED

Git LFS Details

  • SHA256: 6f18042be4c1e87da4e75bc1eb7d6a1648f444fb54076aa29a458334dd920c00
  • Pointer size: 132 Bytes
  • Size of remote file: 2.08 MB
train/02d28798-45ea-4890-9cf6-ecc3077ef93d.png ADDED

Git LFS Details

  • SHA256: 97aee99940d8520fcc8bf1773f9dfb37ab4f96777264f4947707bed3f1fe9b7b
  • Pointer size: 132 Bytes
  • Size of remote file: 2.2 MB
train/03485da8-fb49-4dc9-bbef-e4a2232c0181.png ADDED

Git LFS Details

  • SHA256: be9d7c2f4d4c965d19ae55fd6ab6d8b2ece039bddf07bbf9f79c58895abcf447
  • Pointer size: 132 Bytes
  • Size of remote file: 2.04 MB
train/034e5c87-f053-4cda-9d46-57652b174de7.png ADDED

Git LFS Details

  • SHA256: 6ca978530440c7004c7ce18e02c91bf7a9ecaad512769c82e49ae9e67c17c62a
  • Pointer size: 132 Bytes
  • Size of remote file: 2.09 MB
train/042d818e-065e-4e01-86cc-d91c49d7077c.png ADDED

Git LFS Details

  • SHA256: 6309461490ab58e564623e9006ed87c5d7c2a74f9ffeafc31ff13a382e41f731
  • Pointer size: 132 Bytes
  • Size of remote file: 2.08 MB
train/0441a292-e8b8-45ae-9817-efee1e5147e6.png ADDED

Git LFS Details

  • SHA256: 1c401aa6bf3c2af779bf599ccec6773f8c28b533c36335fc2c1ac0def14dbf87
  • Pointer size: 132 Bytes
  • Size of remote file: 2.25 MB
train/04695513-6b7f-41a7-a961-27db5ab03592.png ADDED

Git LFS Details

  • SHA256: 93995ad57b4517f4036a81f01192bdddc787fd352b6aacaa85b86eb00fa47fc5
  • Pointer size: 132 Bytes
  • Size of remote file: 2.25 MB
train/04d2ae96-443b-4cbd-873f-e60a769e29a5.png ADDED

Git LFS Details

  • SHA256: 229ae3906249e644c9645011252c6583b73d4681474f754b5cc60f7f799dccd1
  • Pointer size: 132 Bytes
  • Size of remote file: 2.12 MB
train/04d69896-054c-4762-b8e7-327cdb31503d.png ADDED

Git LFS Details

  • SHA256: 248a87509ea34e327d82665796e23a28d58260505bf28fd44d4007a9679ebb5e
  • Pointer size: 132 Bytes
  • Size of remote file: 1.88 MB
train/04d9fd59-4440-4777-b944-f065d56677cb.png ADDED

Git LFS Details

  • SHA256: c7dcafb258b92857453cbbf486b0b3064fbe28408ed0205ed55f93331fde7f9c
  • Pointer size: 132 Bytes
  • Size of remote file: 2.16 MB
train/04e08d0a-f33a-4355-b45b-d456e1bb555d.png ADDED

Git LFS Details

  • SHA256: 0bab8953a03dc46234adc81329fc3d2e2276db9895423ae6841602de916825ee
  • Pointer size: 132 Bytes
  • Size of remote file: 2.09 MB
train/0504a319-4408-4d31-b842-5760fec46e7e.png ADDED

Git LFS Details

  • SHA256: 23f7ef182999cb4b46dab06e3df8c9b08844ad9e38e5bda1f718ab1689a3047a
  • Pointer size: 132 Bytes
  • Size of remote file: 2.14 MB
train/0528732a-2f4a-403d-90d1-e7e46d927bb6.png ADDED

Git LFS Details

  • SHA256: e7a8040deb96a6d42e3a7a00dcf6b4defd873db00d56540599e2fe02b3b0ad9e
  • Pointer size: 132 Bytes
  • Size of remote file: 2.22 MB
train/05d01729-6ced-4b22-a492-352443dcc74c.png ADDED

Git LFS Details

  • SHA256: cf4a9af46ae61a8040c2c681cc61b95040928852cb66a9d1d7e2b5c114268ba7
  • Pointer size: 132 Bytes
  • Size of remote file: 2.05 MB
train/0604dbd4-890d-4d99-b3fb-ee5ad4efd3b4.png ADDED

Git LFS Details

  • SHA256: f720a9288ee7f22236bfe348bbbf53a337d05d9073f79f0db854d69ca9497838
  • Pointer size: 132 Bytes
  • Size of remote file: 2.07 MB
train/06067581-a0aa-4525-8d36-3c4b329ac151.png ADDED

Git LFS Details

  • SHA256: 9a10f3521581c357d0e1c79f9952e25cc4d0b2ddc9452c1c5fe0772f09749b75
  • Pointer size: 132 Bytes
  • Size of remote file: 2.06 MB
train/06625d12-86ba-4028-9a71-097186bbb754.png ADDED

Git LFS Details

  • SHA256: b43e1325b595cc255eb6c58c9bba65490854c09094a981a89b9725637994373c
  • Pointer size: 132 Bytes
  • Size of remote file: 2.1 MB
train/06813f46-dd8f-4421-87c8-322399ac69f5.png ADDED

Git LFS Details

  • SHA256: 65a1b6725074c63f9e9af6be1811109b608d931755900f716533ed7dbdee7bb4
  • Pointer size: 132 Bytes
  • Size of remote file: 2.24 MB
train/06ae6eb9-0fda-4964-bc06-43853616a584.png ADDED

Git LFS Details

  • SHA256: 99c7195e251caf7cb5be9fcb7cc0d8ab1a9c4a35b2535eea36b36277e974d662
  • Pointer size: 132 Bytes
  • Size of remote file: 2.05 MB
train/07970142-cc85-4a30-9fa6-3bf45f43f32d.png ADDED

Git LFS Details

  • SHA256: ba761381a98c1ce1662bea92735368bdcaf6e4be870ba6ff45bca87658de2d55
  • Pointer size: 132 Bytes
  • Size of remote file: 2.11 MB
train/0798fb4c-927a-4a11-beb8-538e8c854cd5.png ADDED

Git LFS Details

  • SHA256: df523fa0116267f5103f4e84e36bf9947b8607f682533c67ec21930592a91b7b
  • Pointer size: 132 Bytes
  • Size of remote file: 2.13 MB
train/07a05d0f-55a9-4728-ab2e-ed069e96fe88.png ADDED

Git LFS Details

  • SHA256: a325225732c1aca8e2c123699409e6d6a6afc170a3d5ec0c44f131f0b7353aa5
  • Pointer size: 132 Bytes
  • Size of remote file: 2.15 MB
train/0846f615-28ff-448a-9ad6-2a43ffc6d823.png ADDED

Git LFS Details

  • SHA256: fc36d8382c6b72e277acc4d0d5699771c9d99baaf34d8f643a43bf92fdcd7ec0
  • Pointer size: 132 Bytes
  • Size of remote file: 2.16 MB
train/086b80d5-0621-4bb6-b7b6-a3767b2fbc5b.png ADDED

Git LFS Details

  • SHA256: 949a05e71c4eed7d9146c1aa9868b85954ce72b5390051a99de2fa6f1c2c0f63
  • Pointer size: 132 Bytes
  • Size of remote file: 2.05 MB
train/087d553d-bf95-4150-b481-542b473cb223.png ADDED

Git LFS Details

  • SHA256: 6230667c08d00ded2b602a903872766de9d3d8ec7b59f4d176236778f5e82eea
  • Pointer size: 132 Bytes
  • Size of remote file: 2.17 MB
train/08eb296e-f91f-4da4-abfb-0015d4340167.png ADDED

Git LFS Details

  • SHA256: 1ad0cb272b7e44796a3eb4b4f0cae3aa9b4c79c4fdaa6737ec8878366516174f
  • Pointer size: 132 Bytes
  • Size of remote file: 2.04 MB
train/092558b5-f573-4882-9184-6a64168878a9.png ADDED

Git LFS Details

  • SHA256: 5bab2034b01dc7a97c8672ca679da59ff445106b9d8810ba1e5face8a5355334
  • Pointer size: 132 Bytes
  • Size of remote file: 2.15 MB
train/095baeaf-8285-44a4-a573-3283259b8d0c.png ADDED

Git LFS Details

  • SHA256: 77802a8b5366a8f67a84294f68d3bcc341adf655f388d5ee391795d18d1282bb
  • Pointer size: 132 Bytes
  • Size of remote file: 2.17 MB