Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Datajuicer Data juicer ImageFaceBlurMapper

From Leeroopedia
Knowledge Sources
Domains Data_Processing, Mapping
Last Updated 2026-02-14 16:00 GMT

Overview

Concrete tool for detecting and blurring faces in images for anonymization provided by Data-Juicer.

Description

ImageFaceBlurMapper is a mapper operator that uses an OpenCV Haar cascade classifier (default: haarcascade_frontalface_alt.xml) to detect face regions in images and applies a configurable blur type (mean, box, or Gaussian) with adjustable radius to each detected face bounding box. The blurred images are saved to a configurable output directory. Supports additional OpenCV detection parameters like scaleFactor, minNeighbors, minSize, and maxSize.

Usage

Use when you need to anonymize faces in training images for compliance with data protection regulations and for creating datasets where facial identity should not be exposed.

Code Reference

Source Location

Signature

@OPERATORS.register_module("image_face_blur_mapper")
class ImageFaceBlurMapper(Mapper):
    def __init__(self,
                 cv_classifier: str = "",
                 blur_type: str = "gaussian",
                 radius: NonNegativeFloat = 2,
                 save_dir: str = None,
                 *args, **kwargs):

Import

from data_juicer.ops.mapper.image_face_blur_mapper import ImageFaceBlurMapper

I/O Contract

Inputs

Name Type Required Description
cv_classifier str No OpenCV classifier path for face detection; defaults to haarcascade_frontalface_alt.xml
blur_type str No Type of blur kernel: mean, box, or gaussian; defaults to "gaussian"
radius NonNegativeFloat No Radius of blur kernel, defaults to 2
save_dir str No Directory to store generated images; if not specified, saves in same directory as input

Outputs

Name Type Description
samples Dict Transformed samples with face-blurred image paths updated

Usage Examples

process:
  - image_face_blur_mapper:
      blur_type: "gaussian"
      radius: 2

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment