Spaces:
Runtime error
Runtime error
ManishThota
commited on
Commit
•
c78e00d
1
Parent(s):
9871891
Update app.py
Browse files
app.py
CHANGED
@@ -48,17 +48,20 @@
|
|
48 |
# )
|
49 |
# interface.launch(debug=False)
|
50 |
|
|
|
51 |
import warnings
|
52 |
warnings.filterwarnings("ignore")
|
53 |
import gradio as gr
|
54 |
from src.video_model import describe_video # Assuming this function processes the video and query
|
55 |
|
56 |
-
|
|
|
|
|
57 |
additional_info = []
|
58 |
if sitting:
|
59 |
additional_info.append("Is the subject in the video standing or sitting?")
|
60 |
if hands:
|
61 |
-
additional_info.append("Is the subject holding any object in their hands, if so the hands are not free else they are free
|
62 |
if location:
|
63 |
additional_info.append("Is the subject present indoors or outdoors?")
|
64 |
if screen:
|
@@ -71,7 +74,6 @@ def process_video_and_questions(video, query, sitting, hands, location, screen):
|
|
71 |
|
72 |
# Video and text inputs for the interface
|
73 |
video = gr.Video(label="Video")
|
74 |
-
query = gr.Textbox(label="Question", value="Here are some frames of a video. Describe this video in detail and answer the below questions.", placeholder="Enter your question here")
|
75 |
|
76 |
# Options as checkboxes
|
77 |
sitting = gr.Checkbox(label="Sitting/Standing")
|
@@ -86,14 +88,11 @@ response = gr.Textbox(label="Predicted answer", show_label=True, show_copy_butto
|
|
86 |
examples = [
|
87 |
[
|
88 |
"videos/2016-01-01_0100_US_KNBC_Channel_4_News_1867.16-1871.38_now.mp4",
|
89 |
-
"Here are some frames of a video. Describe this video in detail."
|
90 |
],
|
91 |
[
|
92 |
"videos/2016-01-01_0200_US_KNBC_Channel_4_News_1329.12-1333.29_tonight.mp4",
|
93 |
-
"Here are some frames of a video. Describe this video in detail."
|
94 |
],
|
95 |
[ "videos/2016-01-01_0830_US_KNBC_Tonight_Show_with_Jimmy_Fallon_725.45-729.76_tonight.mp4",
|
96 |
-
"Here are some frames of a video. Describe this video in detail."
|
97 |
]
|
98 |
]
|
99 |
|
@@ -105,7 +104,7 @@ article = "<p style='text-align: center'><a href='https://github.com/OpenBMB/Min
|
|
105 |
# Launch the interface
|
106 |
interface = gr.Interface(
|
107 |
fn=process_video_and_questions, # Updated function to handle the query construction
|
108 |
-
inputs=[video,
|
109 |
outputs=response,
|
110 |
examples=examples,
|
111 |
title=title,
|
|
|
48 |
# )
|
49 |
# interface.launch(debug=False)
|
50 |
|
51 |
+
|
52 |
import warnings
|
53 |
warnings.filterwarnings("ignore")
|
54 |
import gradio as gr
|
55 |
from src.video_model import describe_video # Assuming this function processes the video and query
|
56 |
|
57 |
+
# --- Function to construct the final query ---
|
58 |
+
def process_video_and_questions(video, sitting, hands, location, screen):
|
59 |
+
query = "Here are some frames of a video. Describe this video in detail."
|
60 |
additional_info = []
|
61 |
if sitting:
|
62 |
additional_info.append("Is the subject in the video standing or sitting?")
|
63 |
if hands:
|
64 |
+
additional_info.append("Is the subject holding any object in their hands, if so the hands are not free else they are free?")
|
65 |
if location:
|
66 |
additional_info.append("Is the subject present indoors or outdoors?")
|
67 |
if screen:
|
|
|
74 |
|
75 |
# Video and text inputs for the interface
|
76 |
video = gr.Video(label="Video")
|
|
|
77 |
|
78 |
# Options as checkboxes
|
79 |
sitting = gr.Checkbox(label="Sitting/Standing")
|
|
|
88 |
examples = [
|
89 |
[
|
90 |
"videos/2016-01-01_0100_US_KNBC_Channel_4_News_1867.16-1871.38_now.mp4",
|
|
|
91 |
],
|
92 |
[
|
93 |
"videos/2016-01-01_0200_US_KNBC_Channel_4_News_1329.12-1333.29_tonight.mp4",
|
|
|
94 |
],
|
95 |
[ "videos/2016-01-01_0830_US_KNBC_Tonight_Show_with_Jimmy_Fallon_725.45-729.76_tonight.mp4",
|
|
|
96 |
]
|
97 |
]
|
98 |
|
|
|
104 |
# Launch the interface
|
105 |
interface = gr.Interface(
|
106 |
fn=process_video_and_questions, # Updated function to handle the query construction
|
107 |
+
inputs=[video, sitting, hands, location, screen],
|
108 |
outputs=response,
|
109 |
examples=examples,
|
110 |
title=title,
|