LogicGoInfotechSpaces commited on
Commit
4d1fa0f
·
verified ·
1 Parent(s): ff6bec8

Update huggingface_segment_highlights.py

Browse files
Files changed (1) hide show
  1. huggingface_segment_highlights.py +9 -6
huggingface_segment_highlights.py CHANGED
@@ -71,10 +71,13 @@ class HuggingFaceVideoHighlightDetector:
71
  try:
72
  subprocess.run(cmd, check=True, capture_output=True)
73
 
74
- # Analyze this frame
75
- prompt = f"Describe what is happening in this video frame at {time_point:.1f}s. Focus on activities, actions, and interesting visual elements."
 
 
 
76
  description = self.vlm_handler.generate_response(temp_frame.name, prompt)
77
- descriptions.append(f"At {time_point:.1f}s: {description}")
78
 
79
  except subprocess.CalledProcessError as e:
80
  logger.error(f"Failed to extract frame at {time_point}s: {e}")
@@ -84,9 +87,9 @@ class HuggingFaceVideoHighlightDetector:
84
  if os.path.exists(temp_frame.name):
85
  os.unlink(temp_frame.name)
86
 
87
- # Combine all descriptions
88
  if descriptions:
89
- return "Video content analysis:\n" + "\n".join(descriptions)
90
  else:
91
  return "Unable to analyze video content"
92
 
@@ -540,4 +543,4 @@ def main():
540
 
541
 
542
  if __name__ == "__main__":
543
- main()
 
71
  try:
72
  subprocess.run(cmd, check=True, capture_output=True)
73
 
74
+ # Analyze this frame with one concise sentence so final description stays short.
75
+ prompt = (
76
+ f"Describe what is happening in this video frame at {time_point:.1f}s in exactly one sentence. "
77
+ "Be concrete and avoid guessing names/places unless clearly visible."
78
+ )
79
  description = self.vlm_handler.generate_response(temp_frame.name, prompt)
80
+ descriptions.append(description.strip())
81
 
82
  except subprocess.CalledProcessError as e:
83
  logger.error(f"Failed to extract frame at {time_point}s: {e}")
 
87
  if os.path.exists(temp_frame.name):
88
  os.unlink(temp_frame.name)
89
 
90
+ # Combine into a single concise 4-5 sentence video description.
91
  if descriptions:
92
+ return " ".join(descriptions[:5])
93
  else:
94
  return "Unable to analyze video content"
95
 
 
543
 
544
 
545
  if __name__ == "__main__":
546
+ main()