Skip to content

Commit

Permalink
Added try-catch
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Gabarro committed Jun 24, 2024
1 parent a8406dc commit ed5d740
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions scripts/represent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
import sys;
from deepface import DeepFace;

result = DeepFace.represent(
img_path = "{{img_path}}",
model_name = "{{model_name}}",
enforce_detection = {{enforce_detection}},
anti_spoofing = "{{anti_spoofing}}",
detector_backend = "{{detector_backend}}",
align = {{align}},
normalization = "{{normalization}}"
);
try:
result = DeepFace.represent(
img_path = "{{img_path}}",
model_name = "{{model_name}}",
enforce_detection = {{enforce_detection}},
anti_spoofing = "{{anti_spoofing}}",
detector_backend = "{{detector_backend}}",
align = {{align}},
normalization = "{{normalization}}"
);

print(json.dumps(result, default=str))
except ValueError as e:
print(json.dumps({"error": str(e)}), file=sys.stderr)

print(json.dumps(result, default=str))

0 comments on commit ed5d740

Please sign in to comment.