Minimal API for face recognition.
The main aim of this project is to create a minimal API for beginners so that they could use face recognition in their applications.
Also it has been noticed that face recognition systems usually have a lot of dependencies. Installing all these dependencies on every client is not at all feasible. A simple way to solve this is to create a server which will handle all the work. An image to be searched for faces will be sent to the server and it will respond with appropriate information.
- Client sends an image and an username to the server using appropriate API call.
- Server processes the image in following manner :
- Detects faces using Haar cascades. (Frontal face detector)
- Detect facial landmarks of detected face using DLIB
- Encode these landmarks
- Run the Keras model which will recognize the user's face. (Respective Keras model will be fetched from 'HOME:
API_KEY
'.)
- Return a JSON response to the client.
Training a new face will work in a similar way. Only the client will send 10 photos (casted as String(base64(Image))) and then Keras model will be retrained.
FOR DETAILS REGARDING HOW TO CONVERT IMAGES TO BE SENT TO SERVER
AS API IS NOT HOSTED, RUN LOCALLY.
POST `API_KEY`, username and image to 127.0.0.1:5000/recognize/ (Flask test server) according to guidelines mentioned below:
- Image should be converted to base64.
- Convert the base64 bytes to string and send.
- API_KEY and username should be strings.
RESPONSE FROM SERVER IN CASE OF SUCCESSFUL RECOGNITION:
{
responseType : "SUCCESS",
successDescription : "Face recognized successfully.",
detectionTime : 0.02, // Seconds taken by Keras model to generate output
confidencePercentage : 0.95
}
RESPONSE FROM SERVER IN CASE OF FAILED RECOGNITION:
{
responseType : "FAILURE",
successDescription : "Face not recognized." | "Face not detected."
}
POST `API_KEY`, 50 ~ 100 images and username to 127.0.0.1:5000/train (Flask test server) according to guidelines mentioned below:
- Image should be converted to base64.
- Convert the base64 bytes to string and send.
- API_KEY and username should be strings.
RESPONSE FROM SERVER: // Will take ton of time (1 ~ 5 minutes) because of retraining Keras model
{
responseType : "SUCCESS",
successDescription : "Model trained successfully."
}
- Will server respond while model is being retrained ?
- If yes, how will you handle requests to the model that is being retrained?
- Should developers be given to choice to handle Keras hyperparameters?
- Should developers be given such kind of flexibility or just keep the API as minimal as possible?
USE API_KEY = "API_KEY_TEST_1"