feat: round output JSON floats to 2dp + unify ensure_ascii for asr/asrx
This commit is contained in:
@@ -52,6 +52,20 @@ def classify_pose(roll: float, yaw: float) -> str:
|
||||
return "three_quarter"
|
||||
|
||||
|
||||
def round_json_numbers(obj):
|
||||
"""Recursively round all float values to 2 decimal places (JSON output only).
|
||||
|
||||
Intentionally leaves Qdrant push payloads untouched (they use raw values).
|
||||
"""
|
||||
if isinstance(obj, float):
|
||||
return round(obj, 2)
|
||||
if isinstance(obj, dict):
|
||||
return {k: round_json_numbers(v) for k, v in obj.items()}
|
||||
if isinstance(obj, list):
|
||||
return [round_json_numbers(v) for v in obj]
|
||||
return obj
|
||||
|
||||
|
||||
class FaceProcessorVision:
|
||||
def __init__(self, video_path: str, output_path: str, uuid: str = "",
|
||||
sample_interval: int = 3, publisher: RedisPublisher = None):
|
||||
@@ -329,13 +343,13 @@ class FaceProcessorVision:
|
||||
output = {
|
||||
"status": status,
|
||||
"frame_count": len(frames_list),
|
||||
"fps": self.fps,
|
||||
"fps": round(self.fps, 2),
|
||||
"frames": frames_list,
|
||||
"total_faces": total_faces,
|
||||
}
|
||||
|
||||
with open(self.output_path, "w") as f:
|
||||
json.dump(output, f, indent=2, ensure_ascii=False)
|
||||
json.dump(round_json_numbers(output), f, indent=2, ensure_ascii=False)
|
||||
|
||||
# Push embeddings to Qdrant _faces collection
|
||||
if all_embeddings:
|
||||
|
||||
Reference in New Issue
Block a user