Skip to content

Commit

Permalink
put api in deepface folder to make it testable
Browse files Browse the repository at this point in the history
  • Loading branch information
serengil committed Feb 4, 2024
1 parent 1ca17d7 commit 86d424b
Show file tree
Hide file tree
Showing 12 changed files with 7 additions and 14 deletions.
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ RUN apt-get install ffmpeg libsm6 libxext6 -y
# -----------------------------------
# Copy required files from repo into image
COPY ./deepface /app/deepface
COPY ./api/src/app.py /app/
COPY ./api/src/api.py /app/
COPY ./api/src/routes.py /app/
COPY ./api/src/service.py /app/
COPY ./requirements.txt /app/
COPY ./package_info.json /app/package_info.json
COPY ./setup.py /app/
COPY ./README.md /app/

Expand All @@ -50,5 +47,6 @@ ENV PYTHONUNBUFFERED=1

# -----------------------------------
# run the app (re-configure port if necessary)
WORKDIR /app/deepface/api/src
EXPOSE 5000
CMD ["gunicorn", "--workers=1", "--timeout=3600", "--bind=0.0.0.0:5000", "app:create_app()"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ user

**API** - [`Demo`](https://youtu.be/HeKCQ6U9XmI)

DeepFace serves an API as well. You can clone [`/api`](https://github.com/serengil/deepface/tree/master/api) folder and run the api via gunicorn server. This will get a rest service up. In this way, you can call deepface from an external system such as mobile app or web.
DeepFace serves an API as well. You can clone deepface source code and run the api via gunicorn server with the following command. This will get a rest service up. In this way, you can call deepface from an external system such as mobile app or web.

```shell
cd scripts
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion api/src/app.py → deepface/api/src/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 3rd parth dependencies
from flask import Flask
from modules.core.routes import blueprint
from deepface.api.src.modules.core.routes import blueprint

def create_app():
app = Flask(__name__)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask import Blueprint, request
from modules.core import service
from deepface.api.src.modules.core import service
from deepface.commons.logger import Logger

logger = Logger(module="api/src/routes.py")
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/service.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
cd ../api/src
cd ../deepface/api/src
gunicorn --workers=1 --timeout=3600 --bind=0.0.0.0:5000 "app:create_app()"
7 changes: 1 addition & 6 deletions tests/testing_api.py → tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import sys
import unittest
from deepface.commons import constant
from deepface.commons.logger import Logger
from deepface.api.src.app import create_app

# api is not available under deepface import
sys.path.insert(1, f"{constant.ROOT_DIR}/api/src")
# pylint: disable=wrong-import-order, wrong-import-position
from app import create_app

logger = Logger("tests/test_api.py")

Expand Down

0 comments on commit 86d424b

Please sign in to comment.