Spaces:
Runtime error
Runtime error
Update run.py
Browse files
run.py
CHANGED
|
@@ -8,6 +8,8 @@ dataset_options = [
|
|
| 8 |
"OpenVideo/pexels-raw",
|
| 9 |
"OpenVideo/Sample-2k",
|
| 10 |
]
|
|
|
|
|
|
|
| 11 |
|
| 12 |
def login(token):
|
| 13 |
u = HFUser.from_token(token)
|
|
@@ -19,9 +21,7 @@ def show_time(u, name):
|
|
| 19 |
def list_dataset(u, repo):
|
| 20 |
print(f"repo is: {repo}")
|
| 21 |
files = u.list_dataset(repo)
|
| 22 |
-
|
| 23 |
-
print(f"files is: {files}")
|
| 24 |
-
return gr.Dropdown(choices=files), gr.Column(visible=True), gr.Column(visible=False)
|
| 25 |
return gr.Dropdown(value=files[0], choices=files), gr.Column(visible=True), gr.Column(visible=False)
|
| 26 |
|
| 27 |
def fetch_parquet(u, fname):
|
|
@@ -54,6 +54,9 @@ def next_chunks(video_chunks, epoch_idx):
|
|
| 54 |
length = len(video_chunks)
|
| 55 |
return (epoch_idx+1)%length, gr.Slider(value=0)
|
| 56 |
|
|
|
|
|
|
|
|
|
|
| 57 |
with gr.Blocks(**GR_CONF) as Core:
|
| 58 |
user = gr.State()
|
| 59 |
epoch_idx = gr.State(0)
|
|
@@ -93,7 +96,8 @@ with gr.Blocks(**GR_CONF) as Core:
|
|
| 93 |
submit = gr.Button("Submit", variant="primary", size="sm", scale=1)
|
| 94 |
with gr.Row():
|
| 95 |
rst = gr.Button("Reset", variant="stop", size="sm", scale=1)
|
| 96 |
-
nxt = gr.Button("Next Batch
|
|
|
|
| 97 |
|
| 98 |
_auth.click(fn=login, inputs=_token, outputs=[user, name, Auth])
|
| 99 |
name.change(fn=show_time, inputs=[user, name], outputs=[time, Repo])
|
|
@@ -104,6 +108,7 @@ with gr.Blocks(**GR_CONF) as Core:
|
|
| 104 |
_pick.change(fn=select_video, inputs=[video_chunks, epoch_idx, _pick], outputs=_video)
|
| 105 |
_video.change(fn=show_lables, outputs=Tag)
|
| 106 |
nxt.click(fn=next_chunks, inputs=[video_chunks, epoch_idx], outputs=[epoch_idx, _pick])
|
|
|
|
| 107 |
|
| 108 |
if __name__ == "__main__":
|
| 109 |
Core.launch()
|
|
|
|
| 8 |
"OpenVideo/pexels-raw",
|
| 9 |
"OpenVideo/Sample-2k",
|
| 10 |
]
|
| 11 |
+
fetch_files = []
|
| 12 |
+
fetch_files_select_idx = 0
|
| 13 |
|
| 14 |
def login(token):
|
| 15 |
u = HFUser.from_token(token)
|
|
|
|
| 21 |
def list_dataset(u, repo):
|
| 22 |
print(f"repo is: {repo}")
|
| 23 |
files = u.list_dataset(repo)
|
| 24 |
+
fetch_files = files
|
|
|
|
|
|
|
| 25 |
return gr.Dropdown(value=files[0], choices=files), gr.Column(visible=True), gr.Column(visible=False)
|
| 26 |
|
| 27 |
def fetch_parquet(u, fname):
|
|
|
|
| 54 |
length = len(video_chunks)
|
| 55 |
return (epoch_idx+1)%length, gr.Slider(value=0)
|
| 56 |
|
| 57 |
+
def next_mp4_chunks(video_chunks, epoch_idx):
|
| 58 |
+
return gr.Dropdown(value=fetch_files[fetch_files_select_idx + 1], choices=fetch_files)
|
| 59 |
+
|
| 60 |
with gr.Blocks(**GR_CONF) as Core:
|
| 61 |
user = gr.State()
|
| 62 |
epoch_idx = gr.State(0)
|
|
|
|
| 96 |
submit = gr.Button("Submit", variant="primary", size="sm", scale=1)
|
| 97 |
with gr.Row():
|
| 98 |
rst = gr.Button("Reset", variant="stop", size="sm", scale=1)
|
| 99 |
+
nxt = gr.Button("Next Batch", variant="secondary", size="sm", scale=1)
|
| 100 |
+
nxt_mp4 = gr.Button("Next MP4", variant="secondary", size="sm", scale=1)
|
| 101 |
|
| 102 |
_auth.click(fn=login, inputs=_token, outputs=[user, name, Auth])
|
| 103 |
name.change(fn=show_time, inputs=[user, name], outputs=[time, Repo])
|
|
|
|
| 108 |
_pick.change(fn=select_video, inputs=[video_chunks, epoch_idx, _pick], outputs=_video)
|
| 109 |
_video.change(fn=show_lables, outputs=Tag)
|
| 110 |
nxt.click(fn=next_chunks, inputs=[video_chunks, epoch_idx], outputs=[epoch_idx, _pick])
|
| 111 |
+
nxt_mp4.click(fn=next_mp4_chunks, inputs=[video_chunks, epoch_idx], outputs=[file])
|
| 112 |
|
| 113 |
if __name__ == "__main__":
|
| 114 |
Core.launch()
|