Jordan Legg commited on
Commit
2acbc78
1 Parent(s): 91ce691

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/00119902-0714-460c-b8fc-b4eb327a77a3.png +3 -0
  7. train/004d836c-c87a-4aaf-a112-3bbbe3d184c7.png +3 -0
  8. train/00540137-69ca-4c68-b2a0-297075b089df.png +3 -0
  9. train/0065038b-d7a3-4db7-821d-e75fe9d10ac1.png +3 -0
  10. train/00a0d324-8508-4a51-a7e1-d1033ffec3dc.png +3 -0
  11. train/00efef96-bdf0-421c-8d2c-3ace28cf7de9.png +3 -0
  12. train/0103c814-27a9-43c5-933f-7d879e25b5e6.png +3 -0
  13. train/0134a19f-ff9c-47ab-924d-ac382b555c4b.png +3 -0
  14. train/014fbac0-aa1a-467f-9eaf-3e2a7c202247.png +3 -0
  15. train/025b6773-c2b3-430e-aad8-c1090f78633f.png +3 -0
  16. train/03315146-a7a6-49c8-b3cc-18cc6ce05f81.png +3 -0
  17. train/040879b2-eb9f-4bb6-8c76-b0e117cd7256.png +3 -0
  18. train/049b0e1c-751f-4081-b45f-27faf7870516.png +3 -0
  19. train/04e76e54-7922-4a12-b0c3-268ce5842b86.png +3 -0
  20. train/04f39c69-3e65-464c-a087-2360cfc19feb.png +3 -0
  21. train/0568f526-0ce1-48fd-853c-3470d68c34e9.png +3 -0
  22. train/05782464-c82d-441e-9cfe-ad7a1dde542b.png +3 -0
  23. train/0582f238-82df-4de8-b5d2-3e65735e0f08.png +3 -0
  24. train/06506339-02ab-433a-bbee-2c920a63c99e.png +3 -0
  25. train/07437720-0c8d-42e7-aae5-9b5a7f431cc2.png +3 -0
  26. train/0836bbf3-9fe5-4166-b271-d618919bc9dd.png +3 -0
  27. train/08456a2f-3a2c-4a90-b045-7ebd54d2bdcd.png +3 -0
  28. train/08cc6d3d-8ad6-42c8-b8f7-daee58f15a43.png +3 -0
  29. train/08d40d90-ba0f-4a32-a11a-7c20be8bd252.png +3 -0
  30. train/09606650-24f8-4c44-ada7-eed4133a76f9.png +3 -0
  31. train/0974d829-5fb2-4d94-80d5-4a0851c652f2.png +3 -0
  32. train/09c0cff9-6ec1-4f37-95ff-bc1fd4cc0e44.png +3 -0
  33. train/09f736d1-f167-45ed-8b87-b4f0af680919.png +3 -0
  34. train/0a628361-f2ad-48f7-8907-374c566056c7.png +3 -0
  35. train/0ae1e041-261a-4ae6-87fd-7b2c674c81af.png +3 -0
  36. train/0ae8311c-21f9-4607-894d-d0796be154b9.png +3 -0
  37. train/0b11f834-71ea-44a8-b60a-94535fc60ce0.png +3 -0
  38. train/0bc1ddfd-9ae7-431c-be79-c10bf15ca9be.png +3 -0
  39. train/0ca6ddfc-66f5-4fbf-b860-94ccb2dbac73.png +3 -0
  40. train/0caa73cf-b101-444d-9b85-21d36d6830dd.png +3 -0
  41. train/0d2c4c3e-1998-4f81-8e66-1569ada96a1b.png +3 -0
  42. train/0daed586-117b-47a9-8499-bf1bd5f935cf.png +3 -0
  43. train/0dc71e34-4893-4357-b45a-7f7cf5c8fcb2.png +3 -0
  44. train/0e8ec68c-1d1d-43e2-9713-893e69e2796b.png +3 -0
  45. train/0e93811e-e2b0-47db-a878-7a6b646702fb.png +3 -0
  46. train/0ea92cb2-fb86-4453-8422-4883f0a19e00.png +3 -0
  47. train/0eb637f6-70e0-40a6-9a0c-4fad1697ea9a.png +3 -0
  48. train/0ed8012f-45d7-427b-af70-653542eddfb1.png +3 -0
  49. train/0ee5d466-b731-48b2-9128-079634b79488.png +3 -0
  50. train/0f8b6afb-7435-433f-8d87-790db001d6a0.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:bacd140c74b1ef620fae8a4e8d9faf2cf29bba5502c1d8e81dd93ed32a50a67c
3
+ size 127237430
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/00119902-0714-460c-b8fc-b4eb327a77a3.png ADDED

Git LFS Details

  • SHA256: 0535befa1b5b7fca41d2fafba6b76045b662e7dcb2cc735c8f7a09f5365937b5
  • Pointer size: 132 Bytes
  • Size of remote file: 1.88 MB
train/004d836c-c87a-4aaf-a112-3bbbe3d184c7.png ADDED

Git LFS Details

  • SHA256: 5396968fdb393dea22517708ce5b4beebca7ed058c820c1a0dbe517152f0ed67
  • Pointer size: 132 Bytes
  • Size of remote file: 1.77 MB
train/00540137-69ca-4c68-b2a0-297075b089df.png ADDED

Git LFS Details

  • SHA256: 02e96dea22afe77f2fdf768a55e19b7e8cd98b82eb5473094f99b426d06e9f8f
  • Pointer size: 132 Bytes
  • Size of remote file: 1.78 MB
train/0065038b-d7a3-4db7-821d-e75fe9d10ac1.png ADDED

Git LFS Details

  • SHA256: 71e60459a2767951096fc4590539a9b1c445f8c9284b66f8efe7eb561e41d798
  • Pointer size: 132 Bytes
  • Size of remote file: 1.76 MB
train/00a0d324-8508-4a51-a7e1-d1033ffec3dc.png ADDED

Git LFS Details

  • SHA256: 87cd7f796b48028bd7db625f1150916b13683bad750fa28a51fd3d94c002e72a
  • Pointer size: 132 Bytes
  • Size of remote file: 1.85 MB
train/00efef96-bdf0-421c-8d2c-3ace28cf7de9.png ADDED

Git LFS Details

  • SHA256: 5f80b7487435497b365d0df6db96574a7c3fd58946c09c6666c40a28b8e595ad
  • Pointer size: 132 Bytes
  • Size of remote file: 1.82 MB
train/0103c814-27a9-43c5-933f-7d879e25b5e6.png ADDED

Git LFS Details

  • SHA256: f703ca37f1fe2a94c67f0699bafe8a9e4c6d6582a08d966785cd49ba2a23a7f8
  • Pointer size: 132 Bytes
  • Size of remote file: 1.8 MB
train/0134a19f-ff9c-47ab-924d-ac382b555c4b.png ADDED

Git LFS Details

  • SHA256: 5e1e5db855f9cf806e9616387aac82c9592ca1f35d8e5a1ef920c0ecbd3b0e42
  • Pointer size: 132 Bytes
  • Size of remote file: 2 MB
train/014fbac0-aa1a-467f-9eaf-3e2a7c202247.png ADDED

Git LFS Details

  • SHA256: cc68e2e2708b9b592c759d9425fde117526b842b76da23d5280bf0a66631b6f5
  • Pointer size: 132 Bytes
  • Size of remote file: 1.78 MB
train/025b6773-c2b3-430e-aad8-c1090f78633f.png ADDED

Git LFS Details

  • SHA256: 646ff441121ae09c271d7663db927326d6aa5c4273af2703dd9e8ee02c5300c5
  • Pointer size: 132 Bytes
  • Size of remote file: 1.76 MB
train/03315146-a7a6-49c8-b3cc-18cc6ce05f81.png ADDED

Git LFS Details

  • SHA256: d7f20478d237a843afe325fefe89da92a97995adacd87a9efdfde4c9c7953567
  • Pointer size: 132 Bytes
  • Size of remote file: 1.7 MB
train/040879b2-eb9f-4bb6-8c76-b0e117cd7256.png ADDED

Git LFS Details

  • SHA256: 61b9984001d871e44d6cd6005023e3b320f4d3c4f626913de0e9240abb494077
  • Pointer size: 132 Bytes
  • Size of remote file: 1.85 MB
train/049b0e1c-751f-4081-b45f-27faf7870516.png ADDED

Git LFS Details

  • SHA256: 20684682ac28830a33922716623b359c6100435546470a0c32818f8b5bbff9fc
  • Pointer size: 132 Bytes
  • Size of remote file: 1.69 MB
train/04e76e54-7922-4a12-b0c3-268ce5842b86.png ADDED

Git LFS Details

  • SHA256: 44edc62050498d0db2525072e22a1195bb6b97b72f0804ad96f8cc631295f034
  • Pointer size: 132 Bytes
  • Size of remote file: 1.96 MB
train/04f39c69-3e65-464c-a087-2360cfc19feb.png ADDED

Git LFS Details

  • SHA256: bb2d6b6eb656a44971ec15bf3fa69efd6d6ca3861c3087c663f82fb1bbb33b06
  • Pointer size: 132 Bytes
  • Size of remote file: 1.9 MB
train/0568f526-0ce1-48fd-853c-3470d68c34e9.png ADDED

Git LFS Details

  • SHA256: 06714879009e1696607f64371383c58ebcd8b87e53f610c2162fa40bd684f313
  • Pointer size: 132 Bytes
  • Size of remote file: 1.81 MB
train/05782464-c82d-441e-9cfe-ad7a1dde542b.png ADDED

Git LFS Details

  • SHA256: 89ee4f38044a837bfd31fa71e708a9a0ec9443275e14d9d767114904df55a416
  • Pointer size: 132 Bytes
  • Size of remote file: 1.9 MB
train/0582f238-82df-4de8-b5d2-3e65735e0f08.png ADDED

Git LFS Details

  • SHA256: dd2791ce3ceef2bcfa5d3511240bf316fba3802419d9b95413c822a3747c2763
  • Pointer size: 132 Bytes
  • Size of remote file: 1.83 MB
train/06506339-02ab-433a-bbee-2c920a63c99e.png ADDED

Git LFS Details

  • SHA256: 974dcc96a7a57461549361b6c4dcf732d84e50fd9499da96d5fbd2d6495416af
  • Pointer size: 132 Bytes
  • Size of remote file: 1.96 MB
train/07437720-0c8d-42e7-aae5-9b5a7f431cc2.png ADDED

Git LFS Details

  • SHA256: 14e31deac1789c31fd2ee5069ced94538981dcbd18314647275075adde485f02
  • Pointer size: 132 Bytes
  • Size of remote file: 1.87 MB
train/0836bbf3-9fe5-4166-b271-d618919bc9dd.png ADDED

Git LFS Details

  • SHA256: cbd3a323203ae52c4f9cf9979b1871e1f416358266be61548ea826b6a5152316
  • Pointer size: 132 Bytes
  • Size of remote file: 1.93 MB
train/08456a2f-3a2c-4a90-b045-7ebd54d2bdcd.png ADDED

Git LFS Details

  • SHA256: 497d6c0cdc36de7424e59b8b21e1665ca7512b33cad83adc9645a2990aa94a7b
  • Pointer size: 132 Bytes
  • Size of remote file: 2.02 MB
train/08cc6d3d-8ad6-42c8-b8f7-daee58f15a43.png ADDED

Git LFS Details

  • SHA256: fc28cb0b85c3a01d77be4731422a3e33e4373de7357640a9378c4a0800b62c34
  • Pointer size: 132 Bytes
  • Size of remote file: 1.75 MB
train/08d40d90-ba0f-4a32-a11a-7c20be8bd252.png ADDED

Git LFS Details

  • SHA256: 7c199f3047a4b26113fa8922afd584bf60b729605e9c420bf326690a4ad61e27
  • Pointer size: 132 Bytes
  • Size of remote file: 1.97 MB
train/09606650-24f8-4c44-ada7-eed4133a76f9.png ADDED

Git LFS Details

  • SHA256: 4b7a1d234560e3dcefbd18724627e6d57b18fa45a2ac00284162d383cbb6a0a8
  • Pointer size: 132 Bytes
  • Size of remote file: 1.86 MB
train/0974d829-5fb2-4d94-80d5-4a0851c652f2.png ADDED

Git LFS Details

  • SHA256: fe31b2cb753511bcad2cb8698b0520ea3c74f86545725d095d8bb6dfa4d62e78
  • Pointer size: 132 Bytes
  • Size of remote file: 1.76 MB
train/09c0cff9-6ec1-4f37-95ff-bc1fd4cc0e44.png ADDED

Git LFS Details

  • SHA256: 6a24ce543ae7517ab09feb559042763d3c14ef74e36e01d7c66eafdaf2fe1255
  • Pointer size: 132 Bytes
  • Size of remote file: 1.57 MB
train/09f736d1-f167-45ed-8b87-b4f0af680919.png ADDED

Git LFS Details

  • SHA256: eedb0f66ee54d409bfc3ee6f4ba183a36e4698a73c82f7879753ff7eb0813549
  • Pointer size: 132 Bytes
  • Size of remote file: 1.75 MB
train/0a628361-f2ad-48f7-8907-374c566056c7.png ADDED

Git LFS Details

  • SHA256: 6d6e012148ee7b0a2f23617088795f51da95b3118acb95ee1e68886a7348829c
  • Pointer size: 132 Bytes
  • Size of remote file: 1.85 MB
train/0ae1e041-261a-4ae6-87fd-7b2c674c81af.png ADDED

Git LFS Details

  • SHA256: 77d258d29ba598556a9f18da7c65b152922ed8fea2cf49ea9e29efa140dd1def
  • Pointer size: 132 Bytes
  • Size of remote file: 1.87 MB
train/0ae8311c-21f9-4607-894d-d0796be154b9.png ADDED

Git LFS Details

  • SHA256: 877adb54c5dfc03230b3e82ed2d535da5719a7e76e604f5a10f1632c9c7e3ad1
  • Pointer size: 132 Bytes
  • Size of remote file: 1.85 MB
train/0b11f834-71ea-44a8-b60a-94535fc60ce0.png ADDED

Git LFS Details

  • SHA256: dd09da15861d390f7ba2faf724658ec1f03fcda9a481693f28eec9827bb6baaa
  • Pointer size: 132 Bytes
  • Size of remote file: 1.72 MB
train/0bc1ddfd-9ae7-431c-be79-c10bf15ca9be.png ADDED

Git LFS Details

  • SHA256: df4fe2f884d0dc7cc4534b1531c36694835383f40cad086733b23f44827b412f
  • Pointer size: 132 Bytes
  • Size of remote file: 1.94 MB
train/0ca6ddfc-66f5-4fbf-b860-94ccb2dbac73.png ADDED

Git LFS Details

  • SHA256: 9978f091fb0ccd5ea8030d55087091f7b87b4ae4b56011e2e6f282bf19132800
  • Pointer size: 132 Bytes
  • Size of remote file: 1.75 MB
train/0caa73cf-b101-444d-9b85-21d36d6830dd.png ADDED

Git LFS Details

  • SHA256: b3056589d2c0e0e552b9d913d9617ad54618862f8a2f3369e821f8cc92c35d66
  • Pointer size: 132 Bytes
  • Size of remote file: 1.72 MB
train/0d2c4c3e-1998-4f81-8e66-1569ada96a1b.png ADDED

Git LFS Details

  • SHA256: 1c0a54b66d68a090060ac812d6b868d2a2ac3f174822c9ea2dd8ff93726e9674
  • Pointer size: 132 Bytes
  • Size of remote file: 1.93 MB
train/0daed586-117b-47a9-8499-bf1bd5f935cf.png ADDED

Git LFS Details

  • SHA256: 39c107be2abd65ae78e6f0443d53b4acda2d3b1c189b1284e65849ad3779a9fb
  • Pointer size: 132 Bytes
  • Size of remote file: 1.71 MB
train/0dc71e34-4893-4357-b45a-7f7cf5c8fcb2.png ADDED

Git LFS Details

  • SHA256: 414452b596ade11d70e33e04292a2ca823554bc285ae9a4fe90632391b07301f
  • Pointer size: 132 Bytes
  • Size of remote file: 1.78 MB
train/0e8ec68c-1d1d-43e2-9713-893e69e2796b.png ADDED

Git LFS Details

  • SHA256: 10a54e278b7ec96c00688697c6464d960e6ee421f47465fae03ce494c98aaebf
  • Pointer size: 132 Bytes
  • Size of remote file: 1.77 MB
train/0e93811e-e2b0-47db-a878-7a6b646702fb.png ADDED

Git LFS Details

  • SHA256: 6b891413451a95a50c2e667d8bc57167cb07c81b7ddc8b25d45fbf18598f7b83
  • Pointer size: 132 Bytes
  • Size of remote file: 2.06 MB
train/0ea92cb2-fb86-4453-8422-4883f0a19e00.png ADDED

Git LFS Details

  • SHA256: ebfa8ee79d793bd500a8746d5a07ddc6c0f5a391a06f6dd56c274976a952d497
  • Pointer size: 132 Bytes
  • Size of remote file: 1.7 MB
train/0eb637f6-70e0-40a6-9a0c-4fad1697ea9a.png ADDED

Git LFS Details

  • SHA256: cc7b5f7f5dc2570a71cfc620ff7f3922b4c0780b93b498a50f170c153aa8b164
  • Pointer size: 132 Bytes
  • Size of remote file: 2.01 MB
train/0ed8012f-45d7-427b-af70-653542eddfb1.png ADDED

Git LFS Details

  • SHA256: 9fa79f5be34f15b4e0c799342390dc17c62521021609040394915c16fe306395
  • Pointer size: 132 Bytes
  • Size of remote file: 1.66 MB
train/0ee5d466-b731-48b2-9128-079634b79488.png ADDED

Git LFS Details

  • SHA256: 6020f9b11b8f6bdff3d8b5043b1cb8b64b3dfed4944a62749c102d2a5ea6b3df
  • Pointer size: 132 Bytes
  • Size of remote file: 1.91 MB
train/0f8b6afb-7435-433f-8d87-790db001d6a0.png ADDED

Git LFS Details

  • SHA256: e27bf64b3b35e792d068cfbc5c475ee8ae322e822a15a931abecf05f428d5fdb
  • Pointer size: 132 Bytes
  • Size of remote file: 1.83 MB