Skip to content

Add SCRFD detector and Gradio web UI - #79

Open
nick8592 wants to merge 9 commits into
ORB-HD:masterfrom
nick8592:feature/gradio-ui
Open

Add SCRFD detector and Gradio web UI#79
nick8592 wants to merge 9 commits into
ORB-HD:masterfrom
nick8592:feature/gradio-ui

Conversation

@nick8592

Copy link
Copy Markdown

Summary

This PR adds two major features:

1. SCRFD Face Detector

  • Add SCRFD as an alternative face detector alongside CenterFace
  • SCRFD uses the scrfd_10g.onnx model (17MB, InsightFace buffalo_l) with FPN architecture and distance-based bounding box/keypoint decoding
  • New --detector {centerface,scrfd} CLI flag (SCRFD is the default)
  • WIDER FACE benchmark: SCRFD-10G scores 95.16/93.87/83.05 (Easy/Medium/Hard) vs CenterFace 93.2/92.1/87.3
  • Both detectors share the same __call__ contract (det, lms output), making them plug-compatible
  • Add SCRFD example images and side-by-side comparisons to README

2. Gradio Web UI

  • New deface/ui.py — interactive web interface for face anonymization
  • Two tabs: Image (upload → anonymize → side-by-side preview + download) and Video (upload → process → download)
  • All CLI options exposed as interactive controls: detector selection, threshold, anonymization mode, mask scale, ellipse/box, draw scores, mosaic size, replacement image, keep audio
  • Conditional UI: mosaic size slider appears only when replacewith=mosaic, replacement image upload only when replacewith=img
  • Lazy detector caching: ONNX model loaded once per config, reused across requests
  • Install via pip install 'deface[ui]', launch via deface-ui or python -m deface.ui

Files Changed

File Change
deface/scrfd.py New — SCRFD detector implementation
deface/scrfd_10g.onnx New — SCRFD model weights
deface/ui.py New — Gradio web interface
deface/deface.py Added --detector CLI flag, get_anonymized_image() programmatic API, SCRFD integration
pyproject.toml Added ui optional dep (gradio>=5.0), deface-ui entry point
README.md SCRFD section, Gradio UI section, example images, screenshot
examples/gradio_ui.jpg New — full-page Gradio UI screenshot

Testing

  • Both detectors tested via CLI and Gradio API (blur, solid, mosaic, none modes)
  • Detector caching verified (same instance on repeated calls)
  • Image processing verified: original preserved, anonymized differs, download file exists
  • Gradio API endpoint returns correct results for all parameter combinations
  • ruff lint: all checks passed

- Generate SCRFD output images for blur, boxes, mosaic, and draw-scores
- Update README header to 3-column comparison: Original vs CenterFace vs SCRFD
- Add side-by-side CenterFace vs SCRFD comparisons for boxes, mosaic, and scores
- Remove "higher recall" and "legacy" claims from README
- Add CenterFace WIDER FACE numbers to benchmark table
- Replace SCRFD-2.5G row with CenterFace row for fair comparison
- Change image comparison headers from "CenterFace (legacy)" to "CenterFace"
SCRFD paper only reports validation set (95.16/93.87/83.05), not test set.
CenterFace val-set numbers are 93.5/92.4/87.5 (from arXiv:1911.03599).
Previous table mixed SCRFD val numbers with CenterFace test numbers (93.2/92.1/87.3),
which is an apples-to-oranges comparison. Add footnote citing sources and resolution.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant