Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/core/edge_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# This will be process-specific, so each edge-endpoint worker will have its own cache instance.
ttl_cache = TTLCache(maxsize=128, ttl=2)

CONFIDENCE_SIGNIFICANT_DIGITS = 4


@cached(ttl_cache)
def is_edge_inference_ready(inference_client_url: str) -> bool:
Expand Down Expand Up @@ -173,7 +175,12 @@ def parse_inference_response(response: dict) -> dict:
raise ValueError("Got more than one text prediction. This should not happen.")
text = text_predictions[0]

output_dict = {"confidence": confidence, "label": label, "text": text, "rois": rois}
output_dict = {
"confidence": round(confidence, CONFIDENCE_SIGNIFICANT_DIGITS),
"label": label,
"text": text,
"rois": rois,
}

return output_dict

Expand Down