FPT.AI Reader - Face Search
Input requirements
Image format must be jpg or jpeg
Size of the input image must not surpass 5 MB with minimum resolution around
640x480 to ensure accuracy rate
Face must take up at least ¼ of the total image area.
Qualified image sample
Unqualified images
- Low-quality images or images with the face covered
API Information
1. Create user on the system (to add index images)
Request Url
POST https://api.fpt.ai/dmp/facesearch/v2/create
Request Headers
Parameter | Requirement | Default | Description |
api_key | Yes | | your api_key (from console.fpt.ai) |
Request Body
FormData contains the collection name and user information (id, name)
Parameter | Requirement | Description |
collection | yes | each collection will be indexed and searched separately |
id | yes | user id must be unique |
name | yes | |
Sample Request
curl --location --request POST 'https://api.fpt.ai/dmp/facesearch/v2/create' \\
\--header 'api_key: xxxxxxxxxxxxxxxx' \\
\--form 'collection=test2' \\
\--form 'id=1234' \\
\--form 'name=Nam'
Response
JSON
{
"data": "User created/updated",
"code": "200"
}
Response Code
Code | meaning |
200 | User created/updated |
Sample Response: Success
{
"data": "User created/updated",
"code": "200"
}
2. Index user images
Request Url
POST https://api.fpt.ai/dmp/facesearch/v2/add
Request Headers
Parameter | Requirement | Default | Description |
api_key | Yes | | your api_key (from console.fpt.ai) |
Request Body
FormData contains the collection name, user id, and face image
Parameter | Requirement | Description |
collection | yes | each collection will be indexed and searched separately |
id | yes | user id created |
file | yes | face detected |
allow_id_card | no | true/false: allow id card image |
Sample Request
curl --location --request POST 'https://api.fpt.ai/dmp/facesearch/v2/add' \\
\--header 'api_key: xxxxxxxxxxxxxxxx' \\
\--form 'file=\@/path/to/photo.jpg' \\
\--form 'collection=test2' \\
\--form 'id=1234'
Response
JSON
{
"data": "Add photo success",
"code": "200"
}
Response Code
Code | meaning |
200 | Image index successs |
400 | Wrong format / Multiple faces / No face detected |
406 | Face covered with mask, hat, or sunglasses |
410 | Photo is id card |
Sample Response: Success
{
"data": "Add photo success",
"code": "200"
}
Sample Response: Error
{
"data": "No face detected",
"code": "400"
}
{
"data": "Photo is id card",
"code": "410"
}
3. Facesearch
Request Url
POST https://api.fpt.ai/dmp/facesearch/v2/search
Request Headers
Parameter | Requirement | Default | Description |
api_key | Yes | | your api_key (from console.fpt.ai) |
Request Body
FormData contains the collection name, and the face image to be searched
Parameter | Requirement | Description |
collection | yes | each collection will be indexed and searched separately |
file | yes | face detected |
threshold | no | The default threshold for identification of 2 similar faces is 0.85 |
allow_id_card | no | true/false: allow id card image |
Sample Request
curl --location --request POST 'https://api.fpt.ai/dmp/facesearch/v2/search' \\
\--header 'api_key: xxxxxxxxxxxxxxxx' \\
\--form 'file=\@/path/to/search_photo.jpg' \\
\--form 'collection=test2' \\
\--form 'threshold=0.9'
Response
JSON
{
"data": {
"id": "1234",
"name": "Nam",
"similarity": 0.9999998807907104
},
"code": "200"
}
Response Code
Code | meaning |
200 | Image index successs |
400 | Wrong format / Multiple faces / No face detected |
404 | Not found |
406 | Face covered with mask, hat, or sunglasses |
410 | Photo is id card |
Sample Response: Success
{
"data": {
"id": "1234",
"name": "Nam",
"similarity": 0.9999998807907104
},
"code": "200"
}
Sample Response: Error
{
"data": "No face detected",
"code": "400"
}
{
"data": "Photo is id card",
"code": "410"
}
{
"data": "Not found",
"code": "404"
}
4. Remove face data (not delete the user)
Request Url
DELETE https://api.fpt.ai/dmp/facesearch/v2/delete_faces
Request Headers
Parameter | Requirement | Default | Description |
api_key | Yes | | your api_key (from console.fpt.ai) |
Request Body
FormData contains the collection name and user id
Parameter | Requirement | Description |
collection | yes | collection name |
id | yes | the id of user |
Sample Request
curl --location --request DELETE 'https://api.fpt.ai/dmp/facesearch/v2/delete_faces' \
--header 'api_key: xxxxxx' \
--form 'collection="test1"' \
--form 'id="2"'
Response
JSON
{
"data": "User faces deleted",
"code": "200"
}
Response Code
Code | meaning |
200 | Faces delete success |
404 | User not found |
5. Delete user
Request Url
DELETE https://api.fpt.ai/dmp/facesearch/v2/delete
Request Headers
Parameter | Requirement | Default | Description |
api_key | Yes | | your api_key (from console.fpt.ai) |
Request Body
FormData contains the collection name and user id
Parameter | Requirement | Description |
collection | yes | collection name |
id | yes | the id of user |
Sample Request
curl --location --request DELETE 'https://api.fpt.ai/dmp/facesearch/v2/delete' \
--header 'api_key: xxxxxxxx' \
--form 'collection="test2"' \
--form 'id="1234"'
Response
JSON
{
"data": "User deleted",
"code": "200"
}
Response Code
Code | meaning |
200 | User delete success |
404 | User not found |
6. List users in collection
Request Url
GET https://api.fpt.ai/dmp/facesearch/v2/list
Request Headers
Parameter | Requirement | Default | Description |
api_key | Yes | | your api_key (from console.fpt.ai) |
Request Params
Request string contains the collection name
Parameter | Requirement | Description |
collection | yes | The collection name that want to list users |
Sample Request
curl --location --request GET 'https://api.fpt.ai/dmp/facesearch/v2/list?collection=test1' \
--header 'api_key: xxxxxx' \
Response
JSON
{
"data": [
{
"id": "1",
"name": "Nguyen Van A"
},
{
"id": "3",
"name": "Nguyen Van B"
}
],
"code": "200"
}
Response Code
Code | meaning |
200 | Request success |
7. Delete collection
Request Url
DELETE https://api.fpt.ai/dmp/facesearch/v2/delete_collection
Request Headers
Parameter | Requirement | Default | Description |
api_key | Yes | | your api_key (from console.fpt.ai) |
Request Body
FormData contains the collection name
Parameter | Requirement | Description |
collection | yes | collection name |
Sample Request
curl --location --request DELETE 'https://api.fpt.ai/dmp/facesearch/v2/delete_collection' \
--header 'api_key: xxxxxx' \
--form 'collection="test1"'
Response
JSON
{
"data": "Remove collection success",
"code": "200"
}
Response Code
Code | meaning |
200 | Collection delete success |
404 | Collection not found |