Spaces:
Sleeping
Sleeping
ManishThota
commited on
Commit
•
eba62a3
1
Parent(s):
ba1eb4b
Update app.py
Browse files
app.py
CHANGED
@@ -66,8 +66,8 @@ def process_video(video_file, question):
|
|
66 |
return generated_text.split("ASSISTANT: ", 1)[-1].strip()
|
67 |
|
68 |
@spaces.GPU
|
69 |
-
def analyze_videos(video_files,
|
70 |
-
"""Analyzes all videos with the selected
|
71 |
all_results = {}
|
72 |
|
73 |
questions = {
|
@@ -79,8 +79,11 @@ def analyze_videos(video_files, selected_question):
|
|
79 |
|
80 |
for video_file in video_files:
|
81 |
video_name = os.path.basename(video_file.name)
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
84 |
return json.dumps(all_results, indent=4)
|
85 |
|
86 |
# Define Gradio interface
|
@@ -88,12 +91,12 @@ iface = gr.Interface(
|
|
88 |
fn=analyze_videos,
|
89 |
inputs=[
|
90 |
gr.File(label="Upload Videos", file_count="multiple"),
|
91 |
-
gr.
|
92 |
-
|
93 |
],
|
94 |
outputs=gr.JSON(label="Analysis Results"),
|
95 |
title="Video Analysis",
|
96 |
-
description="Upload videos and select
|
97 |
)
|
98 |
|
99 |
if __name__ == "__main__":
|
|
|
66 |
return generated_text.split("ASSISTANT: ", 1)[-1].strip()
|
67 |
|
68 |
@spaces.GPU
|
69 |
+
def analyze_videos(video_files, selected_questions):
|
70 |
+
"""Analyzes all videos with the selected questions."""
|
71 |
all_results = {}
|
72 |
|
73 |
questions = {
|
|
|
79 |
|
80 |
for video_file in video_files:
|
81 |
video_name = os.path.basename(video_file.name)
|
82 |
+
all_results[video_name] = {}
|
83 |
+
for question_key in selected_questions:
|
84 |
+
answer = process_video(video_file, questions[question_key])
|
85 |
+
# Simple True/False determination (You might want to refine this)
|
86 |
+
all_results[video_name][question_key] = "true" if "yes" in answer.lower() else "false"
|
87 |
return json.dumps(all_results, indent=4)
|
88 |
|
89 |
# Define Gradio interface
|
|
|
91 |
fn=analyze_videos,
|
92 |
inputs=[
|
93 |
gr.File(label="Upload Videos", file_count="multiple"),
|
94 |
+
gr.CheckboxGroup(["hands_free", "standing/sitting", "interaction_with_background", "indoors/outdoors"],
|
95 |
+
label="Select Questions to Apply")
|
96 |
],
|
97 |
outputs=gr.JSON(label="Analysis Results"),
|
98 |
title="Video Analysis",
|
99 |
+
description="Upload videos and select questions to analyze."
|
100 |
)
|
101 |
|
102 |
if __name__ == "__main__":
|