explaingit

jungbae009/faceblur-anti-ai

19PythonAudience · developerComplexity · 3/5ActiveSetup · moderate

TLDR

A single Python file that auto-blurs faces in images and video using a YOLO person detector with fail-closed defaults that over-blur rather than leak a raw frame.

Mindmap

mindmap
  root((faceblur-anti-ai))
    Inputs
      Image or video file
      YOLO weights path
      OpenCV frame array
    Outputs
      Blurred media file
      Blurred frame array
      Detection metadata
    Use Cases
      Anonymize uploaded photos
      Strip faces from video
      Add a privacy filter to a pipeline
    Tech Stack
      Python
      Ultralytics
      OpenCV
      NumPy

Things people build with this

USE CASE 1

Blur faces in user-uploaded photos before storing them

USE CASE 2

Anonymize a video file frame by frame for a privacy preserving dataset

USE CASE 3

Add a fail-closed blur step inside an existing OpenCV pipeline

USE CASE 4

Drop in a single file privacy guard into a Python project without packaging overhead

Tech stack

PythonUltralyticsOpenCVNumPyYOLO

Getting it running

Difficulty · moderate Time to first run · 30min

You must supply your own YOLO person detection weights, none ship with the file.

In plain English

faceblur-anti-ai is a single Python file you drop into a project to automatically blur faces in images and video for privacy reasons. The README describes the workflow simply: a YOLO person-detection model is used to find people in a frame, and for each accepted detection the module works out a conservative face or head region and applies a blur over it before any media is saved or returned. The project is shipped as one file called faceblur_anti_ai.py, with no package layout, no PyPI release, and no build configuration. You copy the file into your project and import it directly. It needs Python 3.9 or newer plus three libraries: ultralytics, opencv-python and numpy. Model weights for YOLO are not included, and the README is explicit that the user must supply weights suited to their own camera or media domain. The basic usage is to create a FaceBlurAntiAI object with a YOLO model path, then call blur_image, blur_video or blur_frame. blur_image reads an input file, applies the blur, and writes the result to an output path. blur_video does the same for a video, processing every frame and writing a new file without audio in version 0.1. blur_frame takes a single OpenCV-style frame array, always works on a copy, and returns the blurred frame along with metadata. A lot of the README is about what the module calls fail-closed behaviour: defaults that lean towards over-blurring rather than leaking a raw frame. If people are detected, every derived head region is blurred. If no person is detected, the whole frame is blurred by default. If YOLO inference fails, the default is to raise an error rather than return raw pixels; a setting can change that to a full-frame blur instead. Files are first written to a temporary location and then moved, overwriting is off by default, and input and output paths must be different. A no_person_policy of allow is available for workflows where unblurred passthrough is acceptable when no person is found. The README is honest about limits. The module only supports YOLO models, not OpenCV DNN, MediaPipe, Haar cascades or cloud APIs. Standard YOLO person models do not find exact faces, so the face region is derived from the upper part of each person box and may miss side or back views. Detection quality depends on the chosen weights, video audio is not preserved, and the module does not claim to be a legal compliance solution. It also avoids network calls, shell commands, telemetry and raw frame logging.

Copy-paste prompts

Prompt 1
Copy faceblur_anti_ai.py into my project and blur every face in input.mp4 using a YOLO person model
Prompt 2
Process a single OpenCV frame with blur_frame and print the returned detection metadata
Prompt 3
Configure no_person_policy to allow passthrough when no person is detected and explain the tradeoff
Prompt 4
Swap the YOLO weights for a domain-specific model and tell me which detection knobs to tune
Prompt 5
Add audio preservation to blur_video by piping the original audio track back into the output file
Open on GitHub → Explain another repo

Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.