Make the API /verify work with image URL

This commit is contained in:
Markus Hinsche 2024-11-11 13:59:35 +01:00
parent cc484b54be
commit 7d2da1eb59
5 changed files with 37 additions and 8 deletions

View File

@ -1,6 +1,6 @@
# base image
FROM python:3.8.12
LABEL org.opencontainers.image.source https://github.com/serengil/deepface
LABEL org.opencontainers.image.source=https://github.com/serengil/deepface
# -----------------------------------
# create required folder
@ -24,15 +24,11 @@ RUN apt-get update && apt-get install -y \
&& rm -rf /var/lib/apt/lists/*
# -----------------------------------
# Copy required files from repo into image
COPY ./deepface /app/deepface
# even though we will use local requirements, this one is required to perform install deepface from source code
COPY ./requirements.txt /app/requirements.txt
COPY ./requirements_local /app/requirements_local.txt
COPY ./package_info.json /app/
COPY ./setup.py /app/
COPY ./README.md /app/
COPY ./entrypoint.sh /app/deepface/api/src/entrypoint.sh
# -----------------------------------
# if you plan to use a GPU, you should install the 'tensorflow-gpu' package
@ -46,6 +42,14 @@ COPY ./entrypoint.sh /app/deepface/api/src/entrypoint.sh
# -----------------------------------
# install dependencies - deepface with these dependency versions is working
RUN pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host=files.pythonhosted.org -r /app/requirements_local.txt
# Copy required files from repo into image
COPY ./deepface /app/deepface
COPY ./setup.py /app/
COPY ./README.md /app/
COPY ./entrypoint.sh /app/deepface/api/src/entrypoint.sh
# install deepface from source code (always up-to-date)
RUN pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host=files.pythonhosted.org -e .

View File

@ -623,5 +623,7 @@ def detectFace(
extracted_face = None
if len(face_objs) > 0:
extracted_face = face_objs[0]["face"]
extracted_face = preprocessing.resize_image(img=extracted_face, target_size=target_size)
extracted_face = preprocessing.resize_image(
img=extracted_face, target_size=target_size
)
return extracted_face

View File

@ -16,3 +16,6 @@ def create_app():
app.register_blueprint(blueprint)
logger.info(f"Welcome to DeepFace API v{DeepFace.__version__}!")
return app
app = create_app()

View File

@ -2,4 +2,4 @@
echo "Starting the application..."
exec "$@"
gunicorn -w 1 -b 0.0.0.0:5000 --timeout 7200 --log-level 'debug' --access-logfile - --access-logformat '%(h)s - - [%(t)s] "%(r)s" %(s)s %(b)s %(L)s' app:create_app
gunicorn -w 1 -b 0.0.0.0:5000 --timeout 7200 --log-level 'debug' --access-logfile - --access-logformat '%(h)s - - [%(t)s] "%(r)s" %(s)s %(b)s %(L)s' app:app

20
scripts/mh_use_api.py Normal file

File diff suppressed because one or more lines are too long