fix: correct face detection threshold defaults
- Changed min_confidence from 50.0 to 0.5 (Vision uses 0.0-1.0 range) - Changed min_size from 32 to 1 (was filtering out all small faces) - Changed min_capture_quality from 25.0 to 0.25 - Fixes issue where all videos showed 0 faces detected Root cause: admin_config.rs used wrong defaults (50.0/32) instead of config.rs constants (0.5/1), causing Vision framework to filter out ALL faces because confidence threshold exceeded valid range. Verified: IMG_9449 now correctly detects 191 faces (was 0).
This commit is contained in:
@@ -26,6 +26,14 @@ import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Import admin config loader
|
||||
try:
|
||||
from admin_config_loader import get_prompt_text, get_max_tokens
|
||||
except ImportError:
|
||||
print("Warning: admin_config_loader not found, using default prompts", file=sys.stderr)
|
||||
def get_prompt_text(key): return None
|
||||
def get_max_tokens(key): return 100
|
||||
|
||||
# VLM configuration from environment variables
|
||||
VLM_URL = os.environ.get("MOMENTRY_LLM_VISION_URL", "http://localhost:8091/v1/chat/completions")
|
||||
VLM_MODEL = os.environ.get("MOMENTRY_LLM_VISION_MODEL", "llava-v1.6-vicuna-13b")
|
||||
@@ -182,12 +190,17 @@ def analyze_trace(trace_dir: str, model: str = "llava:7b", store_qdrant: bool =
|
||||
|
||||
print(f"[vlm] Analyzing {trace_path.name}...")
|
||||
|
||||
# Prompt 1: Person description
|
||||
desc_prompt = "Describe this person briefly. For EVERY item, include COLOR: hair color, skin tone, clothing colors. If uncertain, say 'unknown color'. Be concise and honest."
|
||||
# Helper function to get prompt with fallback
|
||||
def get_prompt(key, default):
|
||||
prompt = get_prompt_text(key)
|
||||
return prompt if prompt else default
|
||||
|
||||
# Prompt 1: Person description
|
||||
desc_prompt = get_prompt("trace_desc", "Describe this person briefly. For EVERY item, include COLOR: hair color, skin tone, clothing colors. If uncertain, say 'unknown color'. Be concise and honest.")
|
||||
description = call_vlm(image_to_analyze, desc_prompt, model)
|
||||
|
||||
# Prompt 2: Clothing details
|
||||
clothing_prompt = "Describe this person's clothing in detail. For EACH item, you MUST specify the COLOR: shirt color, pants color, jacket color, hat color, glasses frame color, shoe color. Format: 'color + item' (e.g., 'black hoodie', 'blue jeans'). If color is unclear, say 'unclear color'. Do not skip colors. Include any visible text or logos."
|
||||
clothing_prompt = get_prompt("trace_clothing", "Describe this person's clothing in detail. For EACH item, you MUST specify the COLOR: shirt color, pants color, jacket color, hat color, glasses frame color, shoe color. Format: 'color + item' (e.g., 'black hoodie', 'blue jeans'). If color is unclear, say 'unclear color'. Do not skip colors. Include any visible text or logos.")
|
||||
clothing = call_vlm(image_to_analyze, clothing_prompt, model)
|
||||
|
||||
# Prompt 3: Tags - auto-extract from description
|
||||
@@ -207,15 +220,15 @@ def analyze_trace(trace_dir: str, model: str = "llava:7b", store_qdrant: bool =
|
||||
tags = tags[:5] if tags else ["unknown"]
|
||||
|
||||
# Prompt 5: Objects in hand
|
||||
hand_prompt = "Look at the person's hands. What objects are they holding or touching? For EACH object, state its COLOR and type (e.g., 'red cup', 'black phone'). If hands not visible, say 'hands not visible'. If empty, say 'empty hands'."
|
||||
hand_prompt = get_prompt("trace_hand_objects", "Look at the person's hands. What objects are they holding or touching? For EACH object, state its COLOR and type (e.g., 'red cup', 'black phone'). If hands not visible, say 'hands not visible'. If empty, say 'empty hands'.")
|
||||
hand_objects = call_vlm(image_to_analyze, hand_prompt, model)
|
||||
|
||||
# Prompt 6: Lighting (day/night)
|
||||
light_prompt = "What is the lighting condition? Answer one word: day, night, indoor-light, mixed, or unknown. If uncertain, answer 'unknown'."
|
||||
light_prompt = get_prompt("trace_lighting", "What is the lighting condition? Answer one word: day, night, indoor-light, mixed, or unknown. If uncertain, answer 'unknown'.")
|
||||
lighting = call_vlm(image_to_analyze, light_prompt, model).lower().strip()
|
||||
|
||||
# Prompt 7: Scene classification
|
||||
scene_prompt = "Classify the scene. Answer in JSON: {\"location\": \"indoor/outdoor/unknown\", \"weather\": \"sunny/cloudy/rainy/night/unknown\", \"setting\": \"office/street/home/nature/studio/unknown\", \"transportation\": \"car/train/bus/none/unknown\"}. Use 'unknown' if uncertain."
|
||||
scene_prompt = get_prompt("trace_scene", "Classify the scene. Answer in JSON: {\"location\": \"indoor/outdoor/unknown\", \"weather\": \"sunny/cloudy/rainy/night/unknown\", \"setting\": \"office/street/home/nature/studio/unknown\", \"transportation\": \"car/train/bus/none/unknown\"}. Use 'unknown' if uncertain.")
|
||||
scene_raw = call_vlm(image_to_analyze, scene_prompt, model)
|
||||
|
||||
# Parse scene JSON (handle markdown code blocks)
|
||||
@@ -228,11 +241,11 @@ def analyze_trace(trace_dir: str, model: str = "llava:7b", store_qdrant: bool =
|
||||
scene_data = {}
|
||||
|
||||
# Prompt 8: Background description
|
||||
bg_prompt = "Describe the background and environment. For EACH visible object, state its COLOR and type. Include: wall color, monitor colors, furniture colors, equipment colors. If color unclear, say 'unclear'."
|
||||
bg_prompt = get_prompt("trace_background", "Describe the background and environment. For EACH visible object, state its COLOR and type. Include: wall color, monitor colors, furniture colors, equipment colors. If color unclear, say 'unclear'.")
|
||||
background = call_vlm(image_to_analyze, bg_prompt, model)
|
||||
|
||||
# Prompt 9: Plants detection
|
||||
plants_prompt = "What plants, trees, or flowers are clearly visible? Answer in JSON: {\"has_plants\": true/false, \"plants\": [\"list recognizable plants by name. If not recognizable, describe briefly what you see. Use empty list if none or uncertain.\"]}"
|
||||
plants_prompt = get_prompt("trace_plants", "What plants, trees, or flowers are clearly visible? Answer in JSON: {\"has_plants\": true/false, \"plants\": [\"list recognizable plants by name. If not recognizable, describe briefly what you see. Use empty list if none or uncertain.\"]}")
|
||||
plants_raw = call_vlm(image_to_analyze, plants_prompt, model)
|
||||
|
||||
# Parse plants JSON
|
||||
@@ -244,7 +257,7 @@ def analyze_trace(trace_dir: str, model: str = "llava:7b", store_qdrant: bool =
|
||||
plants_data = {"has_plants": False, "plants": []}
|
||||
|
||||
# Prompt 10: Animals detection
|
||||
animals_prompt = "What animals are clearly visible? Answer in JSON: {\"has_animals\": true/false, \"animals\": [\"list recognizable animals by name. If not recognizable, describe briefly what you see. Use empty list if none or uncertain.\"]}"
|
||||
animals_prompt = get_prompt("trace_animals", "What animals are clearly visible? Answer in JSON: {\"has_animals\": true/false, \"animals\": [\"list recognizable animals by name. If not recognizable, describe briefly what you see. Use empty list if none or uncertain.\"]}")
|
||||
animals_raw = call_vlm(image_to_analyze, animals_prompt, model)
|
||||
|
||||
# Parse animals JSON
|
||||
@@ -256,7 +269,7 @@ def analyze_trace(trace_dir: str, model: str = "llava:7b", store_qdrant: bool =
|
||||
animals_data = {"has_animals": False, "animals": []}
|
||||
|
||||
# Prompt 11: Background tags
|
||||
bg_tags_prompt = "List 5 tags for the background/scene, comma-separated. Examples: office, street, sunny, building, car, trees."
|
||||
bg_tags_prompt = get_prompt("trace_bg_tags", "List 5 tags for the background/scene, comma-separated. Examples: office, street, sunny, building, car, trees.")
|
||||
bg_tags_raw = call_vlm(image_to_analyze, bg_tags_prompt, model)
|
||||
bg_tags = [t.strip() for t in bg_tags_raw.replace(",", " ").split() if t.strip()][:5]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user