Init funtional of api

This commit is contained in:
Mario Gil 2023-12-25 15:09:52 -05:00
parent 9667bd64b9
commit 086fdd6958
10 changed files with 120 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
__pycache__/main.cpython-311.pyc

View File

@ -0,0 +1,10 @@
Api to get emotions, age, gender , race and rectangle of face.
in a Post in http://127.0.0.1:7860/faces/ with a json in body with this format:
{"path":"data/3.jpg","actions":["age", "gender", "emotion", "race"]}
** install
install requeriments.txt

BIN
data/1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

BIN
data/2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

BIN
data/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

BIN
data/4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

BIN
data/5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

37
main.py Normal file
View File

@ -0,0 +1,37 @@
from deepface import DeepFace
from fastapi import FastAPI
from pydantic import BaseModel
from typing import Optional
# objs = DeepFace.analyze(img_path = "data/1.jpg",
# actions = ['age', 'gender', 'race', 'emotion']
# )
# print(objs)
# objs = DeepFace.analyze(img_path = "data/2.jpg",
# actions = ['age', 'gender', 'race', 'emotion']
# )
# print(objs)
# objs = DeepFace.analyze(img_path = "data/3.jpg",
# actions = ['age', 'gender', 'race', 'emotion']
# )
# print(objs)
# objs = DeepFace.analyze(img_path = "data/4.jpg",
# actions = ['age', 'gender', 'race', 'emotion']
# )
# print(objs)
# print(objs)
class Response(BaseModel):
path: str
actions : Optional[list] = ['age', 'gender', 'race', 'emotion']
app = FastAPI()
@app.get("/")
def read_main():
return {"message": "This is your main app"}
@app.post("/faces/")
def calculate_api(response: Response):
path = response.path
actions = response.actions
objs = DeepFace.analyze(img_path =path,
actions = actions)
return objs

71
requeriments.txt Normal file
View File

@ -0,0 +1,71 @@
absl-py==2.0.0
annotated-types==0.6.0
anyio==3.7.1
astunparse==1.6.3
beautifulsoup4==4.12.2
blinker==1.7.0
cachetools==5.3.2
certifi==2023.11.17
charset-normalizer==3.3.2
click==8.1.7
deepface==0.0.80
Deprecated==1.2.14
fastapi==0.106.0
filelock==3.13.1
fire==0.5.0
Flask==3.0.0
flatbuffers==23.5.26
gast==0.5.4
gdown==4.7.1
google-auth==2.25.2
google-auth-oauthlib==1.2.0
google-pasta==0.2.0
grpcio==1.60.0
gunicorn==21.2.0
h11==0.14.0
h5py==3.10.0
idna==3.6
itsdangerous==2.1.2
Jinja2==3.1.2
keras==2.15.0
libclang==16.0.6
Markdown==3.5.1
MarkupSafe==2.1.3
ml-dtypes==0.2.0
mtcnn==0.1.1
numpy==1.26.2
oauthlib==3.2.2
opencv-python==4.8.1.78
opt-einsum==3.3.0
packaging==23.2
pandas==2.1.4
Pillow==10.1.0
protobuf==4.23.4
pyasn1==0.5.1
pyasn1-modules==0.3.0
pydantic==2.5.3
pydantic_core==2.14.6
PySocks==1.7.1
python-dateutil==2.8.2
pytz==2023.3.post1
requests==2.31.0
requests-oauthlib==1.3.1
retina-face==0.0.13
rsa==4.9
six==1.16.0
sniffio==1.3.0
soupsieve==2.5
starlette==0.27.0
tensorboard==2.15.1
tensorboard-data-server==0.7.2
tensorflow==2.15.0.post1
tensorflow-estimator==2.15.0
tensorflow-io-gcs-filesystem==0.35.0
termcolor==2.4.0
tqdm==4.66.1
typing_extensions==4.9.0
tzdata==2023.3
urllib3==2.1.0
uvicorn==0.25.0
Werkzeug==3.0.1
wrapt==1.14.1

1
run.sh Normal file
View File

@ -0,0 +1 @@
uvicorn main:app --reload --port 7860