Spaces:
Running
Running
Commit
·
a5b259e
1
Parent(s):
f0ccf64
final working state
Browse files
app.py
CHANGED
@@ -15,41 +15,193 @@ import cv2
|
|
15 |
import gradio as gr
|
16 |
import rerun as rr
|
17 |
import rerun.blueprint as rrb
|
18 |
-
from color_grid import build_color_grid
|
19 |
from gradio_rerun import Rerun
|
20 |
from gradio_rerun.events import (
|
21 |
SelectionChange,
|
22 |
TimelineChange,
|
23 |
TimeUpdate,
|
24 |
)
|
|
|
|
|
|
|
25 |
|
|
|
|
|
|
|
26 |
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
with gr.Blocks() as demo:
|
29 |
with gr.Tab("Hosted RRD"):
|
30 |
with gr.Row():
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
)
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
|
55 |
if __name__ == "__main__":
|
|
|
15 |
import gradio as gr
|
16 |
import rerun as rr
|
17 |
import rerun.blueprint as rrb
|
|
|
18 |
from gradio_rerun import Rerun
|
19 |
from gradio_rerun.events import (
|
20 |
SelectionChange,
|
21 |
TimelineChange,
|
22 |
TimeUpdate,
|
23 |
)
|
24 |
+
from gradio_huggingfacehub_search import HuggingfaceHubSearch
|
25 |
+
from huggingface_hub import HfApi, HfFileSystem
|
26 |
+
from pathlib import Path
|
27 |
|
28 |
+
API = HfApi() # thin REST wrapper
|
29 |
+
FS = HfFileSystem() # fsspec-style filesystem :contentReference[oaicite:0]{index=0}
|
30 |
+
REPO = "pablovela5620/ego-dex-rrd"
|
31 |
|
32 |
|
33 |
+
SEQUENCE_NAMES = [
|
34 |
+
"add_remove_lid",
|
35 |
+
"arrange_topple_dominoes",
|
36 |
+
"assemble_disassemble_furniture_bench_chair",
|
37 |
+
"assemble_disassemble_furniture_bench_desk",
|
38 |
+
"assemble_disassemble_furniture_bench_drawer",
|
39 |
+
"assemble_disassemble_furniture_bench_lamp",
|
40 |
+
"assemble_disassemble_furniture_bench_square_table",
|
41 |
+
"assemble_disassemble_furniture_bench_stool",
|
42 |
+
"assemble_disassemble_legos",
|
43 |
+
"assemble_disassemble_soft_legos",
|
44 |
+
"assemble_disassemble_structures",
|
45 |
+
"assemble_disassemble_tiles",
|
46 |
+
"assemble_jenga",
|
47 |
+
"basic_fold",
|
48 |
+
"basic_pick_place",
|
49 |
+
"boil_serve_egg",
|
50 |
+
"braid_unbraid",
|
51 |
+
"build_unstack_lego",
|
52 |
+
"charge_uncharge_airpods",
|
53 |
+
"charge_uncharge_device",
|
54 |
+
"clean_cups",
|
55 |
+
"clean_surface",
|
56 |
+
"clean_tableware",
|
57 |
+
"clip_unclip_papers",
|
58 |
+
"color",
|
59 |
+
"crumple_flatten_paper",
|
60 |
+
"deal_gather_cards",
|
61 |
+
"declutter_desk",
|
62 |
+
"dry_hands",
|
63 |
+
"fidget_magnetic_spinner_rings",
|
64 |
+
"flip_coin",
|
65 |
+
"flip_pages",
|
66 |
+
"fold_stack_unstack_unfold_cloths",
|
67 |
+
"fold_unfold_paper_basic",
|
68 |
+
"fold_unfold_paper_origami",
|
69 |
+
"fry_bread",
|
70 |
+
"fry_egg",
|
71 |
+
"gather_roll_dice",
|
72 |
+
"insert_dump_blocks",
|
73 |
+
"insert_remove_airpods",
|
74 |
+
"insert_remove_bagging",
|
75 |
+
"insert_remove_bookshelf",
|
76 |
+
"insert_remove_cups_from_rack",
|
77 |
+
"insert_remove_drawer",
|
78 |
+
"insert_remove_furniture_bench_cabinet",
|
79 |
+
"insert_remove_furniture_bench_round_table",
|
80 |
+
"insert_remove_plug_socket",
|
81 |
+
"insert_remove_shirt_in_tube",
|
82 |
+
"insert_remove_tennis_ball",
|
83 |
+
"insert_remove_usb",
|
84 |
+
"insert_remove_utensils",
|
85 |
+
"knead_slime",
|
86 |
+
"load_dispense_ice",
|
87 |
+
"lock_unlock_key",
|
88 |
+
"make_sandwich",
|
89 |
+
"measure_objects",
|
90 |
+
"open_close_insert_remove_box",
|
91 |
+
"open_close_insert_remove_case",
|
92 |
+
"open_close_insert_remove_tupperware",
|
93 |
+
"paint_clean_brush",
|
94 |
+
"peel_place_sticker",
|
95 |
+
"pick_place_food",
|
96 |
+
"pick_up_and_put_down_case_or_bag",
|
97 |
+
"play_mancala",
|
98 |
+
"play_piano",
|
99 |
+
"play_reset_connect_four",
|
100 |
+
"point_and_click_remote",
|
101 |
+
"pour",
|
102 |
+
"push_pop_toy",
|
103 |
+
"put_away_set_up_board_game",
|
104 |
+
"put_in_take_out_glasses",
|
105 |
+
"put_toothpaste_on_toothbrush",
|
106 |
+
"rake_smooth_zen_garden",
|
107 |
+
"roll_ball",
|
108 |
+
"scoop_dump_ice",
|
109 |
+
"screw_unscrew_allen_fixture",
|
110 |
+
"screw_unscrew_bottle_cap",
|
111 |
+
"screw_unscrew_fingers_fixture",
|
112 |
+
"set_up_clean_up_chessboard",
|
113 |
+
"setup_cleanup_table",
|
114 |
+
"sleeve_unsleeve_cards",
|
115 |
+
"slot_batteries",
|
116 |
+
"sort_beads",
|
117 |
+
"stack",
|
118 |
+
"stack_remove_jenga",
|
119 |
+
"stack_unstack_bowls",
|
120 |
+
"stack_unstack_cups",
|
121 |
+
"stack_unstack_plates",
|
122 |
+
"stack_unstack_tupperware",
|
123 |
+
"staple_paper",
|
124 |
+
"stock_unstock_fridge",
|
125 |
+
"sweep_dustpan",
|
126 |
+
"thread_unthread_bead_necklace",
|
127 |
+
"throw_and_catch_ball",
|
128 |
+
"throw_collect_objects",
|
129 |
+
"tie_and_untie_shoelace",
|
130 |
+
"tie_untie_rubberband",
|
131 |
+
"type_keyboard",
|
132 |
+
"use_chopsticks",
|
133 |
+
"use_rubiks_cube",
|
134 |
+
"vertical_pick_place",
|
135 |
+
"wash_fruit",
|
136 |
+
"wash_kitchen_dishes",
|
137 |
+
"wash_put_away_dishes",
|
138 |
+
"wipe_kitchen_surfaces",
|
139 |
+
"wipe_screen",
|
140 |
+
"wrap",
|
141 |
+
"wrap_unwrap_food",
|
142 |
+
"write",
|
143 |
+
"zip_unzip_bag",
|
144 |
+
"zip_unzip_case",
|
145 |
+
]
|
146 |
+
|
147 |
+
def show_dataset(task_name: str, episode_index: str):
|
148 |
+
episode_index = f"{int(episode_index):05d}"
|
149 |
+
url_str = f"https://huggingface.co/datasets/pablovela5620/ego-dex-rrd/resolve/main/{task_name}/{episode_index}.rrd"
|
150 |
+
return url_str
|
151 |
+
|
152 |
+
def list_episodes(task:str) -> list[str]:
|
153 |
+
"""
|
154 |
+
Return ["00000", "00001", ...] for the chosen task folder.
|
155 |
+
"""
|
156 |
+
# fastest: one HTTP hit that returns the whole tree once
|
157 |
+
files = API.list_repo_files(REPO, repo_type="dataset")
|
158 |
+
return sorted(
|
159 |
+
{Path(f).stem for f in files
|
160 |
+
if f.startswith(f"{task}/") and f.endswith(".rrd")}
|
161 |
+
)
|
162 |
+
default_task = SEQUENCE_NAMES[0] # "add_remove_lid"
|
163 |
+
initial_eps = list_episodes(default_task) # ["00000", "00001", …]
|
164 |
+
|
165 |
with gr.Blocks() as demo:
|
166 |
with gr.Tab("Hosted RRD"):
|
167 |
with gr.Row():
|
168 |
+
with gr.Column(scale=1):
|
169 |
+
task_name = gr.Dropdown(
|
170 |
+
label="Task Name",
|
171 |
+
choices=SEQUENCE_NAMES,
|
172 |
+
value=default_task,
|
173 |
+
)
|
174 |
+
episode_index = gr.Dropdown(
|
175 |
+
label="Episode Index",
|
176 |
+
choices=initial_eps,
|
177 |
+
value=initial_eps[0] if initial_eps else None,
|
178 |
+
|
179 |
+
)
|
180 |
+
|
181 |
+
def _update_eps(t): # Gradio wants a fn
|
182 |
+
eps = list_episodes(t)
|
183 |
+
return gr.update(choices=eps, value=eps[0] if eps else None)
|
184 |
+
|
185 |
+
task_name.change(_update_eps, inputs=task_name, outputs=episode_index)
|
186 |
+
|
187 |
+
button = gr.Button("Show Dataset")
|
188 |
+
with gr.Column(scale=4):
|
189 |
+
viewer = Rerun(
|
190 |
+
streaming=True,
|
191 |
+
panel_states={
|
192 |
+
"time": "collapsed",
|
193 |
+
"blueprint": "hidden",
|
194 |
+
"selection": "hidden",
|
195 |
+
},
|
196 |
+
)
|
197 |
+
# choose_rrd.change(lambda x: x, inputs=[choose_rrd], outputs=[viewer])
|
198 |
+
button.click(
|
199 |
+
fn=show_dataset,
|
200 |
+
inputs=[task_name, episode_index],
|
201 |
+
outputs=[viewer]
|
202 |
+
)
|
203 |
+
|
204 |
+
|
205 |
|
206 |
|
207 |
if __name__ == "__main__":
|