data_juicer.ops.mapper.video_face_blur_mapper module

class data_juicer.ops.mapper.video_face_blur_mapper.VideoFaceBlurMapper(cv_classifier: str = '', blur_type: str = 'gaussian', radius: float = 2, save_dir: str = None, *args, **kwargs)[源代码]

基类:Mapper

Mapper to blur faces detected in videos.

This operator uses an OpenCV classifier for face detection and applies a specified blur type to the detected faces. The default classifier is 'haarcascade_frontalface_alt.xml'. Supported blur types include 'mean', 'box', and 'gaussian'. The radius of the blur kernel can be adjusted. If a save directory is not provided, the processed videos will be saved in the same directory as the input files. The DJ_PRODUCED_DATA_DIR environment variable can also be used to specify the save directory.

__init__(cv_classifier: str = '', blur_type: str = 'gaussian', radius: float = 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 video 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