Skip to main content

Face anonymization utilities (blur faces in images & video)

Project description

faceghost - face anonymization for image & videos

faceghost is a lightweight Python package for automatically detecting and anonymizing faces in images and videos.

It uses a YOLO-based face detector and offers multiple blur and pixelation methods, making it ideal for datasets, research, and privacy-sensitive media.

Original Frame faceghost output (using default options)
Original Frame faceghost Output

Features

  • Detects faces using a YOLO-based detector (yolo_infer.predict) and applies blurring only to detected face regions.
  • Multiple blur modes:
    • gaussian — oval Gaussian blur (default)
    • gaussian_sqr — square Gaussian blur
    • mossaic — pixelation / mosaic blur
    • median — median filter blur
  • Works on a single image, a directory of images, or a full video.
  • CLI-ready and simple Python API for embedding in other projects.
  • Safe fallback handling (validates inputs, ensures kernel size is a positive odd integer).

Installation

faceghost supports all commonly operating system like linux, windows, mac. It can be used both on CLI like bash, shell, powershell.

Intallation of faceghost can be done through pip

pip install faceghost

Quick CLI Usage

Process a single Image:

faceghost --img /path/to/photo.jpg

Process a directory of images (saves blurred images into /folder_specified/face_anonymized/):

faceghost --dir /path/to/images --kernel 51 --blur mossaic

Process a video (outputs basename_blurred.mp4 in the current working directory):

faceghost --vid /path/to/video.mp4 --kernel 41 --blur gaussian_sqr

CLI argument notes

  • --img / --vid / --dir — supply one of these (mutually exclusive).

  • --kernel — blur size (default 39). The package enforces a positive odd kernel; if you pass an even number it will be rounded up to the next odd integer. For Gaussian-style blurs the kernel is used as a (k,k) tuple; for mosaic/median blurs it is used as a single integer magnitude.

  • --blur — one of gaussian, gaussian_sqr, mossaic, median.

Python API

You can use the function directly in Python:

from faceghost import run_on_image, run_on_dir, run_on_video

# Single image
run_on_image("photo.jpg", blur_name="mossaic", kernel_val=51, output_path="outdir")

# Directory
run_on_dir("data/images", blur_name="gaussian", kernel_val=39)

# Video
run_on_video("input.mp4", blur_name="gaussian_sqr", kernel_val=41)

Important internal helpers (useful if you integrate the pipeline):

  • select_blur_function(blur_name) — returns the blur function and whether it expects a tuple or int kernel.
  • process_frame(frame, detect_results, blur_fn, kernel_tuple, kernel_int) — applies the selected blur to the provided frame using detection results.
  • The detection step is performed by calling predict(frame) from the yolo_infer module; this function must return the detections in the format the blur functions expect.

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

faceghost-0.1.5.tar.gz (10.6 MB view details)

Uploaded Source

Built Distribution

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

faceghost-0.1.5-py3-none-any.whl (10.6 MB view details)

Uploaded Python 3

File details

Details for the file faceghost-0.1.5.tar.gz.

File metadata

  • Download URL: faceghost-0.1.5.tar.gz
  • Upload date:
  • Size: 10.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for faceghost-0.1.5.tar.gz
Algorithm Hash digest
SHA256 44a423d795e95bd21e2e1efc711d32a7e2b3a571eadcdbae0215435cafc35849
MD5 bb5b56c8aa413898c0235bd1262e575a
BLAKE2b-256 5db8ce3b979a3a7ae8e8d600a476d6f1509487464081a902ee4f70578a416d2f

See more details on using hashes here.

File details

Details for the file faceghost-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: faceghost-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 10.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for faceghost-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 152ccd879b184b5b1398c770cbbcf950b49ce9df852f629abb6b1fe69c4bcb5a
MD5 b43f040ba80da1834d7e25d9aeaea169
BLAKE2b-256 7c9002850c8f309f78c937f603522d248d50f0fefe6f198cbb66e9493d2681ee

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