deprecated functions added

This commit is contained in:
Sefik Ilkin Serengil 2023-02-23 10:04:22 +00:00
parent 0f913adde9
commit d04ab28bd3
4 changed files with 66 additions and 1 deletions

9
api/api.py Normal file
View File

@ -0,0 +1,9 @@
import argparse
import app
if __name__ == "__main__":
deepface_app = app.create_app()
parser = argparse.ArgumentParser()
parser.add_argument("-p", "--port", type=int, default=5000, help="Port of serving api")
args = parser.parse_args()
deepface_app.run(host="0.0.0.0", port=args.port)

View File

@ -808,6 +808,30 @@ def extract_faces(
return resp_objs
# ---------------------------
# deprecated functions
def detectFace(
img_path, target_size=(224, 224), detector_backend="opencv", enforce_detection=True, align=True
):
print("⚠️ Function detectFace is deprecated! Use extract_faces instead of this.")
face_objs = extract_faces(
img_path=img_path,
target_size=target_size,
detector_backend=detector_backend,
enforce_detection=enforce_detection,
align=align,
grayscale=False,
)
extracted_face = None
if len(face_objs) > 0:
extracted_face = face_objs[0]["face"]
return extracted_face
# ---------------------------
# main

View File

@ -251,3 +251,35 @@ def find_target_size(model_name):
raise ValueError(f"unimplemented model name - {model_name}")
return target_size
# ---------------------------------------------------
# deprecated functions
def preprocess_face(
img,
target_size=(224, 224),
detector_backend="opencv",
grayscale=False,
enforce_detection=True,
align=True,
):
print("⚠️ Function preprocess_face function is deprecated! Use extract_faces instead of this.")
result = None
img_objs = extract_faces(
img=img,
target_size=target_size,
detector_backend=detector_backend,
grayscale=grayscale,
enforce_detection=enforce_detection,
align=align,
)
if len(img_objs) > 0:
result, _, _ = img_objs[0]
# discard expanded dimension
if len(result.shape) == 4:
result = result[0]
return result

View File

@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
setuptools.setup(
name="deepface",
version="0.0.78",
version="0.0.79",
author="Sefik Ilkin Serengil",
author_email="serengil@gmail.com",
description="A Lightweight Face Recognition and Facial Attribute Analysis Framework (Age, Gender, Emotion, Race) for Python",