This API service uses the MediaPipe Face Detection model from Qualcomm AI Hub, running on ONNX Runtime with QNN execution provider for NPU acceleration.
- Python 3.8 or higher
- Qualcomm NPU-enabled device
- ONNX Runtime with QNN provider installed
- Create a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Download the model: The model will be automatically downloaded on first run, or you can manually download it from Qualcomm AI Hub.
Start the server:
python app.pyThe API will be available at http://localhost:8000
Returns basic API information and available endpoints.
Health check endpoint to verify API and model status.
Upload an image to detect faces.
Request:
- Method: POST
- Content-Type: multipart/form-data
- Body: image file
Response:
{
"success": true,
"face_count": 2,
"face_locations": [
// Array of face bounding boxes
]
}Using curl:
curl -X POST -F "file=@image.jpg" http://localhost:8000/detectUsing Python requests:
import requests
url = "http://localhost:8000/detect"
files = {"file": open("image.jpg", "rb")}
response = requests.post(url, files=files)
print(response.json())- The API uses ONNX Runtime with QNN execution provider for NPU acceleration
- Input images are automatically resized to 256x256 pixels
- The model supports real-time face detection with sub-millisecond processing
- Face detection includes facial landmarks (eyes, nose, mouth)
This project uses the MediaPipe Face Detection model under the AI-HUB-MODELS-LICENSE from Qualcomm AI Hub.