hezar.preprocessors.image_processor module

class hezar.preprocessors.image_processor.ImageProcessor(config: ImageProcessorConfig, **kwargs)[source]

Bases: Preprocessor

General image processor to perform sequential transforms on a list of images.

image_processor_config_file = 'image_processor_config.yaml'
classmethod load(hub_or_local_path, subfolder: str | None = None, config_filename: str | None = None, cache_dir: str | None = None, **kwargs) ImageProcessor[source]

Load an ImageProcessor from a specified path.

Parameters:
  • hub_or_local_path – Path to the hub or local location.

  • subfolder (str) – Subfolder within the specified path.

  • config_filename (str) – Configuration filename.

  • cache_dir – Path to cache directory

  • **kwargs – Additional keyword arguments.

Returns:

Loaded image processor instance.

Return type:

ImageProcessor

preprocessor_subfolder = 'preprocessor'
push_to_hub(repo_id, subfolder=None, commit_message=None, private=None, config_filename=None)[source]

Push the ImageProcessor configuration to the hub.

Parameters:
  • repo_id – ID of the repository.

  • subfolder (str) – Subfolder within the repository.

  • commit_message (str) – Commit message.

  • private (bool) – Flag indicating whether the repository is private.

  • config_filename (str) – Configuration filename.

required_backends: List[str | Backends] = [Backends.PILLOW]
save(path, subfolder=None, config_filename=None)[source]

Save the ImageProcessor configuration.

Parameters:
  • path – Path to save the configuration.

  • subfolder (str) – Subfolder within the specified path.

  • config_filename (str) – Configuration filename.

class hezar.preprocessors.image_processor.ImageProcessorConfig(mean: List[float] | None = None, std: List[float] | None = None, rescale: float | None = None, resample: int | None = None, size: Tuple[int, int] | None = None, mirror: bool = False, gray_scale: bool = False)[source]

Bases: PreprocessorConfig

Configuration class for the ImageProcessor.

gray_scale: bool = False
mean: List[float] = None
mirror: bool = False
name: str = 'image_processor'
resample: int = None
rescale: float = None
size: Tuple[int, int] = None
std: List[float] = None