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)
Everything you need to protect identities in images and videos
All face detection and blurring happens entirely on your machine. No cloud uploads, no API calls, complete data sovereignty.
Feathered elliptical masks create natural-looking blur that seamlessly blends with surrounding pixels.
Advanced tiled detection algorithm finds faces of all sizes, even in crowded group photos with small faces.
Process video files frame-by-frame or run real-time anonymization on live webcam feeds.
Anonymize entire directories of images with a single command, with progress tracking and recursive support.
Use from the command line for quick tasks, or integrate the Python API into your applications.
pip install bahlib
from bahlib import Bahlib
result = Bahlib().anonymize("photo.jpg")
Master the library with just three concepts
Integrate face anonymization into your Python applications with a clean, intuitive API.
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")
Use bahlib directly from your terminal for quick anonymization tasks.
# 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
Anonymize faces in video files or live webcam feeds with frame-by-frame detection.
# 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 )
Multiple anonymization methods available