I created this as part of a college project laboratory project. The project is a face recognition based authentication system.
This API is capable creating embedding vectors of faces and also comparing an image with an embedding vector.
The app utilizes Flask and the facenet-pytorch library to create rest endpoints that can create the embedding vectors and do the comparisons.
- Clone the repository
- Install the requirements
pip install -r requirements.txt
- Run the app
flask --debug run
Every request should contain an api key in the headers.
The API key is known only to the authentication backend API and this API.
POST /image-embedding
Payload type: form-data
interface Payload {
image: File,
}
Expected successful result: Status code - 200
{
"fv": [...]
}
It should return a 512 dimensional embedding vector.
POST /compare-faces
Payload type: form-data
interface Payload {
image: File,
fv: string, // The embedding vector as a string in { "fv": [...] } format
}
Expected successful result: Status code - 200
{
"cosine_similarity": 0.9
}
It should return the cosine similarity between the embedding vector taken off the image and the image and the embedding vector parameter.