From a8cb394b768cf4f2a53f5978ec2e5429c5ed1c58 Mon Sep 17 00:00:00 2001 From: Sefik Ilkin Serengil Date: Sun, 2 Jun 2024 18:53:38 +0100 Subject: [PATCH 1/3] deepface version printed --- deepface/api/src/app.py | 6 ++++++ deepface/api/src/modules/core/routes.py | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/deepface/api/src/app.py b/deepface/api/src/app.py index fa0cb878e..9e495afd2 100644 --- a/deepface/api/src/app.py +++ b/deepface/api/src/app.py @@ -1,8 +1,14 @@ # 3rd parth dependencies from flask import Flask +from deepface import DeepFace from deepface.api.src.modules.core.routes import blueprint +from deepface.commons import logger as log + +logger = log.get_singletonish_logger() + def create_app(): app = Flask(__name__) app.register_blueprint(blueprint) + logger.info(f"Welcome to DeepFace API v{DeepFace.__version__}!") return app diff --git a/deepface/api/src/modules/core/routes.py b/deepface/api/src/modules/core/routes.py index a0bce251b..c7254fc5a 100644 --- a/deepface/api/src/modules/core/routes.py +++ b/deepface/api/src/modules/core/routes.py @@ -1,4 +1,5 @@ from flask import Blueprint, request +from deepface import DeepFace from deepface.api.src.modules.core import service from deepface.commons import logger as log @@ -9,7 +10,7 @@ @blueprint.route("/") def home(): - return "

Welcome to DeepFace API!

" + return f"

Welcome to DeepFace API v{DeepFace.__version__}!

" @blueprint.route("/represent", methods=["POST"]) From 47bdb509cddd744df4f0ed96f954b218f33edd05 Mon Sep 17 00:00:00 2001 From: Sefik Ilkin Serengil Date: Sun, 2 Jun 2024 18:54:12 +0100 Subject: [PATCH 2/3] expose internal service at port 5005 --- scripts/dockerize.sh | 3 ++- scripts/service.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/dockerize.sh b/scripts/dockerize.sh index 0d5ac6e00..2bd22d404 100644 --- a/scripts/dockerize.sh +++ b/scripts/dockerize.sh @@ -17,7 +17,8 @@ docker build -t deepface . # docker cp ~/.deepface/weights/. :/root/.deepface/weights/ # run image -docker run --net="host" deepface +# docker run --net="host" deepface +docker run -p 5005:5000 deepface # to access the inside of docker image when it is in running status # docker exec -it /bin/sh diff --git a/scripts/service.sh b/scripts/service.sh index a8ac03243..3fa54a733 100755 --- a/scripts/service.sh +++ b/scripts/service.sh @@ -5,4 +5,4 @@ cd ../deepface/api/src # python api.py # run the service with gunicorn - for prod purposes -gunicorn --workers=1 --timeout=3600 --bind=0.0.0.0:5000 "app:create_app()" \ No newline at end of file +gunicorn --workers=1 --timeout=3600 --bind=0.0.0.0:5005 "app:create_app()" \ No newline at end of file From 9d323002e1cd2959d174d4fd3bd0d1c144595c94 Mon Sep 17 00:00:00 2001 From: Sefik Ilkin Serengil Date: Sun, 2 Jun 2024 18:55:34 +0100 Subject: [PATCH 3/3] port number updated --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8d003fd4c..6ec645a48 100644 --- a/README.md +++ b/README.md @@ -315,11 +315,11 @@ cd scripts

-Face recognition, facial attribute analysis and vector representation functions are covered in the API. You are expected to call these functions as http post methods. Default service endpoints will be `http://localhost:5000/verify` for face recognition, `http://localhost:5000/analyze` for facial attribute analysis, and `http://localhost:5000/represent` for vector representation. You can pass input images as exact image paths on your environment, base64 encoded strings or images on web. [Here](https://github.com/serengil/deepface/tree/master/deepface/api/postman), you can find a postman project to find out how these methods should be called. +Face recognition, facial attribute analysis and vector representation functions are covered in the API. You are expected to call these functions as http post methods. Default service endpoints will be `http://localhost:5005/verify` for face recognition, `http://localhost:5005/analyze` for facial attribute analysis, and `http://localhost:5005/represent` for vector representation. You can pass input images as exact image paths on your environment, base64 encoded strings or images on web. [Here](https://github.com/serengil/deepface/tree/master/deepface/api/postman), you can find a postman project to find out how these methods should be called. **Dockerized Service** - [`Demo`](https://youtu.be/9Tk9lRQareA) -You can deploy the deepface api on a kubernetes cluster with docker. The following [shell script](https://github.com/serengil/deepface/blob/master/scripts/dockerize.sh) will serve deepface on `localhost:5000`. You need to re-configure the [Dockerfile](https://github.com/serengil/deepface/blob/master/Dockerfile) if you want to change the port. Then, even if you do not have a development environment, you will be able to consume deepface services such as verify and analyze. You can also access the inside of the docker image to run deepface related commands. Please follow the instructions in the [shell script](https://github.com/serengil/deepface/blob/master/scripts/dockerize.sh). +You can deploy the deepface api on a kubernetes cluster with docker. The following [shell script](https://github.com/serengil/deepface/blob/master/scripts/dockerize.sh) will serve deepface on `localhost:5005`. You may need to re-configure the [Dockerfile](https://github.com/serengil/deepface/blob/master/Dockerfile) if you want to apply some customization. Then, even if you do not have a development environment, you will be able to consume deepface services such as verify and analyze. You can also access the inside of the docker image to run deepface related commands. Please follow the instructions in the [shell script](https://github.com/serengil/deepface/blob/master/scripts/dockerize.sh). ```shell cd scripts