Spaces:
Runtime error
Runtime error
ManishThota
commited on
Commit
•
57a114d
1
Parent(s):
1b7a970
Update app.py
Browse files
app.py
CHANGED
@@ -27,20 +27,41 @@ def process_video(video, sitting, hands, location, screen):
|
|
27 |
def process_and_display_json(video_description):
|
28 |
json_response = process_description(video_description)
|
29 |
return json_response
|
30 |
-
|
31 |
-
# --- Gradio Interface ---
|
32 |
-
video = gr.Video(label="Video")
|
33 |
-
sitting = gr.Checkbox(label="Sitting/Standing")
|
34 |
-
hands = gr.Checkbox(label="Hands Free/Not Free")
|
35 |
-
location = gr.Checkbox(label="Indoors/Outdoors")
|
36 |
-
screen = gr.Checkbox(label="Screen Interaction")
|
37 |
|
38 |
-
video_description = gr.Textbox(label="Video Description", show_label=True, show_copy_button=True)
|
39 |
-
json_output = gr.JSON(label="JSON Output")
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
-
#
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
["videos/2016-01-01_0100_US_KNBC_Channel_4_News_1867.16-1871.38_now.mp4",],
|
45 |
["videos/2016-01-01_0200_US_KNBC_Channel_4_News_1329.12-1333.29_tonight.mp4",],
|
46 |
["videos/2016-01-01_0830_US_KNBC_Tonight_Show_with_Jimmy_Fallon_725.45-729.76_tonight.mp4",],
|
@@ -52,40 +73,20 @@ examples = [
|
|
52 |
["videos/2016-01-01_1300_US_KNBC_Today_in_LA_at_5am_12.46-16.95_this_morning.mp4"],
|
53 |
["videos/2016-01-05_0200_US_KNBC_Channel_4_News_1561.29-1565.95_next_week.mp4"],
|
54 |
["videos/2016-01-28_0700_US_KNBC_Channel_4_News_at_11PM_629.56-633.99_in_the_future.mp4"]
|
55 |
-
]
|
56 |
-
|
57 |
-
# Title, description, and article for the interface
|
58 |
-
title = "GSoC Super Raid Annotator"
|
59 |
-
description = "Annotate Videos"
|
60 |
-
article = "<p style='text-align: center'><a href='https://github.com/OpenBMB/MiniCPM-V' target='_blank'>Model GitHub Repo</a> | <a href='https://huggingface.co/openbmb/MiniCPM-V-2_6' target='_blank'>Model Page</a></p>"
|
61 |
-
|
62 |
-
custom_theme = gr.themes.Soft(
|
63 |
-
primary_hue="blue",
|
64 |
-
secondary_hue="blue",
|
65 |
-
neutral_hue="zinc"
|
66 |
-
)
|
67 |
|
68 |
-
#
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
title=title,
|
75 |
-
description=description,
|
76 |
-
article=article,
|
77 |
-
theme=custom_theme,
|
78 |
-
allow_flagging="never",
|
79 |
-
live=True # Add live=True here
|
80 |
-
)
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
live=True,
|
88 |
-
live_inputs=[0] # Update based on the first input (video_description)
|
89 |
-
)
|
90 |
|
91 |
-
interface
|
|
|
|
27 |
def process_and_display_json(video_description):
|
28 |
json_response = process_description(video_description)
|
29 |
return json_response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
|
|
|
|
31 |
|
32 |
+
# --- Function to handle JSON processing ---
|
33 |
+
def process_and_display_json(video_description):
|
34 |
+
json_response = process_description(video_description)
|
35 |
+
return json_response
|
36 |
+
|
37 |
+
# --- Gradio Blocks Interface ---
|
38 |
+
with gr.Blocks(title="GSoC Super Raid Annotator", theme=gr.themes.Soft(primary_hue="red", secondary_hue="red")) as demo:
|
39 |
+
gr.Markdown("Annotate Videos")
|
40 |
+
gr.Markdown(
|
41 |
+
"<p style='text-align: center'><a href='https://github.com/OpenBMB/MiniCPM-V' target='_blank'>Model GitHub Repo</a> | <a href='https://huggingface.co/openbmb/MiniCPM-V-2_6' target='_blank'>Model Page</a></p>"
|
42 |
+
)
|
43 |
+
|
44 |
+
with gr.Row():
|
45 |
+
with gr.Column():
|
46 |
+
# Input components
|
47 |
+
video = gr.Video(label="Video")
|
48 |
+
sitting = gr.Checkbox(label="Sitting/Standing")
|
49 |
+
hands = gr.Checkbox(label="Hands Free/Not Free")
|
50 |
+
location = gr.Checkbox(label="Indoors/Outdoors")
|
51 |
+
screen = gr.Checkbox(label="Screen Interaction")
|
52 |
|
53 |
+
# Submit buttons
|
54 |
+
with gr.Row():
|
55 |
+
process_video_btn = gr.Button("Process Video")
|
56 |
+
process_json_btn = gr.Button("Process JSON")
|
57 |
+
|
58 |
+
with gr.Column():
|
59 |
+
# Output components
|
60 |
+
video_description = gr.Textbox(label="Video Description", show_label=True, show_copy_button=True)
|
61 |
+
json_output = gr.JSON(label="JSON Output")
|
62 |
+
|
63 |
+
# Examples for the interface
|
64 |
+
examples = [
|
65 |
["videos/2016-01-01_0100_US_KNBC_Channel_4_News_1867.16-1871.38_now.mp4",],
|
66 |
["videos/2016-01-01_0200_US_KNBC_Channel_4_News_1329.12-1333.29_tonight.mp4",],
|
67 |
["videos/2016-01-01_0830_US_KNBC_Tonight_Show_with_Jimmy_Fallon_725.45-729.76_tonight.mp4",],
|
|
|
73 |
["videos/2016-01-01_1300_US_KNBC_Today_in_LA_at_5am_12.46-16.95_this_morning.mp4"],
|
74 |
["videos/2016-01-05_0200_US_KNBC_Channel_4_News_1561.29-1565.95_next_week.mp4"],
|
75 |
["videos/2016-01-28_0700_US_KNBC_Channel_4_News_at_11PM_629.56-633.99_in_the_future.mp4"]
|
76 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
+
# Event handling
|
79 |
+
process_video_btn.click(
|
80 |
+
fn=process_video,
|
81 |
+
inputs=[video, sitting, hands, location, screen],
|
82 |
+
outputs=video_description,
|
83 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
+
process_json_btn.click(
|
86 |
+
fn=process_and_display_json,
|
87 |
+
inputs=video_description,
|
88 |
+
outputs=json_output,
|
89 |
+
)
|
|
|
|
|
|
|
90 |
|
91 |
+
# Launch the interface
|
92 |
+
demo.launch(debug=False)
|