Faceplugin-ltd/FaceLivenessDetection-Docker
关于
Self-hosted face liveness detection & anti-spoofing API for Linux and Docker. Passive liveness with presentation attack detection — detects printed photos, video replays and 3D masks. Tested internally to ISO/IEC 30107-3. On-premise REST API, no cloud, for KYC.
设计与媒体实测星标增长
- 24小时
- 0
- 7天
- 正在收集历史
- 15天
- 正在收集历史
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文
🌐 Company Site - Here
🤗 Hugging Face - Here
🛟 Help Center - Here
🐳 Docker Hub - Here
FacePlugin Face Liveness Detection — Docker (Fully On-Premise)
Jump: Quick start · Get the runtime · Start the API · SDK License · Try it · Setup on your own app · About SDK
Quick start
- Docker (recommended):
docker pull faceplugin/face-liveness:latest, thendocker run— Start the API - Or native Linux: download
runtime.zipfrom Releases and extract it intolib/cpu/, then./run.sh— Get the runtime - Confirm it is running:
curl -s http://127.0.0.1:8093/api/health(no license needed yet) - Contact us with your machine code for a license key, then
POST /api/activate - Try it with Postman, curl, or the Gradio demo on 9093 (
python3 demo.py)
Docs: doc.faceplugin.com · Try online: Hugging Face Space
Introduction
FacePlugin Face Liveness Detection is a fully on-premise anti-spoofing engine for KYC and remote identity verification. It answers one question about one photo — is this a real face in front of the camera, or a presentation attack? — and returns Real / Spoof with a score. Passive: nothing is asked of the person, and a single RGB frame is enough. No depth camera, no infrared, no extra hardware.
It detects printed photos, screen replays (photo and video), 3D masks, and deepfakes handled as one more kind of spoof.
The SDK runs as a REST API server through Docker on a Linux host, or natively on Linux x86_64. It runs on CPU only. The container is started privileged, with 2 GB of shared memory and the host's /etc/machine-id bound in — see Option A — Docker — so Docker Desktop on macOS or Windows is not a supported host; use a Linux VM there. This repository is self-contained; no other FacePlugin repository is required.
All processing stays on your server. No biometric data is sent to FacePlugin — built for banking, eKYC, and on-premise compliance workflows.
Main Functionalities
| Feature | API |
|---|---|
| Passive face liveness — score one RGB image for presentation attacks | POST /api/liveness · sdk.liveness |
| Printed photo, screen replay, 3D mask and deepfake detection | same call |
| Score, Real/Spoof verdict, pass flag | data.score · data.result · data.pass |
| Health / machine code / activate / license | GET /api/health · GET /api/machinecode · POST /api/activate · GET /api/licenseStatus |
| Which runtime is loaded | GET /api/backend |
Score ≥ 0.5 → result: "Real", pass: true. Score < 0.5 → result: "Spoof", pass: false.
POST /api/check_liveness is an alias of /api/liveness. Routes are /api/*; there is no version segment, and every /api/* path answers OPTIONS for browser preflight.
The call takes one image and nothing else — there is no model or algorithm to choose. The runtime fuses every RGB estimator it holds into the single score you get back, and pass is score >= 0.5, fixed in native code and not settable over HTTP.
Liveness here is passive only. There is no active (challenge–response) liveness over HTTP; for that, use the mobile SDKs in Product List.
Benchmarks
Passive mode, at the default threshold of 0.5:
| Metric | This product (server) |
|---|---|
| BPCER — real faces wrongly rejected | 3.3% |
| APCER — attacks wrongly accepted | 0% |
Measured by FacePlugin QA following the ISO/IEC 30107-3 methodology, against four presentation attack instrument species: printed photo, screen replay (photo), screen replay (video), and a painted 3D resin mask.
This is an internal evaluation, not an independent laboratory result, and no iBeta certification is claimed. A 0% APCER means no acceptance was observed among the attack presentations in this run. Ask us for the full PAD evaluation report.
Figures: doc.faceplugin.com.
Product List
The same Face Liveness product ships on nine platforms. The mobile SDKs run on-device and offer passive and active liveness; the two server products are passive only.
| Platform | Repository |
|---|---|
| Android | FaceLivenessDetection-Android |
| iOS | FaceLivenessDetection-iOS |
| Flutter | FaceLivenessDetection-Flutter |
| React Native | FaceLivenessDetection-ReactNative |
| Ionic Capacitor | FaceLivenessDetection-Ionic-Capacitor |
| Ionic Cordova | FaceLivenessDetection-Ionic-Cordova |
| .NET MAUI | FaceLivenessDetection-DotNet-MAUI |
| Windows (server) | FaceLivenessDetection-Windows |
| Linux / Docker (server) | Docker Hub · FaceLivenessDetection-Docker (this repo) |
Related products
Need active liveness — blink, smile, turn your head? That is an on-device feature; start with the mobile SDKs above, for example FaceLivenessDetection-Android or FaceLivenessDetection-iOS.
Face recognition, on-premise servers:
- Docker — Docker Hub · FaceRecognition-Docker
- Windows — FaceRecognition-Windows
On-device face recognition + liveness apps for mobile:
Before you start
| Step | What you need |
|---|---|
| 1 | Docker Engine on a Linux host, or Linux x86_64 with glibc 2.38+ and Python 3.10+ |
| 2 | For a native run only: the runtime in lib/cpu/ — see Get the runtime. The Docker image already contains it. |
| 3 | Start without a license, copy the machine code from the logs, send it to FacePlugin (contact), then activate with your license key |
You do not need a license to start the API. Product endpoints unlock after you activate.
System requirements
| Item | Minimum | Recommended |
|---|---|---|
| CPU | 2 cores | 4 cores |
| RAM | 4 GB | 8 GB |
| Disk | 4 GB | 8 GB |
| OS (Docker) | Linux + Docker Engine | Ubuntu 22.04 / 24.04 |
| OS (native) | Linux x86_64, glibc 2.38+ | Ubuntu 24.04 |
| Python (native) | 3.10+ | 3.12 |
Check your glibc with ldd --version. Debian Bookworm ships 2.36 and is too old for a native run — use Docker there.
Get the runtime
Docker users can skip this: the runtime is already inside the image.
For a native run, lib/cpu/ is empty on GitHub because the native libraries and model files are too large. This product is CPU-only — there is no gpu/ package.
Download the runtime from Releases
The release holds one archive, runtime.zip — there is a single runtime for this product.
- Clone the repo (if you have not already):
git clone https://github.com/Faceplugin-ltd/FaceLivenessDetection-Docker.git
cd FaceLivenessDetection-Docker
- Open the release page above and download
runtime.zip. - Extract it and place the files directly in
lib/cpu/, not in a subfolder.
FaceLivenessDetection-Docker/
└── lib/
└── cpu/
├── libFaceLivenessSDK.so
├── libfacerec.so
├── fal.fpk
├── libonnxruntime.so
├── libonnxruntime_providers_shared.so
└── ... (remaining files from the archive)
⚠️ Move the extracted files up if the archive nests them, so you do not end up with
lib/cpu/SomeFolder/libFaceLivenessSDK.so.
Start the API
You do not need a license to start the API. The server prints your machine code on startup, which you need to get a license. Product endpoints unlock after you activate.
Option A — Docker
sudo docker pull faceplugin/face-liveness:latest
sudo docker run -d --name faceplugin-face-liveness \
--shm-size=2gb --privileged \
-p 8093:8093 \
-v /etc/machine-id:/etc/machine-id:ro \
faceplugin/face-liveness:latest
sudo docker logs -f faceplugin-face-liveness
# Look for the machine code line in the logs
All three flags are mandatory. run.sh checks them inside the container before it starts anything, and exits with an error if any is missing:
| Flag | What is checked |
|---|---|
-v /etc/machine-id:/etc/machine-id:ro |
/etc/machine-id must be a mountpoint — otherwise the license binds to the container's own id, not the host's |
--shm-size=2gb |
/dev/shm must be at least ~1.9 GB |
--privileged |
CAP_SYS_ADMIN must be set in the container's effective capabilities |
So the image expects a Linux host — or a Linux VM — that can supply a real /etc/machine-id. On Docker Desktop for macOS or Windows there is no host /etc/machine-id to bind, and dropping the mount does not help: the container then fails the check and stops. Run it on a Linux host, or inside a Linux VM you control.
The repository also ships a docker-compose.yml and a Dockerfile if you prefer Compose or your own build. A local build needs lib/cpu/ filled first — see Get the runtime.
Several containers on one host: to share one machine code and license across containers, see the docs.
Option B — Native Linux (./run.sh)
pip3 install -r requirements.txt
./run.sh
API: http://127.0.0.1:8093. The machine code is printed in the terminal.
SDK License
Licenses are offline and bound to your machine. Offline cryptography is pre-packaged within the SDK — no third-party licensing libraries or external OpenSSL installations are required.
How to get a license
- Start the server (above). A license is not required for the first start.
- Copy the machine code from the logs — it looks like
FPMC1.…— or fetch it withGET /api/machinecode. - Send that machine code to FacePlugin (contact). We will issue a license key for that code.
- Activate with the license key:
# Save the key, then post it
curl -s -X POST http://127.0.0.1:8093/api/activate \
-H "Content-Type: text/plain" --data-binary @license.txt
Or mount it into the container, as docker-compose.yml does:
-v $(pwd)/license.txt:/root/facesdk/license.txt
The machine code comes from /etc/machine-id, which is why the host's file must be bound in read-only. Without that mount the code would follow the container and your license would stop matching after a recreate — so run.sh refuses to start at all. See Option A — Docker.
License capabilities
This product exposes liveness APIs only. A key labelled Liveness only or Recognition + Liveness unlocks /api/liveness; a Recognition only key leaves it unavailable here.
curl -s http://127.0.0.1:8093/api/licenseStatus
The Gradio demo shows the same summary as License: at the top of the page.
Try it
Health
curl -s http://127.0.0.1:8093/api/health
Liveness
curl -s -X POST http://127.0.0.1:8093/api/liveness \
-H "Content-Type: application/json" \
-d '{"image":"<base64-jpeg>"}'
# or multipart, with the file in the `image` field (`file` is accepted too)
curl -s -X POST http://127.0.0.1:8093/api/liveness -F "[email protected]"
The native JSON is passed through verbatim:
{ "success": true, "code": 0, "message": "OK", "data": { "score": 0.72, "result": "Real", "pass": true } }
Common failures (success: false, data: null):
message |
Meaning |
|---|---|
NO_FACE |
No usable face in the image |
Image not suitable |
Missing or undecodable image |
Full protocol: https://doc.faceplugin.com.
Security
This API has no authentication. By default it listens on 0.0.0.0 — every interface, which is what makes the published Docker port work — and answers browser requests from any origin.
| Variable | Purpose |
|---|---|
FACESDK_BIND_HOST |
Listen address. Default 0.0.0.0. Set it to 127.0.0.1 for this machine only. |
PORT / FACESDK_PORT |
API port. Default 8093. |
LICENSE |
A license key (FP1.…) or a path to a license file. Default ./license.txt. |
FP_NO_LICENSE_PROMPT |
Set to 1 to skip the interactive paste prompt — for services and CI. |
Put it behind your own gateway, or publish the port only to a private network, before exposing it anywhere untrusted.
Postman
Import postman/FaceLiveness-API.postman_collection.json. See postman/README.md for the flow and failure messages.
Default base URL: http://127.0.0.1:8093. Routes are /api/* (/api/check_liveness aliases /api/liveness).
Demo UI (Gradio) — local only
A local FacePlugin Face Liveness demo in the browser. The API must already be running on port 8093.
pip3 install -r requirements-demo.txt
DEMO_PORT=9093 API_BASE=http://127.0.0.1:8093 python3 demo.py
Open http://127.0.0.1:9093. Sample spoof images are in assets/examples/samples/.
Each run shows Score, Result (Real or Spoof) and Pass, with the raw JSON beside it.
Setup on your own app
Two ways to call the same engine. Full protocol: https://doc.faceplugin.com.
| Path | When to use |
|---|---|
HTTP API (Docker or ./run.sh) |
Any language. Keep the API running and POST a base64 JPEG to it. |
sdk.py |
Python on the same Linux machine as lib/cpu/. No HTTP hop. |
HTTP (any language)
- Start the API and activate it once.
POST /api/livenesswith{"image":"<base64-jpeg>"}.- Read
data.passfor the verdict, and checksuccess/codeon every response.
Python in-process
- Copy
sdk.pyandlib/cpu/into your project. - Put
lib/cpuonLD_LIBRARY_PATH(that is allrun.shdoes). - Call
get_machine_code→activate→init_sdk, thenliveness.
The Gradio demo (demo.py) is a local test UI. You do not need it in production.
About SDK
sdk.py is the Python binding. Every call returns 0 on success, or an error code.
1. Get the machine code and request a license
import sdk
print(sdk.get_machine_code()) # FPMC1.…
2. Activate, then initialize
ret = sdk.activate("license.txt") # 0 on success
if ret == 0:
ret = sdk.init_sdk() # 0 on success
status = sdk.get_license_status() # what the key unlocks
3. Score a face
result = sdk.liveness(base64_image) # JSON string
data is { "score": <float>, "result": "Real" | "Spoof", "pass": <bool> }. Every RGB engine in the runtime is run and the scores are combined into that one verdict. Images arrive as base64 JPEG (a data: prefix is accepted); anything else is converted and re-encoded, and over 8 MB is downscaled.
HTTP endpoints: /api/health, /api/machinecode, /api/licenseStatus, /api/backend, /api/activate, /api/liveness, /api/check_liveness.
Contact
探索相关项目
加载中…