Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,10 +2,15 @@ import warnings
|
|
2 |
warnings.filterwarnings("ignore")
|
3 |
import gradio as gr
|
4 |
from src.video_model import describe_video # Assuming this function processes the video and query
|
|
|
5 |
|
6 |
# --- Function to construct the final query ---
|
7 |
def process_video_and_questions(video, sitting, hands, location, screen):
|
8 |
-
|
|
|
|
|
|
|
|
|
9 |
additional_info = []
|
10 |
if sitting:
|
11 |
additional_info.append("Is the subject in the video standing or sitting?")
|
@@ -22,9 +27,11 @@ def process_video_and_questions(video, sitting, hands, location, screen):
|
|
22 |
<annotation>screen_interaction: 0</annotation>"""
|
23 |
final_query = query + " " + " ".join(additional_info)
|
24 |
final_prompt = final_query + " " + end_query
|
|
|
25 |
# Assuming your describe_video function handles the video processing
|
26 |
response = describe_video(video, final_prompt)
|
27 |
-
|
|
|
28 |
|
29 |
# Video and text inputs for the interface
|
30 |
video = gr.Video(label="Video")
|
@@ -58,15 +65,13 @@ title = "GSoC Super Raid Annotator"
|
|
58 |
description = "Annotate Videos"
|
59 |
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>"
|
60 |
|
61 |
-
|
62 |
custom_theme = gr.themes.Soft(
|
63 |
-
# Set the primary hue of the Soft theme to your red color
|
64 |
primary_hue="red",
|
65 |
secondary_hue="red")
|
66 |
|
67 |
# Launch the interface
|
68 |
interface = gr.Interface(
|
69 |
-
fn=process_video_and_questions,
|
70 |
inputs=[video, sitting, hands, location, screen],
|
71 |
outputs=response,
|
72 |
examples=examples,
|
@@ -76,4 +81,4 @@ interface = gr.Interface(
|
|
76 |
theme=custom_theme,
|
77 |
allow_flagging="never",
|
78 |
)
|
79 |
-
interface.launch(debug=False)
|
|
|
2 |
warnings.filterwarnings("ignore")
|
3 |
import gradio as gr
|
4 |
from src.video_model import describe_video # Assuming this function processes the video and query
|
5 |
+
import os
|
6 |
|
7 |
# --- Function to construct the final query ---
|
8 |
def process_video_and_questions(video, sitting, hands, location, screen):
|
9 |
+
# Extract the video name (filename)
|
10 |
+
video_name = os.path.basename(video)
|
11 |
+
|
12 |
+
# Construct the query with the video name included
|
13 |
+
query = f"Describe the video '{video_name}' in detail and answer the questions"
|
14 |
additional_info = []
|
15 |
if sitting:
|
16 |
additional_info.append("Is the subject in the video standing or sitting?")
|
|
|
27 |
<annotation>screen_interaction: 0</annotation>"""
|
28 |
final_query = query + " " + " ".join(additional_info)
|
29 |
final_prompt = final_query + " " + end_query
|
30 |
+
|
31 |
# Assuming your describe_video function handles the video processing
|
32 |
response = describe_video(video, final_prompt)
|
33 |
+
final_response = f"<video_name>{video_name}</video_name>" + " " + response
|
34 |
+
return final_response
|
35 |
|
36 |
# Video and text inputs for the interface
|
37 |
video = gr.Video(label="Video")
|
|
|
65 |
description = "Annotate Videos"
|
66 |
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>"
|
67 |
|
|
|
68 |
custom_theme = gr.themes.Soft(
|
|
|
69 |
primary_hue="red",
|
70 |
secondary_hue="red")
|
71 |
|
72 |
# Launch the interface
|
73 |
interface = gr.Interface(
|
74 |
+
fn=process_video_and_questions,
|
75 |
inputs=[video, sitting, hands, location, screen],
|
76 |
outputs=response,
|
77 |
examples=examples,
|
|
|
81 |
theme=custom_theme,
|
82 |
allow_flagging="never",
|
83 |
)
|
84 |
+
interface.launch(debug=False)
|