perf: cut face_traced Qdrant I/O — merge trace-count scan (B1) + batch 1000 (B2)
This commit is contained in:
@@ -128,6 +128,7 @@ def run_face_tracker(
|
||||
print(f"[TRACE] Loading embeddings from Qdrant for {file_uuid}...")
|
||||
try:
|
||||
from qdrant_faces import get_file_faces
|
||||
|
||||
qdrant_points = get_file_faces(file_uuid, with_vector=True)
|
||||
# Build lookup: (frame, x, y) -> embedding
|
||||
emb_lookup = {}
|
||||
@@ -181,7 +182,9 @@ def run_face_tracker(
|
||||
face_data["metadata"] = metadata
|
||||
|
||||
with open(traced_json_path, "w") as f:
|
||||
json.dump(strip_embeddings_and_round(face_data), f, indent=2, ensure_ascii=False)
|
||||
json.dump(
|
||||
strip_embeddings_and_round(face_data), f, indent=2, ensure_ascii=False
|
||||
)
|
||||
|
||||
trace_count = len(face_data.get("traces", {}))
|
||||
print(f"[TRACE] Completed: {trace_count} traces -> {traced_json_path}")
|
||||
@@ -210,27 +213,20 @@ def store_traced_faces(file_uuid: str, traced_json_path: str, schema: str = SCHE
|
||||
bbox_key = f"{face['x']}_{face['y']}_{face['width']}_{face['height']}"
|
||||
trace_mapping[frame_num][bbox_key] = trace_id
|
||||
|
||||
# Update Qdrant _faces collection with trace_id
|
||||
# Update Qdrant _faces collection with trace_id.
|
||||
# return_trace_ids=True makes update_trace_ids also return the trace_id set seen
|
||||
# during its scroll, so we avoid a redundant third full-collection scan below.
|
||||
trace_ids = set()
|
||||
try:
|
||||
qdrant_updated = update_trace_ids(file_uuid, trace_mapping)
|
||||
qdrant_updated, trace_ids = update_trace_ids(
|
||||
file_uuid, trace_mapping, return_trace_ids=True
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"[TRACE] Warning: Qdrant trace_id update failed: {e}")
|
||||
qdrant_updated = 0
|
||||
|
||||
# Count unique traces from Qdrant
|
||||
try:
|
||||
from qdrant_faces import get_file_faces
|
||||
|
||||
points = get_file_faces(file_uuid)
|
||||
trace_ids = set()
|
||||
for p in points:
|
||||
tid = p.get("payload", {}).get("trace_id")
|
||||
if tid is not None and tid > 0:
|
||||
trace_ids.add(tid)
|
||||
qdrant_trace_count = len(trace_ids)
|
||||
except Exception as e:
|
||||
print(f"[TRACE] Warning: Qdrant trace count failed: {e}")
|
||||
qdrant_trace_count = 0
|
||||
# Unique trace count from the update scroll (no extra full scan needed).
|
||||
qdrant_trace_count = len(trace_ids)
|
||||
|
||||
total_faces = sum(
|
||||
1
|
||||
|
||||
Reference in New Issue
Block a user