Spaces:
Runtime error
Runtime error
Update multi_video_app.py
Browse files- multi_video_app.py +19 -21
multi_video_app.py
CHANGED
@@ -20,14 +20,14 @@ def save_to_csv(observations: List[Dict], output_dir: str = "outputs") -> str:
|
|
20 |
|
21 |
with open(csv_file, mode='w', newline='') as file:
|
22 |
writer = csv.writer(file)
|
23 |
-
writer.writerow(["video_name", "standing", "
|
24 |
for observation in observations:
|
25 |
writer.writerow([
|
26 |
observation['video_name'],
|
27 |
observation['standing'],
|
28 |
-
observation['
|
29 |
observation['indoors'],
|
30 |
-
observation['
|
31 |
])
|
32 |
|
33 |
return csv_file
|
@@ -57,24 +57,22 @@ def process_single_video(video_path: str, sitting, hands, location, screen) -> D
|
|
57 |
final_prompt = final_query + " " + end_query
|
58 |
|
59 |
# Assuming your describe_video function handles the video processing
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
except Exception as e:
|
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):
|
|
|
20 |
|
21 |
with open(csv_file, mode='w', newline='') as file:
|
22 |
writer = csv.writer(file)
|
23 |
+
writer.writerow(["video_name", "standing", "hands.free", "indoors", "screen.interaction_yes"])
|
24 |
for observation in observations:
|
25 |
writer.writerow([
|
26 |
observation['video_name'],
|
27 |
observation['standing'],
|
28 |
+
observation['hands.free'],
|
29 |
observation['indoors'],
|
30 |
+
observation['screen.interaction_yes']
|
31 |
])
|
32 |
|
33 |
return csv_file
|
|
|
57 |
final_prompt = final_query + " " + end_query
|
58 |
|
59 |
# Assuming your describe_video function handles the video processing
|
60 |
+
final_response = describe_video(video_path, final_prompt)
|
61 |
+
|
62 |
+
conditions = {
|
63 |
+
'standing': (standing, 'standing: 1', 'standing: None'),
|
64 |
+
'hands': (hands, 'hands.free: 1', 'hands.free: None'),
|
65 |
+
'location': (location, 'indoors: 1', 'indoors: None'),
|
66 |
+
'screen': (screen, 'screen.interaction_yes: 1', 'screen.interaction_yes: None')
|
67 |
+
}
|
68 |
+
|
69 |
+
for key, (condition, to_replace, replacement) in conditions.items():
|
70 |
+
if not condition:
|
71 |
+
final_response = final_response.replace(to_replace, replacement)
|
72 |
+
|
73 |
+
return final_response
|
74 |
+
|
75 |
+
|
|
|
|
|
76 |
|
77 |
# Function to process all videos in a folder
|
78 |
def process_multiple_videos(video_files: List[str], sitting, hands, location, screen):
|