github-actions[bot] commited on
Commit ·
02c4243
1
Parent(s): eac3a0d
Deploy hyper3labs/HyperView-DeepFashion-Text-Search from Hyper3Labs/hyperview-spaces@9eda89a
Browse files- .gitattributes +0 -35
- .hyperview/extensions/fashion-search-readout/panel.js +7 -42
- demo.py +2 -41
.gitattributes
DELETED
|
@@ -1,35 +0,0 @@
|
|
| 1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.hyperview/extensions/fashion-search-readout/panel.js
CHANGED
|
@@ -23,9 +23,6 @@ const colors = {
|
|
| 23 |
bodyText: "#cbd5e1",
|
| 24 |
accent: "#93c5fd",
|
| 25 |
success: "#86efac",
|
| 26 |
-
warningBg: "#3b2f12",
|
| 27 |
-
warningBorder: "#92400e",
|
| 28 |
-
warningText: "#fde68a",
|
| 29 |
error: "#fca5a5",
|
| 30 |
};
|
| 31 |
|
|
@@ -625,7 +622,6 @@ export default function FashionSearchComparisonPanel() {
|
|
| 625 |
const models = React.useMemo(() => normalizeModels(panelProps.models), [panelProps.models]);
|
| 626 |
const inspectableModels = React.useMemo(() => models.filter((model) => model.layoutKey), [models]);
|
| 627 |
const examples = Array.isArray(panelProps.examples) ? panelProps.examples : [];
|
| 628 |
-
const warnings = Array.isArray(panelProps.warnings) ? panelProps.warnings.filter(Boolean) : [];
|
| 629 |
const metrics = panelProps.metrics || {};
|
| 630 |
const selectedExample =
|
| 631 |
examples.find((item) => item.id === selectedExampleId) || examples[0] || null;
|
|
@@ -672,7 +668,7 @@ export default function FashionSearchComparisonPanel() {
|
|
| 672 |
|
| 673 |
const selectSimilarityAnchor = React.useCallback(
|
| 674 |
async (sampleId) => {
|
| 675 |
-
if (!sampleId
|
| 676 |
await commands.setSelection([sampleId], {
|
| 677 |
persist: false,
|
| 678 |
source: "panel",
|
|
@@ -704,17 +700,7 @@ export default function FashionSearchComparisonPanel() {
|
|
| 704 |
focus: "samples",
|
| 705 |
persist: false,
|
| 706 |
});
|
| 707 |
-
if (requestSeq !== evidenceRequestSeq.current)
|
| 708 |
-
const latest = latestEvidenceRequest.current;
|
| 709 |
-
if (latest && latest.requestKey !== requestKey) {
|
| 710 |
-
window.setTimeout(() => {
|
| 711 |
-
if (latestEvidenceRequest.current?.requestKey === latest.requestKey) {
|
| 712 |
-
void loadEvidenceForSample(latest);
|
| 713 |
-
}
|
| 714 |
-
}, 0);
|
| 715 |
-
}
|
| 716 |
-
return;
|
| 717 |
-
}
|
| 718 |
|
| 719 |
await selectSimilarityAnchor(sampleId);
|
| 720 |
} catch (error) {
|
|
@@ -762,11 +748,7 @@ export default function FashionSearchComparisonPanel() {
|
|
| 762 |
if (!evidenceModel) return;
|
| 763 |
didPrimeEvidence.current = true;
|
| 764 |
|
| 765 |
-
|
| 766 |
-
void showExampleEvidence(selectedExample, evidenceModel, "fashion-demo:initial");
|
| 767 |
-
}, 700);
|
| 768 |
-
|
| 769 |
-
return () => window.clearTimeout(timer);
|
| 770 |
}, [mode, models, selectedExample, showExampleEvidence]);
|
| 771 |
|
| 772 |
const clearSelection = async () => {
|
|
@@ -779,8 +761,8 @@ export default function FashionSearchComparisonPanel() {
|
|
| 779 |
const key = `${item.queryId}:${model.key}`;
|
| 780 |
setPanelError(null);
|
| 781 |
if (!model.layoutKey) {
|
| 782 |
-
await commands.setSelection
|
| 783 |
-
commands.focusPanel
|
| 784 |
return;
|
| 785 |
}
|
| 786 |
setLoadingKey(key);
|
|
@@ -803,11 +785,11 @@ export default function FashionSearchComparisonPanel() {
|
|
| 803 |
const key = `${result.sampleId}:${model.key}:ranked-result`;
|
| 804 |
setPanelError(null);
|
| 805 |
if (!model.layoutKey) {
|
| 806 |
-
await commands.setSelection
|
| 807 |
persist: false,
|
| 808 |
source: `fashion-ranked-result:${model.key}`,
|
| 809 |
});
|
| 810 |
-
commands.focusPanel
|
| 811 |
return;
|
| 812 |
}
|
| 813 |
setLoadingKey(key);
|
|
@@ -956,23 +938,6 @@ export default function FashionSearchComparisonPanel() {
|
|
| 956 |
})
|
| 957 |
: null,
|
| 958 |
),
|
| 959 |
-
warnings.length
|
| 960 |
-
? React.createElement(
|
| 961 |
-
"div",
|
| 962 |
-
{
|
| 963 |
-
style: {
|
| 964 |
-
border: `1px solid ${colors.warningBorder}`,
|
| 965 |
-
borderRadius: 4,
|
| 966 |
-
background: colors.warningBg,
|
| 967 |
-
color: colors.warningText,
|
| 968 |
-
padding: 8,
|
| 969 |
-
fontSize: 11,
|
| 970 |
-
lineHeight: 1.35,
|
| 971 |
-
},
|
| 972 |
-
},
|
| 973 |
-
warnings[0],
|
| 974 |
-
)
|
| 975 |
-
: null,
|
| 976 |
React.createElement(BenchmarkDetails, { typedMetricRows, imageMetricRows }),
|
| 977 |
panelError
|
| 978 |
? React.createElement(
|
|
|
|
| 23 |
bodyText: "#cbd5e1",
|
| 24 |
accent: "#93c5fd",
|
| 25 |
success: "#86efac",
|
|
|
|
|
|
|
|
|
|
| 26 |
error: "#fca5a5",
|
| 27 |
};
|
| 28 |
|
|
|
|
| 622 |
const models = React.useMemo(() => normalizeModels(panelProps.models), [panelProps.models]);
|
| 623 |
const inspectableModels = React.useMemo(() => models.filter((model) => model.layoutKey), [models]);
|
| 624 |
const examples = Array.isArray(panelProps.examples) ? panelProps.examples : [];
|
|
|
|
| 625 |
const metrics = panelProps.metrics || {};
|
| 626 |
const selectedExample =
|
| 627 |
examples.find((item) => item.id === selectedExampleId) || examples[0] || null;
|
|
|
|
| 668 |
|
| 669 |
const selectSimilarityAnchor = React.useCallback(
|
| 670 |
async (sampleId) => {
|
| 671 |
+
if (!sampleId) return;
|
| 672 |
await commands.setSelection([sampleId], {
|
| 673 |
persist: false,
|
| 674 |
source: "panel",
|
|
|
|
| 700 |
focus: "samples",
|
| 701 |
persist: false,
|
| 702 |
});
|
| 703 |
+
if (requestSeq !== evidenceRequestSeq.current) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 704 |
|
| 705 |
await selectSimilarityAnchor(sampleId);
|
| 706 |
} catch (error) {
|
|
|
|
| 748 |
if (!evidenceModel) return;
|
| 749 |
didPrimeEvidence.current = true;
|
| 750 |
|
| 751 |
+
void showExampleEvidence(selectedExample, evidenceModel, "fashion-demo:initial");
|
|
|
|
|
|
|
|
|
|
|
|
|
| 752 |
}, [mode, models, selectedExample, showExampleEvidence]);
|
| 753 |
|
| 754 |
const clearSelection = async () => {
|
|
|
|
| 761 |
const key = `${item.queryId}:${model.key}`;
|
| 762 |
setPanelError(null);
|
| 763 |
if (!model.layoutKey) {
|
| 764 |
+
await commands.setSelection([item.queryId], { persist: false, source: `fashion-target:${model.key}` });
|
| 765 |
+
commands.focusPanel("grid");
|
| 766 |
return;
|
| 767 |
}
|
| 768 |
setLoadingKey(key);
|
|
|
|
| 785 |
const key = `${result.sampleId}:${model.key}:ranked-result`;
|
| 786 |
setPanelError(null);
|
| 787 |
if (!model.layoutKey) {
|
| 788 |
+
await commands.setSelection([result.sampleId], {
|
| 789 |
persist: false,
|
| 790 |
source: `fashion-ranked-result:${model.key}`,
|
| 791 |
});
|
| 792 |
+
commands.focusPanel("grid");
|
| 793 |
return;
|
| 794 |
}
|
| 795 |
setLoadingKey(key);
|
|
|
|
| 938 |
})
|
| 939 |
: null,
|
| 940 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 941 |
React.createElement(BenchmarkDetails, { typedMetricRows, imageMetricRows }),
|
| 942 |
panelError
|
| 943 |
? React.createElement(
|
demo.py
CHANGED
|
@@ -33,11 +33,6 @@ FORCE_SAMPLE_REFRESH = os.environ.get("HYPERVIEW_DEEPFASHION_FORCE_REFRESH", "")
|
|
| 33 |
"true",
|
| 34 |
"yes",
|
| 35 |
}
|
| 36 |
-
ALLOW_CANDIDATE_FALLBACK = os.environ.get("HYPERVIEW_ALLOW_CANDIDATE_FALLBACK", "1").lower() in {
|
| 37 |
-
"1",
|
| 38 |
-
"true",
|
| 39 |
-
"yes",
|
| 40 |
-
}
|
| 41 |
ENABLE_CONTEXT_MAPS = os.environ.get("FASHION_ENABLE_CONTEXT_MAPS", "1").lower() in {
|
| 42 |
"1",
|
| 43 |
"true",
|
|
@@ -45,7 +40,6 @@ ENABLE_CONTEXT_MAPS = os.environ.get("FASHION_ENABLE_CONTEXT_MAPS", "1").lower()
|
|
| 45 |
}
|
| 46 |
EMBEDDING_MAX_ATTEMPTS = max(1, int(os.environ.get("HYPERVIEW_EMBEDDING_MAX_ATTEMPTS", "4")))
|
| 47 |
EMBEDDING_RETRY_DELAY_SECONDS = float(os.environ.get("HYPERVIEW_EMBEDDING_RETRY_DELAY_SECONDS", "15"))
|
| 48 |
-
RUNTIME_WARNINGS: list[str] = []
|
| 49 |
DEFAULT_EXAMPLE_ID = os.environ.get("FASHION_DEFAULT_EXAMPLE_ID", "light-denim-leggings")
|
| 50 |
|
| 51 |
MODEL_SPECS = [
|
|
@@ -308,33 +302,7 @@ def ensure_layouts(dataset: hv.Dataset) -> dict[str, str]:
|
|
| 308 |
layouts: dict[str, str] = {}
|
| 309 |
for spec in MODEL_SPECS:
|
| 310 |
print(f"Ensuring {spec['display_name']} embeddings...", flush=True)
|
| 311 |
-
|
| 312 |
-
space_key = compute_embeddings_with_retry(dataset, spec)
|
| 313 |
-
except BaseException as exc:
|
| 314 |
-
if isinstance(exc, (KeyboardInterrupt, SystemExit)):
|
| 315 |
-
raise
|
| 316 |
-
if spec["key"] == "candidate" and ALLOW_CANDIDATE_FALLBACK and "clip" in layouts:
|
| 317 |
-
warning = (
|
| 318 |
-
f"Hyper3-CLIP embeddings are unavailable ({type(exc).__name__}: {exc}). "
|
| 319 |
-
"Showing the CLIP layout as a clearly labeled fallback so the Space can start."
|
| 320 |
-
)
|
| 321 |
-
print(warning, flush=True)
|
| 322 |
-
RUNTIME_WARNINGS.append(warning)
|
| 323 |
-
fallback_layout_key = layouts["clip"]
|
| 324 |
-
spec.update(
|
| 325 |
-
{
|
| 326 |
-
"display_name": "Hyper3-CLIP unavailable (CLIP fallback)",
|
| 327 |
-
"button_label": "Inspect CLIP fallback neighbors",
|
| 328 |
-
"geometry": MODEL_SPECS[0]["geometry"],
|
| 329 |
-
"layout_dimension": MODEL_SPECS[0]["layout_dimension"],
|
| 330 |
-
"panel_title": "Hyper3-CLIP unavailable - showing CLIP fallback",
|
| 331 |
-
"fallback": True,
|
| 332 |
-
"layout_key": fallback_layout_key,
|
| 333 |
-
}
|
| 334 |
-
)
|
| 335 |
-
layouts[spec["key"]] = fallback_layout_key
|
| 336 |
-
continue
|
| 337 |
-
raise
|
| 338 |
print(f"Ensuring {spec['display_name']} layout...", flush=True)
|
| 339 |
layout_key = dataset.compute_visualization(
|
| 340 |
space_key=space_key,
|
|
@@ -391,16 +359,10 @@ def neighbor_summary(dataset: hv.Dataset, sample_id: str, model_key: str) -> dic
|
|
| 391 |
|
| 392 |
def build_examples(dataset: hv.Dataset) -> list[dict[str, Any]]:
|
| 393 |
examples = []
|
| 394 |
-
candidate_is_fallback = any(spec["key"] == "candidate" and spec.get("fallback") for spec in MODEL_SPECS)
|
| 395 |
for item in TEXT_SEARCH_EXAMPLES:
|
| 396 |
sample_id = safe_sample_id(item["targetItemId"])
|
| 397 |
if sample_id not in {sample.id for sample in dataset.samples}:
|
| 398 |
continue
|
| 399 |
-
candidate_text = (
|
| 400 |
-
"Hyper3-CLIP is unavailable in this runtime, so this button shows the CLIP fallback neighborhood."
|
| 401 |
-
if candidate_is_fallback
|
| 402 |
-
else item["hyper3Text"]
|
| 403 |
-
)
|
| 404 |
examples.append(
|
| 405 |
{
|
| 406 |
"id": item["id"],
|
|
@@ -417,7 +379,7 @@ def build_examples(dataset: hv.Dataset) -> list[dict[str, Any]]:
|
|
| 417 |
},
|
| 418 |
"candidate": {
|
| 419 |
"rank": item["hyper3Rank"],
|
| 420 |
-
"text":
|
| 421 |
**neighbor_summary(dataset, sample_id, "candidate"),
|
| 422 |
},
|
| 423 |
},
|
|
@@ -431,7 +393,6 @@ def build_demo_view(dataset: hv.Dataset, layouts: dict[str, str]) -> hv.ui.View:
|
|
| 431 |
"models": model_panel_props(layouts),
|
| 432 |
"examples": build_examples(dataset),
|
| 433 |
"initialExampleId": DEFAULT_EXAMPLE_ID,
|
| 434 |
-
"warnings": RUNTIME_WARNINGS,
|
| 435 |
"metrics": {
|
| 436 |
"typedQueryCount": 180,
|
| 437 |
"typedCandidateImages": 1120,
|
|
|
|
| 33 |
"true",
|
| 34 |
"yes",
|
| 35 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
ENABLE_CONTEXT_MAPS = os.environ.get("FASHION_ENABLE_CONTEXT_MAPS", "1").lower() in {
|
| 37 |
"1",
|
| 38 |
"true",
|
|
|
|
| 40 |
}
|
| 41 |
EMBEDDING_MAX_ATTEMPTS = max(1, int(os.environ.get("HYPERVIEW_EMBEDDING_MAX_ATTEMPTS", "4")))
|
| 42 |
EMBEDDING_RETRY_DELAY_SECONDS = float(os.environ.get("HYPERVIEW_EMBEDDING_RETRY_DELAY_SECONDS", "15"))
|
|
|
|
| 43 |
DEFAULT_EXAMPLE_ID = os.environ.get("FASHION_DEFAULT_EXAMPLE_ID", "light-denim-leggings")
|
| 44 |
|
| 45 |
MODEL_SPECS = [
|
|
|
|
| 302 |
layouts: dict[str, str] = {}
|
| 303 |
for spec in MODEL_SPECS:
|
| 304 |
print(f"Ensuring {spec['display_name']} embeddings...", flush=True)
|
| 305 |
+
space_key = compute_embeddings_with_retry(dataset, spec)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
print(f"Ensuring {spec['display_name']} layout...", flush=True)
|
| 307 |
layout_key = dataset.compute_visualization(
|
| 308 |
space_key=space_key,
|
|
|
|
| 359 |
|
| 360 |
def build_examples(dataset: hv.Dataset) -> list[dict[str, Any]]:
|
| 361 |
examples = []
|
|
|
|
| 362 |
for item in TEXT_SEARCH_EXAMPLES:
|
| 363 |
sample_id = safe_sample_id(item["targetItemId"])
|
| 364 |
if sample_id not in {sample.id for sample in dataset.samples}:
|
| 365 |
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 366 |
examples.append(
|
| 367 |
{
|
| 368 |
"id": item["id"],
|
|
|
|
| 379 |
},
|
| 380 |
"candidate": {
|
| 381 |
"rank": item["hyper3Rank"],
|
| 382 |
+
"text": item["hyper3Text"],
|
| 383 |
**neighbor_summary(dataset, sample_id, "candidate"),
|
| 384 |
},
|
| 385 |
},
|
|
|
|
| 393 |
"models": model_panel_props(layouts),
|
| 394 |
"examples": build_examples(dataset),
|
| 395 |
"initialExampleId": DEFAULT_EXAMPLE_ID,
|
|
|
|
| 396 |
"metrics": {
|
| 397 |
"typedQueryCount": 180,
|
| 398 |
"typedCandidateImages": 1120,
|