Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,12 +16,30 @@ import gradio as gr
|
|
| 16 |
EGOVERSE_REPO = "angkul07/egoverse-pick-tasks"
|
| 17 |
ABC_REPO = "angkul07/abc-ego"
|
| 18 |
ABC_TASKS = ["place_the_bread", "put_the_screwdriver_in_the_bin"]
|
| 19 |
-
ABC_CAMERAS = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
"/top-camera": "Top",
|
|
|
|
|
|
|
| 21 |
"/left-wrist-camera": "Left Wrist",
|
| 22 |
"/right-wrist-camera": "Right Wrist",
|
| 23 |
}
|
| 24 |
-
FPS = 30
|
| 25 |
|
| 26 |
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 27 |
# UUID discovery helpers
|
|
@@ -63,6 +81,13 @@ def list_abc_uuids(task: str, n: int = 50) -> list[str]:
|
|
| 63 |
print(f"[warn] Could not list abc uuids for {task}: {ex}")
|
| 64 |
return []
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 67 |
# Zarr helpers (egoverse)
|
| 68 |
# βββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -310,25 +335,22 @@ def stream_videos(dataset: str, uuid_input: str, task: str):
|
|
| 310 |
|
| 311 |
# ββ ABC Teleop (mcap β 3 cameras, streamed one at a time) βββββββ
|
| 312 |
elif dataset == "ABC Teleop":
|
| 313 |
-
if not MCAP_AVAILABLE:
|
| 314 |
-
yield "mcap package not installed in this environment.", None, None, None
|
| 315 |
-
return
|
| 316 |
-
|
| 317 |
-
# uuid from dropdown is already "episode_<uuid>", bare uuid also accepted
|
| 318 |
episode_folder = uuid if uuid.startswith("episode_") else f"episode_{uuid}"
|
| 319 |
-
|
| 320 |
yield f"Downloading {episode_folder} / {task} ...", None, None, None
|
| 321 |
try:
|
| 322 |
mcap_path = download_mcap(task, episode_folder, tmp_dir)
|
| 323 |
except Exception as e:
|
| 324 |
yield f"Download failed: {e}", None, None, None
|
| 325 |
return
|
| 326 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
videos = [None, None, None]
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
for i, (topic, label) in enumerate(zip(topics, labels)):
|
| 332 |
yield f"Converting {label} camera ...", *videos
|
| 333 |
try:
|
| 334 |
mp4 = convert_mcap_camera(mcap_path, topic, tmp_dir, label.replace(" ", "_").lower())
|
|
@@ -337,7 +359,7 @@ def stream_videos(dataset: str, uuid_input: str, task: str):
|
|
| 337 |
yield f"Error on {label}: {e}", *videos
|
| 338 |
return
|
| 339 |
yield f"Done: {label}", *videos
|
| 340 |
-
|
| 341 |
yield f"All cameras ready: {episode_folder}", *videos
|
| 342 |
|
| 343 |
finally:
|
|
|
|
| 16 |
EGOVERSE_REPO = "angkul07/egoverse-pick-tasks"
|
| 17 |
ABC_REPO = "angkul07/abc-ego"
|
| 18 |
ABC_TASKS = ["place_the_bread", "put_the_screwdriver_in_the_bin"]
|
| 19 |
+
# ABC_CAMERAS = {
|
| 20 |
+
# "/top-camera": "Top",
|
| 21 |
+
# "/left-wrist-camera": "Left Wrist",
|
| 22 |
+
# "/right-wrist-camera": "Right Wrist",
|
| 23 |
+
# }
|
| 24 |
+
FPS = 30
|
| 25 |
+
|
| 26 |
+
# Remove the static ABC_CAMERAS dict entirely
|
| 27 |
+
|
| 28 |
+
CAMERA_TOPIC_VARIANTS = [
|
| 29 |
+
"/top-camera",
|
| 30 |
+
"/top-left-camera",
|
| 31 |
+
"/top-right-camera",
|
| 32 |
+
"/left-wrist-camera",
|
| 33 |
+
"/right-wrist-camera",
|
| 34 |
+
]
|
| 35 |
+
|
| 36 |
+
TOPIC_LABELS = {
|
| 37 |
"/top-camera": "Top",
|
| 38 |
+
"/top-left-camera": "Top Left",
|
| 39 |
+
"/top-right-camera": "Top Right",
|
| 40 |
"/left-wrist-camera": "Left Wrist",
|
| 41 |
"/right-wrist-camera": "Right Wrist",
|
| 42 |
}
|
|
|
|
| 43 |
|
| 44 |
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 45 |
# UUID discovery helpers
|
|
|
|
| 81 |
print(f"[warn] Could not list abc uuids for {task}: {ex}")
|
| 82 |
return []
|
| 83 |
|
| 84 |
+
def get_mcap_camera_topics(mcap_path: str) -> list[str]:
|
| 85 |
+
"""Return only the camera topics that actually exist in this mcap file."""
|
| 86 |
+
with open(mcap_path, "rb") as f:
|
| 87 |
+
reader = make_reader(f, decoder_factories=[DecoderFactory()])
|
| 88 |
+
topics = {ch.topic for _, ch, _, _ in reader.iter_decoded_messages()}
|
| 89 |
+
return [t for t in CAMERA_TOPIC_VARIANTS if t in topics]
|
| 90 |
+
|
| 91 |
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 92 |
# Zarr helpers (egoverse)
|
| 93 |
# βββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 335 |
|
| 336 |
# ββ ABC Teleop (mcap β 3 cameras, streamed one at a time) βββββββ
|
| 337 |
elif dataset == "ABC Teleop":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
episode_folder = uuid if uuid.startswith("episode_") else f"episode_{uuid}"
|
| 339 |
+
|
| 340 |
yield f"Downloading {episode_folder} / {task} ...", None, None, None
|
| 341 |
try:
|
| 342 |
mcap_path = download_mcap(task, episode_folder, tmp_dir)
|
| 343 |
except Exception as e:
|
| 344 |
yield f"Download failed: {e}", None, None, None
|
| 345 |
return
|
| 346 |
+
|
| 347 |
+
# discover which cameras this episode actually has
|
| 348 |
+
topics = get_mcap_camera_topics(mcap_path)
|
| 349 |
+
print(f"[{episode_folder}] found cameras: {topics}")
|
| 350 |
+
|
| 351 |
videos = [None, None, None]
|
| 352 |
+
for i, topic in enumerate(topics[:3]): # max 3 panels
|
| 353 |
+
label = TOPIC_LABELS[topic]
|
|
|
|
|
|
|
| 354 |
yield f"Converting {label} camera ...", *videos
|
| 355 |
try:
|
| 356 |
mp4 = convert_mcap_camera(mcap_path, topic, tmp_dir, label.replace(" ", "_").lower())
|
|
|
|
| 359 |
yield f"Error on {label}: {e}", *videos
|
| 360 |
return
|
| 361 |
yield f"Done: {label}", *videos
|
| 362 |
+
|
| 363 |
yield f"All cameras ready: {episode_folder}", *videos
|
| 364 |
|
| 365 |
finally:
|