Simple face detector API using dlib
using localstack
to save data in S3 bucket
and dynamoDB
.
The project is divided into two directories.
./streamer
: a python script that launches your camera and detects your face../api
: a vanilla django api (with an appstreamer
), with Postgresql.
- First start the api :
docker-compose up -d api
. You may need to run the first migrations :docker-compose exec api django-admin migrate
. - Create dynamodb table (chose a name) :
aws dynamodb create-table --table-name testDB --attribute-definitions AttributeName=id,AttributeType=S --key-schema AttributeName=id,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 --endpoint-url http://localhost:4569
- Create a S3 bucket :
aws s3api create-bucket --bucket testBucket --endpoint-url http://localhost:4572
- Make the bucket easily readable :
aws s3api put-bucket-acl --bucket testBucket --acl public-read --endpoint-url http://localhost:4572
Once you've done all these steps, the API and different storage are up and running, just as if they were distant services. It is now time to look at the streamer, which is the client that will run on your machine, access the webcam and interact with the API.
Our goal is to save all the data generated by one session of the streamer. For each iteration of the streamer algorithm, we need to save :
- the frame on which the streamer has run
- the feedback returned for that frame
- the face extracted for that frame, if there was one
- During running of streamer, images are saved inside S3 and info on single frame iteration is saved inside dynamodb.
- Once the streamer is done, API calls are made to create and save data as Django objects from the dynamodb data.
Different API calls to get data:
- To get extracted faces of session with :
http://localhost:8000/api/stream-sessions/<sessionId>/faces
- To get all streaming sessions:
http://localhost:8000/api/stream-sessions/
- To get all frame iterations for a streaming session:
http://localhost:8000/api/stream-sessions/<sessionId>/iterations