Spaces:
Sleeping
Sleeping
Commit ·
ea0b5ea
1
Parent(s): 475892a
Fix SmolVLM2 scoring: Force numerical scores in responses
Browse files- Updated prompt to require 'Score: X/10' format at start of response
- Added regex pattern to extract the new score format
- Fixes issue where all segments got default 6.0 score
- Now produces varied scores (2.0-9.0) based on actual content analysis
- Tested with ooty_resort.mp4: excellent results with proper scoring
audio_enhanced_highlights_final.py
CHANGED
|
@@ -141,8 +141,10 @@ class AudioVisualAnalyzer:
|
|
| 141 |
try:
|
| 142 |
def generate_with_timeout():
|
| 143 |
prompt = ("Analyze this video frame for interesting, engaging, or highlight-worthy content. "
|
| 144 |
-
"
|
| 145 |
-
"Focus on action, emotion, important moments, or visually striking elements."
|
|
|
|
|
|
|
| 146 |
return self.vlm_handler.generate_response(frame_path, prompt)
|
| 147 |
|
| 148 |
# Run with timeout protection
|
|
@@ -205,8 +207,9 @@ class AudioVisualAnalyzer:
|
|
| 205 |
"""Extract numeric score from analysis text"""
|
| 206 |
import re
|
| 207 |
|
| 208 |
-
# Look for patterns like "8/10", "
|
| 209 |
patterns = [
|
|
|
|
| 210 |
r'(\d+(?:\.\d+)?)\s*/\s*10', # "8/10" or "7.5/10"
|
| 211 |
r'(?:score|rating|rate)(?:\s*[:=]\s*)(\d+(?:\.\d+)?)', # "score: 8" or "rating=7.5"
|
| 212 |
r'(\d+(?:\.\d+)?)\s*(?:out of|/)\s*10', # "8 out of 10"
|
|
|
|
| 141 |
try:
|
| 142 |
def generate_with_timeout():
|
| 143 |
prompt = ("Analyze this video frame for interesting, engaging, or highlight-worthy content. "
|
| 144 |
+
"IMPORTANT: Start your response with 'Score: X/10' where X is a number from 1-10. "
|
| 145 |
+
"Then explain what makes it noteworthy. Focus on action, emotion, important moments, or visually striking elements. "
|
| 146 |
+
"Rate based on: Action/movement (high scores), People talking/interacting (medium-high), "
|
| 147 |
+
"Static scenes (low-medium), Boring/empty scenes (low scores).")
|
| 148 |
return self.vlm_handler.generate_response(frame_path, prompt)
|
| 149 |
|
| 150 |
# Run with timeout protection
|
|
|
|
| 207 |
"""Extract numeric score from analysis text"""
|
| 208 |
import re
|
| 209 |
|
| 210 |
+
# Look for patterns like "Score: 8/10", "8/10", "score: 7", etc.
|
| 211 |
patterns = [
|
| 212 |
+
r'score:\s*(\d+(?:\.\d+)?)\s*/\s*10', # "Score: 8/10" (our new format)
|
| 213 |
r'(\d+(?:\.\d+)?)\s*/\s*10', # "8/10" or "7.5/10"
|
| 214 |
r'(?:score|rating|rate)(?:\s*[:=]\s*)(\d+(?:\.\d+)?)', # "score: 8" or "rating=7.5"
|
| 215 |
r'(\d+(?:\.\d+)?)\s*(?:out of|/)\s*10', # "8 out of 10"
|