Spaces:
Sleeping
Sleeping
Restore JSON tau editor, preserve attn aspect ratio, add local-run README
Browse files
README.md
CHANGED
|
@@ -43,4 +43,16 @@ applied directly to the running pipeline.
|
|
| 43 |
- The VLM weights (CLIPSeg + CLIP) download on first run and are cached.
|
| 44 |
- The composed analysis video is exported as an H.264 `.mp4` (bundled
|
| 45 |
`imageio-ffmpeg`, no system ffmpeg required).
|
| 46 |
-
- GPU is recommended; the space
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
- The VLM weights (CLIPSeg + CLIP) download on first run and are cached.
|
| 44 |
- The composed analysis video is exported as an H.264 `.mp4` (bundled
|
| 45 |
`imageio-ffmpeg`, no system ffmpeg required).
|
| 46 |
+
- GPU is recommended; the space runs on **ZeroGPU** (free, shared A10G pool).
|
| 47 |
+
|
| 48 |
+
## Run locally
|
| 49 |
+
|
| 50 |
+
```bash
|
| 51 |
+
git clone <this-repo-url>
|
| 52 |
+
cd anytraverse-ui
|
| 53 |
+
uv sync # or: python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
|
| 54 |
+
python app.py # opens on http://localhost:7860
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
Requires **Python 3.12+** and a CUDA GPU (or CPU, slowly). VLM weights
|
| 58 |
+
(~1 GB) download on the first run. See the repository `README.md` for details.
|
app.py
CHANGED
|
@@ -244,17 +244,23 @@ def build_grid(p):
|
|
| 244 |
|
| 245 |
|
| 246 |
def build_attn_strip(p):
|
| 247 |
-
"""Prompt attention maps as a grid: max 5 columns, wrapping to new rows.
|
|
|
|
| 248 |
raw = p["raw_bgr"]
|
| 249 |
h, w, _ = raw.shape
|
| 250 |
att = p["attn_maps"]
|
| 251 |
if not att:
|
| 252 |
return np.zeros((h, w, 3), dtype=np.uint8)
|
| 253 |
cell_w = max(int(w // min(len(att), 5)), 80)
|
| 254 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
rows = []
|
| 256 |
for i in range(0, len(att), 5):
|
| 257 |
-
cells = [add_caption(colorize(m, cell_w,
|
| 258 |
for name, m in att[i:i + 5]]
|
| 259 |
while len(cells) < 5:
|
| 260 |
cells.append(blank.copy())
|
|
@@ -697,10 +703,12 @@ with gr.Blocks(title="AnyTraverse Studio") as demo:
|
|
| 697 |
# -------- Controls --------
|
| 698 |
video_in = gr.File(label="πΉ Upload Off-Road Video (.mp4, .mov, .avi)",
|
| 699 |
file_count="single")
|
| 700 |
-
pref_input = gr.
|
| 701 |
value="{}",
|
| 702 |
-
|
| 703 |
-
|
|
|
|
|
|
|
| 704 |
with gr.Row():
|
| 705 |
sim_thresh = gr.Slider(0.05, 1.0, value=0.8, step=0.05,
|
| 706 |
label="Ref Scene Sim. Threshold")
|
|
|
|
| 244 |
|
| 245 |
|
| 246 |
def build_attn_strip(p):
|
| 247 |
+
"""Prompt attention maps as a grid: max 5 columns, wrapping to new rows.
|
| 248 |
+
Each cell keeps the map's native aspect ratio (no distortion)."""
|
| 249 |
raw = p["raw_bgr"]
|
| 250 |
h, w, _ = raw.shape
|
| 251 |
att = p["attn_maps"]
|
| 252 |
if not att:
|
| 253 |
return np.zeros((h, w, 3), dtype=np.uint8)
|
| 254 |
cell_w = max(int(w // min(len(att), 5)), 80)
|
| 255 |
+
first = to_numpy(att[0][1])
|
| 256 |
+
if first.ndim > 2:
|
| 257 |
+
first = first.reshape(first.shape[-2:])
|
| 258 |
+
ah, aw = first.shape[:2]
|
| 259 |
+
cell_h = max(int(round(cell_w * ah / max(aw, 1))), 1)
|
| 260 |
+
blank = np.zeros((cell_h, cell_w, 3), dtype=np.uint8)
|
| 261 |
rows = []
|
| 262 |
for i in range(0, len(att), 5):
|
| 263 |
+
cells = [add_caption(colorize(m, cell_w, cell_h).copy(), name)
|
| 264 |
for name, m in att[i:i + 5]]
|
| 265 |
while len(cells) < 5:
|
| 266 |
cells.append(blank.copy())
|
|
|
|
| 703 |
# -------- Controls --------
|
| 704 |
video_in = gr.File(label="πΉ Upload Off-Road Video (.mp4, .mov, .avi)",
|
| 705 |
file_count="single")
|
| 706 |
+
pref_input = gr.Code(
|
| 707 |
value="{}",
|
| 708 |
+
language="json",
|
| 709 |
+
lines=3,
|
| 710 |
+
label="Traversability Preferences (Ο, JSON) β leave {} for defaults",
|
| 711 |
+
)
|
| 712 |
with gr.Row():
|
| 713 |
sim_thresh = gr.Slider(0.05, 1.0, value=0.8, step=0.05,
|
| 714 |
label="Ref Scene Sim. Threshold")
|