feat: round output JSON floats to 2dp + unify ensure_ascii for asr/asrx
This commit is contained in:
@@ -28,6 +28,27 @@ Output:
|
||||
import json
|
||||
import argparse
|
||||
import numpy as np
|
||||
|
||||
|
||||
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
|
||||
from typing import Dict, List, Set
|
||||
from collections import defaultdict
|
||||
|
||||
@@ -544,7 +565,7 @@ def main():
|
||||
if not args.analyze_only:
|
||||
output_path = args.output or args.face_json.replace(".json", "_traced.json")
|
||||
with open(output_path, "w") as f:
|
||||
json.dump(face_data, f, indent=2)
|
||||
json.dump(strip_embeddings_and_round(face_data), f, indent=2)
|
||||
print(f"\n✅ Output saved to: {output_path}")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user