cleaner codes

This commit is contained in:
Sefik Ilkin Serengil 2023-01-29 23:44:09 +00:00
parent 2d39ade138
commit e679c7206a
7 changed files with 15 additions and 11 deletions

View File

@ -434,7 +434,8 @@ disable=raw-checker-failed,
cyclic-import,
global-statement,
no-member,
no-name-in-module
no-name-in-module,
unrecognized-option
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option

View File

@ -20,6 +20,9 @@ WORKDIR /app
RUN apt-get update
RUN apt-get install ffmpeg libsm6 libxext6 -y
# -----------------------------------
# if you will use gpu, then you should install tensorflow-gpu package
# RUN pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host=files.pythonhosted.org tensorflow-gpu
# -----------------------------------
# install deepface from pypi release (might be out-of-the-date)
# RUN pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host=files.pythonhosted.org deepface
# -----------------------------------

View File

@ -62,10 +62,10 @@ def load_image(img):
if type(img).__module__ == np.__name__:
exact_image = True
elif len(img) > 11 and img[0:11] == "data:image/":
elif img.startswith("data:image/"):
base64_img = True
elif len(img) > 11 and img.startswith("http"):
elif img.startswith("http"):
url_img = True
# ---------------------------
@ -177,9 +177,7 @@ def extract_faces(
if len(extracted_faces) == 0 and enforce_detection == True:
raise ValueError(
"Detected face shape is ",
img.shape,
". Consider to set enforce_detection argument to False.",
f"Detected face shape is {img.shape}. Consider to set enforce_detection arg to False."
)
return extracted_faces

View File

@ -87,12 +87,13 @@ def analysis(
)
faces = []
for face_obj in face_objs:
facial_area = face_obj["facial_area"]
faces.append(
(
face_obj["facial_area"]["x"],
face_obj["facial_area"]["y"],
face_obj["facial_area"]["w"],
face_obj["facial_area"]["h"],
facial_area["x"],
facial_area["y"],
facial_area["w"],
facial_area["h"],
)
)
except: # to avoid exception if no face detected

Binary file not shown.

Before

Width:  |  Height:  |  Size: 515 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 KiB

View File

@ -93,7 +93,8 @@ def test_cases():
assert "h" in objs[0]["facial_area"].keys()
assert isinstance(objs[0]["embedding"], list)
assert len(objs[0]["embedding"]) == 2622 # embedding of VGG-Face
except:
except Exception as err:
print(str(err))
exception_thrown = True
assert exception_thrown is False