data_juicer.ops.mapper.image_blur_mapper module

class data_juicer.ops.mapper.image_blur_mapper.ImageBlurMapper(p: float = 0.2, blur_type: str = 'gaussian', radius: float = 2, save_dir: str = None, *args, **kwargs)[源代码]

基类:Mapper

Blurs images in the dataset with a specified probability and blur type.

This operator blurs images using one of three types: mean, box, or Gaussian. The probability of an image being blurred is controlled by the p parameter. The blur effect is applied using a kernel with a specified radius. Blurred images are saved to a directory, which can be specified or defaults to the input directory. If the save directory is not provided, the DJ_PRODUCED_DATA_DIR environment variable can be used to set it. The operator ensures that the blur type is one of the supported options and that the radius is non-negative.

__init__(p: float = 0.2, blur_type: str = 'gaussian', radius: float = 2, save_dir: str = None, *args, **kwargs)[源代码]

Initialization method.

参数:
  • p -- Probability of the image being blurred.

  • 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