Spaces:
Runtime error
Runtime error
Update multi_video_app.py
Browse files- multi_video_app.py +7 -8
multi_video_app.py
CHANGED
@@ -9,7 +9,7 @@ import torch
|
|
9 |
from src.video_model import describe_video
|
10 |
from src.utils import parse_string, parse_annotations
|
11 |
|
12 |
-
|
13 |
|
14 |
# Function to save data to a CSV file
|
15 |
def save_to_csv(observations: List[Dict], output_dir: str = "outputs") -> str:
|
@@ -77,9 +77,8 @@ def process_single_video(video_path: str, sitting, hands, location, screen) -> D
|
|
77 |
return {"error": f"An error occurred with {video_name}: {e}"}
|
78 |
|
79 |
# Function to process all videos in a folder
|
80 |
-
def
|
81 |
all_observations = []
|
82 |
-
video_files = [os.path.join(videos_folder, f) for f in os.listdir(videos_folder) if f.endswith(('.mp4', '.avi', '.mkv'))]
|
83 |
|
84 |
for video_path in video_files:
|
85 |
observation = process_single_video(video_path, sitting, hands, location, screen)
|
@@ -96,11 +95,11 @@ def process_folder_of_videos(videos_folder: str, sitting, hands, location, scree
|
|
96 |
return "Processing completed. Download the CSV file.", csv_file
|
97 |
|
98 |
# Gradio interface
|
99 |
-
def gradio_interface(
|
100 |
-
return
|
101 |
|
102 |
# Inputs
|
103 |
-
|
104 |
sitting = gr.Checkbox(label="Sitting/Standing")
|
105 |
hands = gr.Checkbox(label="Hands Free/Not Free")
|
106 |
location = gr.Checkbox(label="Indoors/Outdoors")
|
@@ -113,10 +112,10 @@ download_link = gr.File(label="Download CSV")
|
|
113 |
# Gradio interface setup
|
114 |
interface = gr.Interface(
|
115 |
fn=gradio_interface,
|
116 |
-
inputs=[
|
117 |
outputs=[response, download_link],
|
118 |
title="Batch Video Annotation",
|
119 |
-
description="Upload
|
120 |
theme=gr.themes.Soft(primary_hue="red", secondary_hue="red"),
|
121 |
allow_flagging="never"
|
122 |
)
|
|
|
9 |
from src.video_model import describe_video
|
10 |
from src.utils import parse_string, parse_annotations
|
11 |
|
12 |
+
|
13 |
|
14 |
# Function to save data to a CSV file
|
15 |
def save_to_csv(observations: List[Dict], output_dir: str = "outputs") -> str:
|
|
|
77 |
return {"error": f"An error occurred with {video_name}: {e}"}
|
78 |
|
79 |
# Function to process all videos in a folder
|
80 |
+
def process_multiple_videos(video_files: List[str], sitting, hands, location, screen):
|
81 |
all_observations = []
|
|
|
82 |
|
83 |
for video_path in video_files:
|
84 |
observation = process_single_video(video_path, sitting, hands, location, screen)
|
|
|
95 |
return "Processing completed. Download the CSV file.", csv_file
|
96 |
|
97 |
# Gradio interface
|
98 |
+
def gradio_interface(video_files, sitting, hands, location, screen):
|
99 |
+
return process_multiple_videos(video_files, sitting, hands, location, screen)
|
100 |
|
101 |
# Inputs
|
102 |
+
video_files = gr.File(file_count="multiple", file_types=["video"], label="Upload multiple videos")
|
103 |
sitting = gr.Checkbox(label="Sitting/Standing")
|
104 |
hands = gr.Checkbox(label="Hands Free/Not Free")
|
105 |
location = gr.Checkbox(label="Indoors/Outdoors")
|
|
|
112 |
# Gradio interface setup
|
113 |
interface = gr.Interface(
|
114 |
fn=gradio_interface,
|
115 |
+
inputs=[video_files, sitting, hands, location, screen],
|
116 |
outputs=[response, download_link],
|
117 |
title="Batch Video Annotation",
|
118 |
+
description="Upload multiple videos and process them sequentially, saving the results to a downloadable CSV file.",
|
119 |
theme=gr.themes.Soft(primary_hue="red", secondary_hue="red"),
|
120 |
allow_flagging="never"
|
121 |
)
|