Spaces:
Sleeping
Sleeping
Update video_processing.py
Browse files- video_processing.py +7 -3
video_processing.py
CHANGED
@@ -137,9 +137,13 @@ def analyze_scenes(video_path, scenes, description):
|
|
137 |
|
138 |
scene_scores.append((scene_prob, start_time, end_time, scene_duration, sentiment_percentages))
|
139 |
|
140 |
-
|
141 |
-
|
142 |
-
|
|
|
|
|
|
|
|
|
143 |
|
144 |
if best_scene:
|
145 |
print(f"Best Scene: Start={best_scene[1]}, End={best_scene[2]}, Probability={best_scene[0]}, Duration={best_scene[3]}, Sentiments: {best_scene[4]}")
|
|
|
137 |
|
138 |
scene_scores.append((scene_prob, start_time, end_time, scene_duration, sentiment_percentages))
|
139 |
|
140 |
+
# Sort scenes by confidence, highest first
|
141 |
+
scene_scores.sort(reverse=True, key=lambda x: x[0])
|
142 |
+
|
143 |
+
# Select the longest scene from the top 3 highest confidence scenes
|
144 |
+
top_3_scenes = scene_scores[:3] # Get the top 3 scenes
|
145 |
+
best_scene = max(top_3_scenes, key=lambda x: x[3]) # Find the longest scene from these top 3
|
146 |
+
|
147 |
|
148 |
if best_scene:
|
149 |
print(f"Best Scene: Start={best_scene[1]}, End={best_scene[2]}, Probability={best_scene[0]}, Duration={best_scene[3]}, Sentiments: {best_scene[4]}")
|