A lightweight Python client for OpenVINO Model Server (OVMS) face recognition pipeline.
Supports:
- Single image inference with face detection + recognition + known face matching
- Real-time RTSP / MJPEG stream processing with face recognition
- Automatic feature extraction from a folder of face images at startup
- MJPEG streaming output (viewable in browser or VLC)
- Docker deployment for easy distribution
- Auto-generates
known_faces.jsonfrom animages/directory on startup - Each image filename prefix becomes the person ID (e.g.
zhang3.jpg→ ID:zhang3) - Real-time face matching with cosine similarity threshold (configurable)
- MJPEG HTTP stream output (
http://host:8080/stream.mjpg) - Silent handling: minimal logs when no faces or inference fails
- English logging for all key steps
- Fully Dockerized — mount images folder and JSON externally
- Python 3.11+
- OVMS server running with model
face_recognition_yiqisoft - Input model expects: 448×448 RGB float32
Python dependencies (see requirements.txt):
- opencv-python
- numpy
- ovmsclient
face-recognition-client/
├── client.py # Main script
├── requirements.txt # Dependencies
├── Dockerfile # Docker build file
├── images/ # (mounted) Folder of face images (jpg/png)
└── known_faces.json # (mounted/generated) Auto-generated face features
docker build -t face-rec-client:latest .docker run --rm \
-v $(pwd)/images:/app/images \
-v $(pwd)/known_faces.json:/app/known_faces.json \
-v $(pwd)/input.jpg:/app/input.jpg \
-v $(pwd)/output.jpg:/app/output.jpg \
face-rec-client:latest \
--host your-ovms-ip \
--port 31734 \
--images-dir /app/images \
--faces /app/known_faces.json \
--image /app/input.jpg \
--output /app/output.jpg \
--threshold 0.65docker run -d --restart unless-stopped \
-p 8080:8080 \
-v $(pwd)/images:/app/images \
-v $(pwd)/known_faces.json:/app/known_faces.json \
--name face-mjpeg \
face-rec-client:latest \
--host your-ovms-ip \
--port 31734 \
--stream "rtsp://user:pass@camera-ip:554/stream" \
--images-dir /app/images \
--faces /app/known_faces.json \
--http-port 8080 \
--threshold 0.65Then open in browser or VLC:
http://your-server-ip:8080/stream.mjpg
| Argument | Description | Default | Required |
|---|---|---|---|
--host |
OVMS server IP or hostname | — | Yes |
--port |
OVMS gRPC port | — | Yes |
--image |
Path to single input image (inside container) | — | No |
--stream |
Input video stream URL (RTSP / MJPEG) | — | No |
--output |
Output path for image or stream recording | result.jpg |
No |
--http-port |
MJPEG streaming port | 8080 |
No |
--images-dir |
Directory of face images to extract features from | /app/images |
No |
--faces |
Path to save/load known_faces.json | /app/known_faces.json |
No |
--threshold |
Cosine similarity threshold (0~1) | 0.60 |
No |
You can also set THRESHOLD via environment variable:
-e THRESHOLD=0.7All important steps are logged in English:
- Startup and OVMS connection
- Feature extraction from images/
- Stream connection / reconnection
- Face detection & matching results (when faces are found)
- MJPEG client connections
Inference failures and no-face frames are logged at DEBUG level only (silent in INFO mode).
View logs:
docker logs -f face-mjpegTo see more detailed logs (including per-frame info):
Edit the first line of logging setup:
logging.basicConfig(level=logging.DEBUG, ...)Apache License