Skip to content

Commit

Permalink
cleaner codes
Browse files Browse the repository at this point in the history
  • Loading branch information
serengil committed Jan 29, 2023
1 parent 2d39ade commit e679c72
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
# -----------------------------------
Expand Down
8 changes: 3 additions & 5 deletions deepface/commons/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

# ---------------------------
Expand Down Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions deepface/commons/realtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file removed icon/deepface-detectors-v2.jpg
Binary file not shown.
Binary file removed icon/stock-4.jpg
Binary file not shown.
3 changes: 2 additions & 1 deletion tests/unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e679c72

Please sign in to comment.