Spaces:
Runtime error
Runtime error
ManishThota
commited on
Commit
•
0ec47c6
1
Parent(s):
92f266c
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,13 @@
|
|
|
|
1 |
import warnings
|
2 |
warnings.filterwarnings("ignore")
|
3 |
import gradio as gr
|
4 |
-
from src.video_model import describe_video #
|
|
|
5 |
|
6 |
-
# --- Function to
|
7 |
-
def
|
8 |
-
query = "Describe this video in detail and answer the questions"
|
9 |
additional_info = []
|
10 |
if sitting:
|
11 |
additional_info.append("Is the subject in the video standing or sitting?")
|
@@ -15,23 +17,23 @@ def process_video_and_questions(video, sitting, hands, location, screen):
|
|
15 |
additional_info.append("Is the subject present indoors or outdoors?")
|
16 |
if screen:
|
17 |
additional_info.append("Is the subject interacting with a screen in the background by facing the screen?")
|
18 |
-
|
19 |
final_query = query + " " + " ".join(additional_info)
|
20 |
-
# Assuming your describe_video function handles the video processing
|
21 |
-
response = describe_video(video, final_query)
|
22 |
-
return response
|
23 |
|
24 |
-
|
25 |
-
|
|
|
|
|
26 |
|
27 |
-
#
|
|
|
28 |
sitting = gr.Checkbox(label="Sitting/Standing")
|
29 |
hands = gr.Checkbox(label="Hands Free/Not Free")
|
30 |
location = gr.Checkbox(label="Indoors/Outdoors")
|
31 |
screen = gr.Checkbox(label="Screen Interaction")
|
32 |
|
33 |
-
|
34 |
-
|
35 |
|
36 |
# Examples for the interface
|
37 |
examples = [
|
@@ -53,17 +55,15 @@ title = "GSoC Super Raid Annotator"
|
|
53 |
description = "Annotate Videos"
|
54 |
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>"
|
55 |
|
56 |
-
|
57 |
custom_theme = gr.themes.Soft(
|
58 |
-
# Set the primary hue of the Soft theme to your red color
|
59 |
primary_hue="red",
|
60 |
-
secondary_hue="red"
|
|
|
61 |
|
62 |
-
# Launch the interface
|
63 |
interface = gr.Interface(
|
64 |
-
fn=
|
65 |
-
inputs=[video, sitting, hands, location, screen],
|
66 |
-
outputs=
|
67 |
examples=examples,
|
68 |
title=title,
|
69 |
description=description,
|
|
|
1 |
+
# --- main.py (your Gradio app file) ---
|
2 |
import warnings
|
3 |
warnings.filterwarnings("ignore")
|
4 |
import gradio as gr
|
5 |
+
from src.video_model import describe_video # Your video processing function
|
6 |
+
from src.text_processor import process_description
|
7 |
|
8 |
+
# --- Function to handle both video and text processing ---
|
9 |
+
def process_video_and_get_json(video, sitting, hands, location, screen):
|
10 |
+
query = "Describe this video in detail and answer the questions."
|
11 |
additional_info = []
|
12 |
if sitting:
|
13 |
additional_info.append("Is the subject in the video standing or sitting?")
|
|
|
17 |
additional_info.append("Is the subject present indoors or outdoors?")
|
18 |
if screen:
|
19 |
additional_info.append("Is the subject interacting with a screen in the background by facing the screen?")
|
20 |
+
|
21 |
final_query = query + " " + " ".join(additional_info)
|
|
|
|
|
|
|
22 |
|
23 |
+
video_description = describe_video(video, final_query)
|
24 |
+
json_response = process_description(video_description)
|
25 |
+
|
26 |
+
return video_description, json_response
|
27 |
|
28 |
+
# --- Gradio Interface ---
|
29 |
+
video = gr.Video(label="Video")
|
30 |
sitting = gr.Checkbox(label="Sitting/Standing")
|
31 |
hands = gr.Checkbox(label="Hands Free/Not Free")
|
32 |
location = gr.Checkbox(label="Indoors/Outdoors")
|
33 |
screen = gr.Checkbox(label="Screen Interaction")
|
34 |
|
35 |
+
video_description = gr.Textbox(label="Video Description", show_label=True, show_copy_button=True)
|
36 |
+
json_output = gr.JSON(label="JSON Output")
|
37 |
|
38 |
# Examples for the interface
|
39 |
examples = [
|
|
|
55 |
description = "Annotate Videos"
|
56 |
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>"
|
57 |
|
|
|
58 |
custom_theme = gr.themes.Soft(
|
|
|
59 |
primary_hue="red",
|
60 |
+
secondary_hue="red"
|
61 |
+
)
|
62 |
|
|
|
63 |
interface = gr.Interface(
|
64 |
+
fn=process_video_and_get_json,
|
65 |
+
inputs=[video, sitting, hands, location, screen],
|
66 |
+
outputs=[video_description, json_output],
|
67 |
examples=examples,
|
68 |
title=title,
|
69 |
description=description,
|