Spaces:
Sleeping
Sleeping
| title: Face Detection (SCRFD comparison) | |
| emoji: π | |
| colorFrom: indigo | |
| colorTo: purple | |
| sdk: gradio | |
| sdk_version: 6.20.0 | |
| app_file: app.py | |
| pinned: false | |
| # Face Detection β SCRFD model comparison | |
| Upload one image; it is run through **all three** SCRFD face detectors at once and | |
| the annotated results are shown **side by side** so you can compare them in a single | |
| pass β no model picker. | |
| | Model | File | Input | Notes | | |
| |-------|------|-------|-------| | |
| | SCRFD-500MF | `models/det_500m.onnx` | 640Γ640 | lighter / faster | | |
| | SCRFD-2.5GF | `models/det_2.5g.onnx` | 640Γ640 | heavier / usually higher recall | | |
| | SCRFD @ 480 | `models/det_480.onnx` | 480Γ480 | same SCRFD-500MF weights as `det_500m`, exported at a smaller input β fastest, but drops more small/distant faces | | |
| The third panel isolates the effect of **input resolution**: `det_480` uses the very | |
| same SCRFD-500MF network as `det_500m`, just fed a 480Γ480 letterbox instead of | |
| 640Γ640, so any difference you see is purely down to input size (speed vs. reach on | |
| small faces). | |
| Each panel draws every detected face (bounding box + confidence) and its title bar | |
| reports the **face count** and **inference time**; the 5-point landmark coordinates | |
| for each face are listed as text below the panel. | |
| CPU-only ONNX Runtime β runs on a free Hugging Face Space. | |
| ## How it works | |
| 1. The image is letterboxed to each model's input size (640Γ640 for `det_500m` / | |
| `det_2.5g`, 480Γ480 for `det_480`), aspect ratio preserved. | |
| 2. All three SCRFD models run in ONNX Runtime (CPU). | |
| 3. `scrfd.py` decodes the anchor-based outputs (3 strides Γ {score, bbox, kps}), | |
| applies IoU-NMS, and maps boxes back to the original image. | |
| `scrfd.py` is a self-contained re-implementation of InsightFace's SCRFD | |
| post-processing, so the raw `.onnx` files load directly β no `insightface` | |
| package or model-pack directory needed. | |
| ## Run locally | |
| ```bash | |
| pip install -r requirements.txt | |
| python app.py | |
| ``` | |
| Then open the URL shown in the terminal (e.g. http://127.0.0.1:7860). | |
| ## Models | |
| `det_500m.onnx` and `det_2.5g.onnx` are the standard InsightFace SCRFD detection | |
| checkpoints (both with 5-point landmarks). `det_480.onnx` is the same SCRFD-500MF | |
| network re-exported with a fixed 480Γ480 input. They live in `models/`. | |