feat: eye filter flag + QA fixes (Gemma4 prompt, YOLO boundary, PaliGemma score, GDINO skip)
This commit is contained in:
@@ -19,6 +19,7 @@ import sys
|
||||
import os
|
||||
import json
|
||||
import argparse
|
||||
from collections import defaultdict
|
||||
import numpy as np
|
||||
import psycopg2
|
||||
import psycopg2.extras
|
||||
@@ -160,7 +161,7 @@ def merge_traces_within_cuts(face_data: dict, cut_scenes: list) -> dict:
|
||||
return face_data
|
||||
|
||||
|
||||
def run_face_tracker(face_json_path: str, traced_json_path: str) -> str:
|
||||
def run_face_tracker(face_json_path: str, traced_json_path: str, filter_eyes: bool = False) -> str:
|
||||
"""Run face_tracker.py on face.json, returns path to face_traced.json"""
|
||||
from face_tracker import track_faces
|
||||
|
||||
@@ -199,7 +200,22 @@ def run_face_tracker(face_json_path: str, traced_json_path: str) -> str:
|
||||
"fps": face_data.get("fps", 30.0),
|
||||
"total_frames": face_data.get("frame_count", 0),
|
||||
}
|
||||
|
||||
|
||||
# Eye filter: remove faces without at least one eye landmark
|
||||
if filter_eyes:
|
||||
removed = 0
|
||||
for fnum_str, frm_data in face_data.get("frames", {}).items():
|
||||
faces = frm_data.get("faces", [])
|
||||
kept = []
|
||||
for face in faces:
|
||||
lm = face.get("landmarks", {})
|
||||
if len(lm.get("left_eye", [])) > 0 or len(lm.get("right_eye", [])) > 0:
|
||||
kept.append(face)
|
||||
else:
|
||||
removed += 1
|
||||
frm_data["faces"] = kept
|
||||
print(f"[TRACE] Eye filter: {removed} faces without eyes removed")
|
||||
|
||||
print(f"[TRACE] Processing {len(face_data.get('frames', {}))} frames")
|
||||
|
||||
# Load embeddings from DB for the face tracker
|
||||
@@ -344,6 +360,7 @@ def main():
|
||||
parser.add_argument("--schema", default=SCHEMA, help="DB schema name")
|
||||
|
||||
parser.add_argument("--uuid", help="UUID for Redis tracking (accepted by executor)")
|
||||
parser.add_argument("--filter-eyes", action="store_true", help="Remove faces without eye landmarks before tracking")
|
||||
args = parser.parse_args()
|
||||
|
||||
face_json = args.face_json or os.path.join(
|
||||
@@ -356,7 +373,7 @@ def main():
|
||||
sys.exit(1)
|
||||
|
||||
# Step 1: Run face tracker
|
||||
run_face_tracker(face_json, traced_json)
|
||||
run_face_tracker(face_json, traced_json, filter_eyes=args.filter_eyes)
|
||||
|
||||
# Step 2: Store in DB with trace_id
|
||||
total, traces = store_traced_faces(args.file_uuid, traced_json, args.schema)
|
||||
|
||||
Reference in New Issue
Block a user