Face Detection
Model basic information¶
Pyramid-Lite is a lightweight model developed by Baidu in 2018 in PyramBox of Computer Vision id 2018 ECCV. It is based on the main network FaceBoxes, measurement, environment, expression changes, meeting changes and other common problem models. The PaddleHub module is based on WIDER FACE data It can be used for face detection based on self-collected face datasets and Baidu self-collected face datasets, which supports prediction.
Sample result example¶
Enter the file path and the model will give its predictions:
Image Source (https://www.pexels.com)
Let's try it out now
Prerequisite¶
1、environment dependent¶
Please visit dependencies
2、pyramidbox_lite_server dependent¶
-
paddlepaddle >= 1.6.2
-
paddlehub >= 1.6.0
3、Download the model¶
hub install pyramidbox_lite_server
Serve the Model¶
Install Pinferencia¶
First, let's install Pinferencia.
pip install "pinferencia[streamlit]"
Create app.py¶
Let's save our predict function into a file app.py
and add some lines to register it.
app.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
Run the service, and wait for it to load the model and start the server:
$ uvicorn app:service --reload
INFO: Started server process [xxxxx]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
Test the service¶
Tips
The image exists on the service machine, you can enter the relative path of the service file or the absolute path of the file
Request
curl --location --request POST \
'http://127.0.0.1:8000/v1/models/face_detector/predict' \
--header 'Content-Type: application/json' \
--data-raw '{
"data": "{base64 encoded image}"
}'
Response
{
"model_name": "face_detector",
"model_version": "default",
"data": [
{
"data": [
{
"confidence": 0.9984221458435059,
"left": 519,
"top": 447,
"right": 755,
"bottom": 750
}
],
"path": "ndarray_time=1655802174713885.0"
}
]
}
Create the test.py
.
test.py | |
---|---|
1 2 3 4 5 6 7 8 9 |
|
$ python test.py
{
"model_name": "face_detector",
"model_version": "default",
"data": [
{
"data": [
{
"confidence": 0.9984221458435059,
"left": 519,
"top": 447,
"right": 755,
"bottom": 750
}
],
"path": "ndarray_time=1655802174713885.0"
}
]
}