Spaces:
Sleeping
Sleeping
Commit
·
c3f878d
1
Parent(s):
b3bc292
Huggingface auth login
Browse files
app.py
CHANGED
|
@@ -10,7 +10,7 @@ user = ""
|
|
| 10 |
def get_username(profile: gr.OAuthProfile):
|
| 11 |
global user
|
| 12 |
user = profile.username
|
| 13 |
-
return profile
|
| 14 |
|
| 15 |
|
| 16 |
def save(df, video_id):
|
|
@@ -36,28 +36,37 @@ def get_next_components():
|
|
| 36 |
(start_video, start_captions, start_video_id) = get_next_components()
|
| 37 |
|
| 38 |
with gr.Blocks(css=css) as main_page:
|
| 39 |
-
gr.Markdown("
|
|
|
|
| 40 |
gr.LoginButton()
|
| 41 |
-
|
|
|
|
| 42 |
current_video_id = gr.Textbox(value=start_video_id, visible=False, interactive=False)
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
main_page.launch(share=True, ssr_mode=False)
|
|
|
|
| 10 |
def get_username(profile: gr.OAuthProfile):
|
| 11 |
global user
|
| 12 |
user = profile.username
|
| 13 |
+
return profile
|
| 14 |
|
| 15 |
|
| 16 |
def save(df, video_id):
|
|
|
|
| 36 |
(start_video, start_captions, start_video_id) = get_next_components()
|
| 37 |
|
| 38 |
with gr.Blocks(css=css) as main_page:
|
| 39 |
+
gr.Markdown("# Caption Editor")
|
| 40 |
+
|
| 41 |
gr.LoginButton()
|
| 42 |
+
|
| 43 |
+
current_user = gr.Textbox(visible=False, interactive=False)
|
| 44 |
current_video_id = gr.Textbox(value=start_video_id, visible=False, interactive=False)
|
| 45 |
+
|
| 46 |
+
main_page.load(get_username, outputs=current_user)
|
| 47 |
+
|
| 48 |
+
@gr.render(inputs=current_user)
|
| 49 |
+
def render_page(logged_in_user):
|
| 50 |
+
if logged_in_user is None:
|
| 51 |
+
gr.Markdown("## Please log in via Hugging Face")
|
| 52 |
+
else:
|
| 53 |
+
with gr.Row():
|
| 54 |
+
with gr.Column():
|
| 55 |
+
caption_editor = gr.DataFrame(interactive=True,
|
| 56 |
+
value=start_captions,
|
| 57 |
+
datatype=["number", "str", "number"],
|
| 58 |
+
row_count=(start_captions.shape[0], "fixed"),
|
| 59 |
+
col_count=(3, "fixed"), column_widths=["20%", "60%", "20%"])
|
| 60 |
+
save_button = gr.Button(value="Save")
|
| 61 |
+
save_result = gr.Markdown()
|
| 62 |
+
with gr.Column():
|
| 63 |
+
video_embed = gr.HTML(value=start_video)
|
| 64 |
+
next_video_button = gr.Button("Next")
|
| 65 |
+
|
| 66 |
+
next_video_button.click(fn=get_next_components,
|
| 67 |
+
outputs=[video_embed, caption_editor, current_video_id])
|
| 68 |
+
save_button.click(fn=save,
|
| 69 |
+
inputs=[caption_editor, current_video_id],
|
| 70 |
+
outputs=save_result)
|
| 71 |
|
| 72 |
main_page.launch(share=True, ssr_mode=False)
|