Fix DeepFashion startup on hyperview 0.6.1
Browse files
demo.py
CHANGED
|
@@ -221,12 +221,19 @@ def select_deepfashion_records() -> list[dict[str, Any]]:
|
|
| 221 |
def add_deepfashion_samples(dataset: hv.Dataset) -> None:
|
| 222 |
existing_ids = {sample.id for sample in dataset.samples}
|
| 223 |
media_dir = media_root()
|
| 224 |
-
|
|
|
|
|
|
|
| 225 |
records = select_deepfashion_records()
|
| 226 |
|
| 227 |
for record in records:
|
| 228 |
item_id = str(record["item_ID"])
|
| 229 |
sample_id = safe_sample_id(item_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
destination = media_dir / f"{sample_id}.jpg"
|
| 231 |
save_image(record["image"], destination)
|
| 232 |
category = readable(record.get("category2") or "unknown").lower()
|
|
@@ -243,25 +250,13 @@ def add_deepfashion_samples(dataset: hv.Dataset) -> None:
|
|
| 243 |
"source_dataset": HF_DATASET,
|
| 244 |
"split": HF_SPLIT,
|
| 245 |
}
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
}
|
| 253 |
-
)
|
| 254 |
|
| 255 |
-
upserted, skipped_existing = dataset.add_images(
|
| 256 |
-
image_rows,
|
| 257 |
-
skip_existing=not FORCE_SAMPLE_REFRESH,
|
| 258 |
-
)
|
| 259 |
-
updated = (
|
| 260 |
-
sum(1 for row in image_rows if str(row["sample_id"]) in existing_ids)
|
| 261 |
-
if FORCE_SAMPLE_REFRESH
|
| 262 |
-
else 0
|
| 263 |
-
)
|
| 264 |
-
added = upserted - updated
|
| 265 |
if skipped_existing:
|
| 266 |
print(f"Skipped {skipped_existing} existing DeepFashion sample rows.", flush=True)
|
| 267 |
print(f"Prepared DeepFashion samples ({added} added, {updated} updated).", flush=True)
|
|
|
|
| 221 |
def add_deepfashion_samples(dataset: hv.Dataset) -> None:
|
| 222 |
existing_ids = {sample.id for sample in dataset.samples}
|
| 223 |
media_dir = media_root()
|
| 224 |
+
added = 0
|
| 225 |
+
updated = 0
|
| 226 |
+
skipped_existing = 0
|
| 227 |
records = select_deepfashion_records()
|
| 228 |
|
| 229 |
for record in records:
|
| 230 |
item_id = str(record["item_ID"])
|
| 231 |
sample_id = safe_sample_id(item_id)
|
| 232 |
+
existed = sample_id in existing_ids
|
| 233 |
+
if existed and not FORCE_SAMPLE_REFRESH:
|
| 234 |
+
skipped_existing += 1
|
| 235 |
+
continue
|
| 236 |
+
|
| 237 |
destination = media_dir / f"{sample_id}.jpg"
|
| 238 |
save_image(record["image"], destination)
|
| 239 |
category = readable(record.get("category2") or "unknown").lower()
|
|
|
|
| 250 |
"source_dataset": HF_DATASET,
|
| 251 |
"split": HF_SPLIT,
|
| 252 |
}
|
| 253 |
+
dataset.add_image(str(destination), label=category, metadata=metadata, sample_id=sample_id)
|
| 254 |
+
if existed:
|
| 255 |
+
updated += 1
|
| 256 |
+
else:
|
| 257 |
+
existing_ids.add(sample_id)
|
| 258 |
+
added += 1
|
|
|
|
|
|
|
| 259 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
if skipped_existing:
|
| 261 |
print(f"Skipped {skipped_existing} existing DeepFashion sample rows.", flush=True)
|
| 262 |
print(f"Prepared DeepFashion samples ({added} added, {updated} updated).", flush=True)
|