albumentations.augmentations.text.transforms
Transforms for text rendering and augmentation on images. This module provides transforms for adding and manipulating text on images, including text augmentation techniques like word insertion, deletion, and swapping.
Members
- classTextImage
TextImageclass
TextImage(
font_path: str | Path,
stopwords: tuple[str, ...] = ('the', 'is', 'in', 'at', 'of'),
augmentations: tuple[Literal['insertion', 'swap', 'deletion'] | None, ...] = (None,),
fraction_range: tuple[float, float] = (1.0, 1.0),
font_size_fraction_range: tuple[float, float] = (0.8, 0.9),
font_color: tuple[float, ...] = (0, 0, 0),
clear_bg: bool = False,
metadata_key: str = textimage_metadata,
p: float = 0.5
)
Apply text rendering transformations on images. This class supports rendering text directly onto images using a variety of configurations, such as custom fonts, font sizes, colors, and augmentation methods. The text can be placed inside specified bounding boxes.
Parameters
Name | Type | Default | Description |
---|---|---|---|
font_path | One of:
| - | Path to the font file to use for rendering text. |
stopwords | tuple[str, ...] | ('the', 'is', 'in', 'at', 'of') | List of stopwords for text augmentation. |
augmentations | One of:
| (None,) | List of text augmentations to apply. None: text is printed as is "insertion": insert random stop words into the text. "swap": swap random words in the text. "deletion": delete random words from the text. |
fraction_range | tuple[float, float] | (1.0, 1.0) | Range for selecting a fraction of bounding boxes to modify. |
font_size_fraction_range | tuple[float, float] | (0.8, 0.9) | Range for selecting the font size as a fraction of bounding box height. |
font_color | tuple[float, ...] | (0, 0, 0) | Font color as RGB values (e.g., (0, 0, 0) for black). |
clear_bg | bool | False | Whether to clear the background before rendering text. |
metadata_key | str | textimage_metadata | Key to access metadata in the parameters. |
p | float | 0.5 | Probability of applying the transform. |
References
- doc-augmentation: https://github.com/danaaubakirova/doc-augmentation