Fix DeepFashion sample ingest for HyperView 0.6.2
Browse files
demo.py
CHANGED
|
@@ -14,6 +14,7 @@ from datasets import load_dataset
|
|
| 14 |
from PIL import Image, ImageOps
|
| 15 |
|
| 16 |
import hyperview as hv
|
|
|
|
| 17 |
|
| 18 |
SPACE_DIR = Path(__file__).resolve().parent
|
| 19 |
SPACE_HOST = os.environ.get("HYPERVIEW_HOST", "127.0.0.1")
|
|
@@ -231,6 +232,7 @@ def add_deepfashion_samples(dataset: hv.Dataset) -> None:
|
|
| 231 |
updated = 0
|
| 232 |
skipped_existing = 0
|
| 233 |
records = select_deepfashion_records()
|
|
|
|
| 234 |
|
| 235 |
for record in records:
|
| 236 |
item_id = str(record["item_ID"])
|
|
@@ -256,13 +258,22 @@ def add_deepfashion_samples(dataset: hv.Dataset) -> None:
|
|
| 256 |
"source_dataset": HF_DATASET,
|
| 257 |
"split": HF_SPLIT,
|
| 258 |
}
|
| 259 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
if existed:
|
| 261 |
updated += 1
|
| 262 |
else:
|
| 263 |
existing_ids.add(sample_id)
|
| 264 |
added += 1
|
| 265 |
|
|
|
|
|
|
|
| 266 |
if skipped_existing:
|
| 267 |
print(f"Skipped {skipped_existing} existing DeepFashion sample rows.", flush=True)
|
| 268 |
print(f"Prepared DeepFashion samples ({added} added, {updated} updated).", flush=True)
|
|
|
|
| 14 |
from PIL import Image, ImageOps
|
| 15 |
|
| 16 |
import hyperview as hv
|
| 17 |
+
from hyperview.core.sample import Sample
|
| 18 |
|
| 19 |
SPACE_DIR = Path(__file__).resolve().parent
|
| 20 |
SPACE_HOST = os.environ.get("HYPERVIEW_HOST", "127.0.0.1")
|
|
|
|
| 232 |
updated = 0
|
| 233 |
skipped_existing = 0
|
| 234 |
records = select_deepfashion_records()
|
| 235 |
+
samples: list[Sample] = []
|
| 236 |
|
| 237 |
for record in records:
|
| 238 |
item_id = str(record["item_ID"])
|
|
|
|
| 258 |
"source_dataset": HF_DATASET,
|
| 259 |
"split": HF_SPLIT,
|
| 260 |
}
|
| 261 |
+
samples.append(
|
| 262 |
+
Sample(
|
| 263 |
+
id=sample_id,
|
| 264 |
+
filepath=str(destination),
|
| 265 |
+
label=category,
|
| 266 |
+
metadata=metadata,
|
| 267 |
+
)
|
| 268 |
+
)
|
| 269 |
if existed:
|
| 270 |
updated += 1
|
| 271 |
else:
|
| 272 |
existing_ids.add(sample_id)
|
| 273 |
added += 1
|
| 274 |
|
| 275 |
+
dataset.add_samples(samples, skip_existing=False)
|
| 276 |
+
|
| 277 |
if skipped_existing:
|
| 278 |
print(f"Skipped {skipped_existing} existing DeepFashion sample rows.", flush=True)
|
| 279 |
print(f"Prepared DeepFashion samples ({added} added, {updated} updated).", flush=True)
|