show more details in case of exception while api calls

This commit is contained in:
Sefik Ilkin Serengil 2024-06-11 20:18:22 +01:00
parent a909d9c81a
commit 09fdf25bb8
2 changed files with 12 additions and 3 deletions

View File

@ -30,6 +30,8 @@ COPY ./README.md /app/
# if you plan to use a GPU, you should install the 'tensorflow-gpu' package
# RUN pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host=files.pythonhosted.org tensorflow-gpu
# if you plan to use face anti-spoofing, then activate this line
# RUN pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host=files.pythonhosted.org torch==2.1.2
# -----------------------------------
# install deepface from pypi release (might be out-of-date)
# RUN pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host=files.pythonhosted.org deepface

View File

@ -1,3 +1,7 @@
# built-in dependencies
import traceback
# project dependencies
from deepface import DeepFace
# pylint: disable=broad-except
@ -24,7 +28,8 @@ def represent(
result["results"] = embedding_objs
return result
except Exception as err:
return {"error": f"Exception while representing: {str(err)}"}, 400
tb_str = traceback.format_exc()
return {"error": f"Exception while representing: {str(err)} - {tb_str}"}, 400
def verify(
@ -50,7 +55,8 @@ def verify(
)
return obj
except Exception as err:
return {"error": f"Exception while verifying: {str(err)}"}, 400
tb_str = traceback.format_exc()
return {"error": f"Exception while verifying: {str(err)} - {tb_str}"}, 400
def analyze(
@ -75,4 +81,5 @@ def analyze(
result["results"] = demographies
return result
except Exception as err:
return {"error": f"Exception while analyzing: {str(err)}"}, 400
tb_str = traceback.format_exc()
return {"error": f"Exception while analyzing: {str(err)} - {tb_str}"}, 400