mirror of
https://github.com/serengil/deepface.git
synced 2025-06-07 12:05:22 +00:00
img args are either numpy or string, and exception logs dumped
This commit is contained in:
parent
6db41ae3f2
commit
8b2475acb2
@ -1,15 +1,22 @@
|
|||||||
# built-in dependencies
|
# built-in dependencies
|
||||||
import traceback
|
import traceback
|
||||||
from typing import Optional
|
from typing import Optional, Union
|
||||||
|
|
||||||
|
# 3rd party dependencies
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
# project dependencies
|
# project dependencies
|
||||||
from deepface import DeepFace
|
from deepface import DeepFace
|
||||||
|
from deepface.commons.logger import Logger
|
||||||
|
|
||||||
|
logger = Logger()
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=broad-except
|
# pylint: disable=broad-except
|
||||||
|
|
||||||
|
|
||||||
def represent(
|
def represent(
|
||||||
img_path: str,
|
img_path: Union[str, np.ndarray],
|
||||||
model_name: str,
|
model_name: str,
|
||||||
detector_backend: str,
|
detector_backend: str,
|
||||||
enforce_detection: bool,
|
enforce_detection: bool,
|
||||||
@ -32,12 +39,14 @@ def represent(
|
|||||||
return result
|
return result
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
tb_str = traceback.format_exc()
|
tb_str = traceback.format_exc()
|
||||||
|
logger.error(str(err))
|
||||||
|
logger.error(tb_str)
|
||||||
return {"error": f"Exception while representing: {str(err)} - {tb_str}"}, 400
|
return {"error": f"Exception while representing: {str(err)} - {tb_str}"}, 400
|
||||||
|
|
||||||
|
|
||||||
def verify(
|
def verify(
|
||||||
img1_path: str,
|
img1_path: Union[str, np.ndarray],
|
||||||
img2_path: str,
|
img2_path: Union[str, np.ndarray],
|
||||||
model_name: str,
|
model_name: str,
|
||||||
detector_backend: str,
|
detector_backend: str,
|
||||||
distance_metric: str,
|
distance_metric: str,
|
||||||
@ -59,11 +68,13 @@ def verify(
|
|||||||
return obj
|
return obj
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
tb_str = traceback.format_exc()
|
tb_str = traceback.format_exc()
|
||||||
|
logger.error(str(err))
|
||||||
|
logger.error(tb_str)
|
||||||
return {"error": f"Exception while verifying: {str(err)} - {tb_str}"}, 400
|
return {"error": f"Exception while verifying: {str(err)} - {tb_str}"}, 400
|
||||||
|
|
||||||
|
|
||||||
def analyze(
|
def analyze(
|
||||||
img_path: str,
|
img_path: Union[str, np.ndarray],
|
||||||
actions: list,
|
actions: list,
|
||||||
detector_backend: str,
|
detector_backend: str,
|
||||||
enforce_detection: bool,
|
enforce_detection: bool,
|
||||||
@ -85,4 +96,6 @@ def analyze(
|
|||||||
return result
|
return result
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
tb_str = traceback.format_exc()
|
tb_str = traceback.format_exc()
|
||||||
|
logger.error(str(err))
|
||||||
|
logger.error(tb_str)
|
||||||
return {"error": f"Exception while analyzing: {str(err)} - {tb_str}"}, 400
|
return {"error": f"Exception while analyzing: {str(err)} - {tb_str}"}, 400
|
||||||
|
Loading…
x
Reference in New Issue
Block a user