github-actions[bot] commited on
Commit
713d895
·
1 Parent(s): 9175688

Deploy hyper3labs/HyperView-ABO-Catalog from Hyper3Labs/hyperview-spaces@67594d4

Browse files
.hyperview/extensions/abo-catalog-readout/panel.js CHANGED
@@ -35,7 +35,6 @@ function normalizeModels(value) {
35
  key: String(model.key || `model-${index}`),
36
  displayName: String(model.displayName || model.display_name || model.key || `Model ${index + 1}`),
37
  layoutKey: model.layoutKey || model.layout_key || null,
38
- spaceKey: model.spaceKey || model.space_key || null,
39
  }))
40
  .filter((model) => model.layoutKey);
41
  }
@@ -732,7 +731,6 @@ export default function CatalogComparisonPanel() {
732
  await commands.showSimilar({
733
  sampleId: item.queryId,
734
  layoutKey: model.layoutKey,
735
- spaceKey: model.spaceKey,
736
  k: 10,
737
  source: `abo-demo:${model.key}`,
738
  focus: "samples",
 
35
  key: String(model.key || `model-${index}`),
36
  displayName: String(model.displayName || model.display_name || model.key || `Model ${index + 1}`),
37
  layoutKey: model.layoutKey || model.layout_key || null,
 
38
  }))
39
  .filter((model) => model.layoutKey);
40
  }
 
731
  await commands.showSimilar({
732
  sampleId: item.queryId,
733
  layoutKey: model.layoutKey,
 
734
  k: 10,
735
  source: `abo-demo:${model.key}`,
736
  focus: "samples",
Dockerfile CHANGED
@@ -20,7 +20,7 @@ WORKDIR $HOME/app
20
 
21
  RUN pip install --upgrade pip
22
 
23
- ARG HYPERVIEW_VERSION=0.6.1
24
  ARG HYPER_MODELS_VERSION=0.3.0
25
 
26
  # Install CPU-only PyTorch first so the Space does not pull the default CUDA bundle.
 
20
 
21
  RUN pip install --upgrade pip
22
 
23
+ ARG HYPERVIEW_VERSION=0.6.2
24
  ARG HYPER_MODELS_VERSION=0.3.0
25
 
26
  # Install CPU-only PyTorch first so the Space does not pull the default CUDA bundle.
README.md CHANGED
@@ -62,7 +62,7 @@ JavaScript.
62
  This folder is intended to deploy to `hyper3labs/HyperView-ABO-Catalog` from
63
  the `hyperview-spaces` deployment repository.
64
 
65
- The Dockerfile installs `hyperview==0.6.1` and `hyper-models[ml]==0.3.0` from
66
  PyPI. The released HyperView wheel includes the built frontend assets, so this
67
  Space does not carry a local `static/` bundle or copy frontend files into the
68
  installed package.
 
62
  This folder is intended to deploy to `hyper3labs/HyperView-ABO-Catalog` from
63
  the `hyperview-spaces` deployment repository.
64
 
65
+ The Dockerfile installs `hyperview==0.6.2` and `hyper-models[ml]==0.3.0` from
66
  PyPI. The released HyperView wheel includes the built frontend assets, so this
67
  Space does not carry a local `static/` bundle or copy frontend files into the
68
  installed package.
demo.py CHANGED
@@ -12,11 +12,11 @@ from pathlib import Path
12
  from typing import Any
13
 
14
  from datasets import load_dataset
 
15
  from PIL import Image, ImageOps
16
 
17
  import hyperview as hv
18
 
19
-
20
  SPACE_DIR = Path(__file__).resolve().parent
21
  SPACE_HOST = os.environ.get("HYPERVIEW_HOST", "127.0.0.1")
22
  SPACE_PORT = int(os.environ.get("HYPERVIEW_PORT", "6262"))
@@ -379,10 +379,9 @@ def prepare_catalog_records() -> list[dict]:
379
  def add_abo_samples(dataset: hv.Dataset) -> None:
380
  existing_ids = {sample.id for sample in dataset.samples}
381
  media_dir = media_root()
382
- added = 0
383
- updated = 0
384
  skipped = 0
385
  product_counts: Counter[str] = Counter()
 
386
  records = prepare_catalog_records()
387
  expected_ids = {
388
  safe_sample_id(str(record["item_id"]), str(record["image_id"])) for record in records
@@ -395,7 +394,7 @@ def add_abo_samples(dataset: hv.Dataset) -> None:
395
  if not FORCE_SAMPLE_REFRESH and not missing_ids and not missing_media:
396
  print(
397
  f"ABO samples already prepared ({len(records)} products). "
398
- "Refreshing sample metadata and media paths.",
399
  flush=True,
400
  )
401
 
@@ -406,31 +405,39 @@ def add_abo_samples(dataset: hv.Dataset) -> None:
406
  skipped += 1
407
  continue
408
 
409
- sample_exists = sample_id in existing_ids
410
-
411
  metadata = dict(record)
412
  metadata["hierarchy"] = f"{record['department']} -> {record['product_type_readable']}"
413
 
414
- dataset.add_image(
415
- str(destination),
416
- label=record["product_type"],
417
- metadata=metadata,
418
- sample_id=sample_id,
 
 
419
  )
420
- if sample_exists:
421
- updated += 1
422
- else:
423
- existing_ids.add(sample_id)
424
- added += 1
425
  product_counts[record["product_type"]] += 1
426
 
427
  if index == 1 or index % 50 == 0 or index == len(records):
428
  print(
429
- f"Prepared {index}/{len(records)} products "
430
- f"({added} added, {updated} updated, {skipped} skipped).",
431
  flush=True,
432
  )
433
 
 
 
 
 
 
 
 
 
 
 
 
 
 
434
  print(f"Product-type counts: {dict(product_counts)}", flush=True)
435
 
436
 
@@ -471,7 +478,6 @@ def model_panel_props(layouts: dict[str, str]) -> list[dict[str, Any]]:
471
  "key": spec["key"],
472
  "displayName": spec["display_name"],
473
  "layoutKey": layout_key,
474
- "spaceKey": layout_key.split("__euclidean_umap", 1)[0].split("__poincare_umap", 1)[0],
475
  }
476
  )
477
  return props
 
12
  from typing import Any
13
 
14
  from datasets import load_dataset
15
+ from hyperview.core.sample import Sample
16
  from PIL import Image, ImageOps
17
 
18
  import hyperview as hv
19
 
 
20
  SPACE_DIR = Path(__file__).resolve().parent
21
  SPACE_HOST = os.environ.get("HYPERVIEW_HOST", "127.0.0.1")
22
  SPACE_PORT = int(os.environ.get("HYPERVIEW_PORT", "6262"))
 
379
  def add_abo_samples(dataset: hv.Dataset) -> None:
380
  existing_ids = {sample.id for sample in dataset.samples}
381
  media_dir = media_root()
 
 
382
  skipped = 0
383
  product_counts: Counter[str] = Counter()
384
+ samples: list[Sample] = []
385
  records = prepare_catalog_records()
386
  expected_ids = {
387
  safe_sample_id(str(record["item_id"]), str(record["image_id"])) for record in records
 
394
  if not FORCE_SAMPLE_REFRESH and not missing_ids and not missing_media:
395
  print(
396
  f"ABO samples already prepared ({len(records)} products). "
397
+ "Existing sample rows will be reused.",
398
  flush=True,
399
  )
400
 
 
405
  skipped += 1
406
  continue
407
 
 
 
408
  metadata = dict(record)
409
  metadata["hierarchy"] = f"{record['department']} -> {record['product_type_readable']}"
410
 
411
+ samples.append(
412
+ Sample(
413
+ id=sample_id,
414
+ filepath=str(destination),
415
+ label=record["product_type"],
416
+ metadata=metadata,
417
+ )
418
  )
 
 
 
 
 
419
  product_counts[record["product_type"]] += 1
420
 
421
  if index == 1 or index % 50 == 0 or index == len(records):
422
  print(
423
+ f"Prepared media for {index}/{len(records)} products "
424
+ f"({skipped} skipped).",
425
  flush=True,
426
  )
427
 
428
+ upserted, skipped_existing = dataset.add_samples(
429
+ samples,
430
+ skip_existing=not FORCE_SAMPLE_REFRESH,
431
+ )
432
+ updated = (
433
+ sum(1 for sample in samples if sample.id in existing_ids)
434
+ if FORCE_SAMPLE_REFRESH
435
+ else 0
436
+ )
437
+ added = upserted - updated
438
+ if skipped_existing:
439
+ print(f"Skipped {skipped_existing} existing ABO sample rows.", flush=True)
440
+ print(f"Prepared ABO samples ({added} added, {updated} updated, {skipped} media skipped).", flush=True)
441
  print(f"Product-type counts: {dict(product_counts)}", flush=True)
442
 
443
 
 
478
  "key": spec["key"],
479
  "displayName": spec["display_name"],
480
  "layoutKey": layout_key,
 
481
  }
482
  )
483
  return props