Bahlib - Biometric Anonymizer Hub Library

A high-performance, lightweight Python library for 100% local biometric anonymization. Bahlib automatically detects human faces in images and videos, applying smooth Gaussian blur to protect privacyโ€”without ever sending data to third-party servers. Features include multi-scale detection for group photos, tiled processing for small faces, and feathered blending for natural-looking results.

pip install bahlib
# Anonymize faces in just 3 lines
from bahlib import Bahlib

with Bahlib() as bh:
    result = bh.anonymize("photo.jpg")
    
# Save your privacy-protected image
cv2.imwrite("anonymous.jpg", result)
Features

Built for Privacy-First Development

Everything you need to protect identities in images and videos

๐Ÿ”’

100% Local Processing

All face detection and blurring happens entirely on your machine. No cloud uploads, no API calls, complete data sovereignty.

๐ŸŽฏ

Smooth Blending

Feathered elliptical masks create natural-looking blur that seamlessly blends with surrounding pixels.

๐Ÿ‘ฅ

Multi-Scale Detection

Advanced tiled detection algorithm finds faces of all sizes, even in crowded group photos with small faces.

๐ŸŽฌ

Video Support

Process video files frame-by-frame or run real-time anonymization on live webcam feeds.

๐Ÿ“

Batch Processing

Anonymize entire directories of images with a single command, with progress tracking and recursive support.

๐Ÿ’ป

CLI & Python API

Use from the command line for quick tasks, or integrate the Python API into your applications.

Installation

Get Started in Seconds

1

Install the package

pip install bahlib
2

Import in your code

from bahlib import Bahlib
3

Anonymize faces

result = Bahlib().anonymize("photo.jpg")
Usage

Three Simple Operations

Master the library with just three concepts

Python API

Integrate face anonymization into your Python applications with a clean, intuitive API.

  • Context manager for automatic resource cleanup
  • Accepts file paths or numpy arrays
  • Configurable blur strength and feathering
  • Multi-scale and tiled detection for group photos
from bahlib import Bahlib
import cv2

# Basic usage
with Bahlib() as bh:
    result = bh.anonymize("photo.jpg")
    cv2.imwrite("output.jpg", result)

# Group photos with small faces
with Bahlib(min_detection_confidence=0.3) as bh:
    result = bh.anonymize(
        "group.jpg",
        blur_strength=71,
        feather_amount=0.4,
        tiled=True,
        tile_size=320
    )

# Detection only (no blur)
faces = bh.detect_faces("photo.jpg")

Command Line Interface

Use bahlib directly from your terminal for quick anonymization tasks.

  • Process single images or entire directories
  • All Python API options available as flags
  • Progress indicators for batch processing
  • Preview results with --show flag
# Single image
$ bahlib image photo.jpg -o output.jpg

# Custom blur strength
$ bahlib image photo.jpg -o out.jpg --blur 71

# Group photo with tiled detection
$ bahlib image group.jpg -o out.jpg \
    --tiled --tile-size 320 --confidence 0.3

# Batch process a directory
$ bahlib batch ./photos ./output --recursive

# Preview result
$ bahlib image photo.jpg -o out.jpg --show

Video Processing

Anonymize faces in video files or live webcam feeds with frame-by-frame detection.

  • Process video files with preserved quality
  • Real-time webcam anonymization
  • Configurable detection confidence
  • Press 'q' to stop webcam mode
# Process video file
$ bahlib video input.mp4 -o output.mp4

# With custom settings
$ bahlib video input.mp4 -o out.mp4 \
    --blur 51 --confidence 0.4

# Real-time webcam
$ bahlib webcam

# Python API
from bahlib.video import anonymize_video

anonymize_video(
    "input.mp4",
    "output.mp4",
    blur_strength=51
)
Example

See It in Action

Multiple anonymization methods available

Gaussian Blur --method blur

Original
Before
โ†’
Blurred
After
bahlib image photo.jpg -o out.jpg

Pixelate + Blackbar --method all

Original
Before
โ†’
Pixelated with blackbar
After
bahlib image photo.jpg -o out.jpg --method all