Update models/visual_analyzer.py
Browse files- models/visual_analyzer.py +10 -2
models/visual_analyzer.py
CHANGED
|
@@ -403,7 +403,7 @@ Respond with just the emotion."""
|
|
| 403 |
|
| 404 |
Args:
|
| 405 |
image: Image to analyze
|
| 406 |
-
prompt: Custom analysis prompt
|
| 407 |
timestamp: Timestamp for this frame
|
| 408 |
|
| 409 |
Returns:
|
|
@@ -419,7 +419,15 @@ Respond with just the emotion."""
|
|
| 419 |
else:
|
| 420 |
pil_image = image
|
| 421 |
|
| 422 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 423 |
|
| 424 |
return {
|
| 425 |
"timestamp": timestamp,
|
|
|
|
| 403 |
|
| 404 |
Args:
|
| 405 |
image: Image to analyze
|
| 406 |
+
prompt: Custom analysis prompt from user
|
| 407 |
timestamp: Timestamp for this frame
|
| 408 |
|
| 409 |
Returns:
|
|
|
|
| 419 |
else:
|
| 420 |
pil_image = image
|
| 421 |
|
| 422 |
+
# Format the prompt to get a clear yes/no style response for clip selection
|
| 423 |
+
formatted_prompt = (
|
| 424 |
+
f"Analyze this frame for the following criteria: {prompt}\n\n"
|
| 425 |
+
f"Does this frame match these criteria? "
|
| 426 |
+
f"Respond with 'Yes' or 'No' followed by a brief explanation. "
|
| 427 |
+
f"If it partially matches, say 'Partially' and explain what matches."
|
| 428 |
+
)
|
| 429 |
+
|
| 430 |
+
response = self._query_model(pil_image, formatted_prompt, max_tokens=200)
|
| 431 |
|
| 432 |
return {
|
| 433 |
"timestamp": timestamp,
|