feat: round output JSON floats to 2dp + unify ensure_ascii for asr/asrx
This commit is contained in:
@@ -32,6 +32,27 @@ OUTPUT_DIR = os.environ.get("MOMENTRY_OUTPUT_DIR", "/Users/accusys/momentry/outp
|
||||
SCHEMA = os.environ.get("DATABASE_SCHEMA", "public")
|
||||
|
||||
|
||||
def strip_embeddings_and_round(obj):
|
||||
"""Remove face embeddings from face_traced.json and round floats to 2 dp.
|
||||
|
||||
Embeddings live in Qdrant _faces (512D); storing them in the JSON bloats the
|
||||
file (~2MB+ per 1000 faces). face_tracker consumes embeddings in-memory (loaded
|
||||
from Qdrant before tracking), so stripping at write time is safe: all downstream
|
||||
consumers (TKG, clustering, cluster_agent) read Qdrant or trace IDs instead.
|
||||
"""
|
||||
if isinstance(obj, dict):
|
||||
return {
|
||||
k: strip_embeddings_and_round(v)
|
||||
for k, v in obj.items()
|
||||
if not (k == "embedding")
|
||||
}
|
||||
if isinstance(obj, list):
|
||||
return [strip_embeddings_and_round(v) for v in obj]
|
||||
if isinstance(obj, float):
|
||||
return round(obj, 2)
|
||||
return obj
|
||||
|
||||
|
||||
def merge_traces_within_cuts(face_data: dict, cut_scenes: list) -> dict:
|
||||
"""Merge traces within the same cut - DISABLED (no embeddings)."""
|
||||
# TODO: Reimplement with Qdrant _faces collection
|
||||
@@ -160,7 +181,7 @@ def run_face_tracker(
|
||||
face_data["metadata"] = metadata
|
||||
|
||||
with open(traced_json_path, "w") as f:
|
||||
json.dump(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}")
|
||||
|
||||
Reference in New Issue
Block a user