data_juicer.ops.mapper.image_face_blur_mapper module

class data_juicer.ops.mapper.image_face_blur_mapper.ImageFaceBlurMapper(cv_classifier: str = '', blur_type: str = 'gaussian', radius: Annotated[float, Ge(ge=0)] = 2, save_dir: str = None, *args, **kwargs)[源代码]

基类:Mapper

Mapper to blur faces detected in images.

This operator uses an OpenCV classifier to detect faces in images and applies a specified blur type to the detected face regions. The blur types supported are 'mean', 'box', and 'gaussian'. The radius of the blur kernel can be adjusted. If no save directory is provided, the modified images will be saved in the same directory as the input files.

__init__(cv_classifier: str = '', blur_type: str = 'gaussian', radius: Annotated[float, Ge(ge=0)] = 2, save_dir: str = None, *args, **kwargs)[源代码]

Initialization method.

参数:
  • cv_classifier -- OpenCV classifier path for face detection. By default, we will use 'haarcascade_frontalface_alt.xml'.

  • blur_type -- Type of blur kernel, including ['mean', 'box', 'gaussian'].

  • radius -- Radius of blur kernel.

  • save_dir -- The directory where generated image files will be stored. If not specified, outputs will be saved in the same directory as their corresponding input files. This path can alternatively be defined by setting the DJ_PRODUCED_DATA_DIR environment variable.

  • args -- extra args

  • kwargs -- extra args

process_single(sample, context=False)[源代码]

For sample level, sample --> sample

参数:

sample -- sample to process

返回:

processed sample