Skip to main content

Simple multi-model face detection library

Project description

FaceSwitch

FaceSwitch is a Python library that provides a common interface for multiple face detection backends.

Features

  • Clean detector interface
  • Optional backend dependencies via extras
  • Pluggable architecture
  • Automatic model download for supported backends
  • Typed API (FaceBox)

Requirements

  • Python 3.10+

Installation

pip install faceswitch

Install a specific backend via extras:

pip install "faceswitch[<backend>]"

Examples:

pip install "faceswitch[hog]"
pip install "faceswitch[yolo]"

Install demo dependencies (opencv-python):

pip install "faceswitch[examples]"

Install all optional dependencies:

pip install "faceswitch[all]"

Backend Model

  • Each detector backend is optional and installed through extras.
  • New backends can be added without changing the core detection interface.
  • Current backend extras include hog and yolo.

Minimal Usage (Backend-Agnostic)

import cv2
from faceswitch.detectors.hog import HogDetector

image = cv2.imread("path/to/image.png")
if image is None:
    raise ValueError("Could not read image")

detector = HogDetector()
faces = detector.detect(image)

print(f"Detected: {len(faces)}")

To switch backend later, replace HogDetector with another detector class from faceswitch (for example, YoloDetector) and install its matching extra.

Detector Interface

faces = detector.detect(image)

All detectors return a list of FaceBox values:

FaceBox(
    x1=int,  # left
    y1=int,  # top
    x2=int,  # right
    y2=int,  # bottom
    confidence=float | None,
)

Some detectors may include backend-specific behavior (for example, model download/caching) documented in their module or config.

Run Demos

python examples/demo_hog.py path/to/image.png
python examples/demo_yolo.py path/to/image.png

Adding New Backends

FaceSwitch is designed to grow with more detector implementations. For contribution workflow and detector contract requirements, see CONTRIBUTING.md and ARCHITECTURE.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

faceswitch-0.2.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

faceswitch-0.2.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file faceswitch-0.2.1.tar.gz.

File metadata

  • Download URL: faceswitch-0.2.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for faceswitch-0.2.1.tar.gz
Algorithm Hash digest
SHA256 d738488c27ac5277f615f77bcb333f8a8729b378b1e8c1dca3a19d0682e60fe1
MD5 e0433d6141076a0272fde320bfaaceb1
BLAKE2b-256 161de56e724901c73907f375bf72a0c5c6c7edda5a1a83f05c9d4b5c9409f9e1

See more details on using hashes here.

File details

Details for the file faceswitch-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: faceswitch-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for faceswitch-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9fdf462d5f587ed3fd4db1cd0269e69a08f855c534d2b7a26e9a2ce7968bb1fd
MD5 711056f207885c12e0150ada0d0d79c8
BLAKE2b-256 4971ec3127fd5107a10b350390f8e51248932f0193a60a14387c6dc47560ee68

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page