Update diffusiondb_prompts_and_images_dataset.py
Browse files
diffusiondb_prompts_and_images_dataset.py
CHANGED
@@ -52,27 +52,27 @@ Demo dataset for testing or showing image-text capabilities.
|
|
52 |
]
|
53 |
|
54 |
def _generate_examples(self, images, parquet_file):
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
# Create a dictionary from the dataframe for faster lookup
|
59 |
-
df_dict = df.set_index('path').to_dict(orient='index')
|
60 |
-
|
61 |
-
for filepath, image in images:
|
62 |
-
image_name = filepath.split('/')[-1]
|
63 |
-
image_key = f"DiffusionDBImages/{image_name}"
|
64 |
|
65 |
-
#
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
# def _generate_examples(self, images, parquet_file):
|
78 |
# df = pd.read_parquet(parquet_file)
|
|
|
52 |
]
|
53 |
|
54 |
def _generate_examples(self, images, parquet_file):
|
55 |
+
df = pd.read_parquet(parquet_file)
|
56 |
+
idx_counter = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
+
# Create a dictionary from the dataframe for faster lookup
|
59 |
+
df_dict = df.set_index('path').to_dict(orient='index')
|
60 |
+
|
61 |
+
for filepath, image in images:
|
62 |
+
image_name = filepath.split('/')[-1]
|
63 |
+
image_key = f"DiffusionDBImages/{image_name}"
|
64 |
+
|
65 |
+
# Check if the image_key exists in the dictionary
|
66 |
+
if image_key in df_dict:
|
67 |
+
row = df_dict[image_key]
|
68 |
+
yield idx_counter, {
|
69 |
+
"prompt": row['prompt'],
|
70 |
+
"seed": row['seed'],
|
71 |
+
"cfg": row['cfg'],
|
72 |
+
"step": row['step'],
|
73 |
+
"image": {"path": filepath, "bytes": image.read()},
|
74 |
+
}
|
75 |
+
idx_counter += 1
|
76 |
|
77 |
# def _generate_examples(self, images, parquet_file):
|
78 |
# df = pd.read_parquet(parquet_file)
|