Automatically detect and blur background faces in images and videos using state-of-the-art AI models.
Vanish combines Florence-2 for intelligent face detection with SAM2 for precise segmentation, enabling privacy-preserving content creation with a single command.
- Smart Speaker Detection — Automatically identifies and preserves main speakers while blurring background faces
- Precise Segmentation — Uses SAM2 for pixel-perfect face masking (no ugly rectangles)
- Image & Video Support — Process single images or entire videos
- Adjustable Pixelation — Control blur intensity with customizable pixel size
- GPU Accelerated — Supports CUDA, MPS (Apple Silicon), and CPU
# Clone the repository
git clone https://github.com/BradenStitt/Vanish.git
cd Vanish
# Install dependencies
pip install -r requirements.txt
# Install SAM2 (required)
pip install git+https://github.com/facebookresearch/segment-anything-2.gitCommand Line:
# Process an image
python vanish.py input.jpg output.jpg
# Process a video
python vanish.py input.mp4 output.mp4
# Adjust pixelation intensity
python vanish.py input.jpg output.jpg --pixel-size 15
# Blur ALL faces (including main speakers)
python vanish.py input.jpg output.jpg --blur-allPython API:
from vanish import vanish, vanish_video
# Process image
result = vanish("input.jpg", "output.jpg", pixel_size=10)
# Process video
vanish_video("input.mp4", "output.mp4", pixel_size=10)
# Blur all faces (no speaker exclusion)
result = vanish("input.jpg", "output.jpg", exclude_speakers=False)Jupyter Notebook:
Open vanish.ipynb for an interactive walkthrough with visualizations.
Input Image/Video
│
▼
┌───────────────────┐
│ Florence-2 │ ← Object detection: finds all "human face" instances
│ (Detection) │ ← Phrase grounding: identifies "main speaker" faces
└───────────────────┘
│
▼
┌───────────────────┐
│ Filter Faces │ ← Excludes main speakers from blur list
└───────────────────┘
│
▼
┌───────────────────┐
│ SAM2 │ ← Generates precise segmentation masks
│ (Segmentation) │ from bounding boxes
└───────────────────┘
│
▼
┌───────────────────┐
│ Pixelation │ ← Applies blur effect only to masked regions
└───────────────────┘
│
▼
Output Image/Video
- Python 3.10+
- PyTorch 2.0+
- CUDA GPU recommended (also works on Apple Silicon MPS or CPU)
- ~4GB VRAM for inference
- Content Creation — Blur bystanders in vlogs and street footage
- Privacy Compliance — Anonymize faces for GDPR/CCPA compliance
- Security Footage — Redact identities while preserving context
- Social Media — Protect privacy of people in background
MIT License - see LICENSE for details.
- Florence-2 by Microsoft
- SAM2 by Meta AI