gradio version
Browse files
README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
---
|
| 2 |
title: Zoo3D (VGGT + open-vocabulary 3D detection)
|
| 3 |
sdk: gradio
|
|
|
|
| 4 |
app_file: app.py
|
| 5 |
pinned: false
|
| 6 |
---
|
|
|
|
| 1 |
---
|
| 2 |
title: Zoo3D (VGGT + open-vocabulary 3D detection)
|
| 3 |
sdk: gradio
|
| 4 |
+
sdk_version: 5.17.1
|
| 5 |
app_file: app.py
|
| 6 |
pinned: false
|
| 7 |
---
|
mvp.py
CHANGED
|
@@ -146,7 +146,11 @@ def check_weights():
|
|
| 146 |
print(f"Downloaded {cropformer_name}...")
|
| 147 |
else:
|
| 148 |
print(f"{cropformer_name} already exists...")
|
| 149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
|
| 151 |
def extract_text_feature(descriptions, clip_model, target_path):
|
| 152 |
text_tokens = tokenizer.tokenize(descriptions).to(device)
|
|
@@ -430,6 +434,11 @@ def reconstruct(
|
|
| 430 |
|
| 431 |
print("Running run_model...")
|
| 432 |
with torch.no_grad():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 433 |
vggt_model, metric3d_model, _ = _init_models()
|
| 434 |
predictions = run_model(target_dir, vggt_model, metric3d_model=metric3d_model)
|
| 435 |
|
|
@@ -787,6 +796,12 @@ def detect_objects(text_labels, target_dir, conf_thres, *viz_args):
|
|
| 787 |
# Require non-empty text labels
|
| 788 |
if not text_labels or not isinstance(text_labels, str) or len([l.strip() for l in text_labels.split(";") if l.strip()]) == 0:
|
| 789 |
return None, "Please enter at least one text label (separated by ';')."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 790 |
|
| 791 |
# 1. Run reconstruction first if needed (checking if predictions exist)
|
| 792 |
predictions_path = os.path.join(target_dir, "predictions.npz")
|
|
@@ -1017,7 +1032,32 @@ with gr.Blocks(
|
|
| 1017 |
input_video = gr.Video(label="Upload Video", interactive=True)
|
| 1018 |
input_images = gr.File(file_count="multiple", label="Upload Images", interactive=True)
|
| 1019 |
|
| 1020 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1021 |
label="Preview",
|
| 1022 |
columns=4,
|
| 1023 |
height="300px",
|
|
|
|
| 146 |
print(f"Downloaded {cropformer_name}...")
|
| 147 |
else:
|
| 148 |
print(f"{cropformer_name} already exists...")
|
| 149 |
+
#
|
| 150 |
+
# IMPORTANT (HF Spaces):
|
| 151 |
+
# Do NOT download large weights at import time (startup). We'll download lazily
|
| 152 |
+
# when running detection/reconstruction that actually needs them.
|
| 153 |
+
#
|
| 154 |
|
| 155 |
def extract_text_feature(descriptions, clip_model, target_path):
|
| 156 |
text_tokens = tokenizer.tokenize(descriptions).to(device)
|
|
|
|
| 434 |
|
| 435 |
print("Running run_model...")
|
| 436 |
with torch.no_grad():
|
| 437 |
+
# Ensure CropFormer weights exist if downstream pipeline is enabled
|
| 438 |
+
try:
|
| 439 |
+
check_weights()
|
| 440 |
+
except Exception as e:
|
| 441 |
+
print(f"Warning: could not ensure Mask2Former weights at startup: {e}")
|
| 442 |
vggt_model, metric3d_model, _ = _init_models()
|
| 443 |
predictions = run_model(target_dir, vggt_model, metric3d_model=metric3d_model)
|
| 444 |
|
|
|
|
| 796 |
# Require non-empty text labels
|
| 797 |
if not text_labels or not isinstance(text_labels, str) or len([l.strip() for l in text_labels.split(";") if l.strip()]) == 0:
|
| 798 |
return None, "Please enter at least one text label (separated by ';')."
|
| 799 |
+
|
| 800 |
+
# Ensure CropFormer weights exist (if detection pipeline uses them)
|
| 801 |
+
try:
|
| 802 |
+
check_weights()
|
| 803 |
+
except Exception as e:
|
| 804 |
+
print(f"Warning: could not ensure Mask2Former weights: {e}")
|
| 805 |
|
| 806 |
# 1. Run reconstruction first if needed (checking if predictions exist)
|
| 807 |
predictions_path = os.path.join(target_dir, "predictions.npz")
|
|
|
|
| 1032 |
input_video = gr.Video(label="Upload Video", interactive=True)
|
| 1033 |
input_images = gr.File(file_count="multiple", label="Upload Images", interactive=True)
|
| 1034 |
|
| 1035 |
+
def _safe_gallery(**kwargs):
|
| 1036 |
+
# Gradio API differs between versions; HF Spaces may run Gradio 6.x.
|
| 1037 |
+
# Retry by removing unsupported kwargs.
|
| 1038 |
+
while True:
|
| 1039 |
+
try:
|
| 1040 |
+
return gr.Gallery(**kwargs)
|
| 1041 |
+
except TypeError as e:
|
| 1042 |
+
msg = str(e)
|
| 1043 |
+
# Typical: "got an unexpected keyword argument 'show_download_button'"
|
| 1044 |
+
bad = None
|
| 1045 |
+
import re
|
| 1046 |
+
m = re.search(r"unexpected keyword argument '([^']+)'", msg)
|
| 1047 |
+
if m:
|
| 1048 |
+
bad = m.group(1)
|
| 1049 |
+
if bad and bad in kwargs:
|
| 1050 |
+
kwargs.pop(bad)
|
| 1051 |
+
continue
|
| 1052 |
+
# Fallback: drop known version-sensitive args
|
| 1053 |
+
for k in ["show_download_button", "preview", "object_fit", "columns", "height"]:
|
| 1054 |
+
if k in kwargs:
|
| 1055 |
+
kwargs.pop(k)
|
| 1056 |
+
break
|
| 1057 |
+
else:
|
| 1058 |
+
raise
|
| 1059 |
+
|
| 1060 |
+
image_gallery = _safe_gallery(
|
| 1061 |
label="Preview",
|
| 1062 |
columns=4,
|
| 1063 |
height="300px",
|