Image augmentation class for document classification. More...

Public Member Functions | |
| __init__ (self, int width=768, int height=992, Optional[str] tesseract_cmd=None) | |
| Constructor for Augmentor class. | |
| Image.Image | resize_image (self, Image.Image image, bool augment=False) |
| Resizes an image to the target dimensions. | |
| Image.Image | augment_image (self, Image.Image image) |
| Applies augmentation transformations to an image. | |
| pd.DataFrame | create_augmented_rows (self, pd.DataFrame df, int factor=2) |
| Creates augmented versions of images in a DataFrame. | |
| Dict[str, Any] | perform_ocr (self, Image.Image image, Optional[str] config=None) |
| Performs OCR on a single image. | |
| pd.DataFrame | process_ocr (self, pd.DataFrame df, int max_workers=4, Optional[str] config=None) |
| Process a DataFrame with OCR in parallel. | |
Public Attributes | |
| width | |
| height | |
| pil_transforms | |
| tensor_transforms | |
Image augmentation class for document classification.
This class provides methods to apply various image augmentation techniques to document images. It supports geometric transformations, color adjustments, and noise addition to create variations of existing images for improved model training.
This we can do to messa up image Patching Diffusion Color Rotation Jigsaw Resolution
| classification.data.augmentor.Augmentor.__init__ | ( | self, | |
| int | width = 768, |
||
| int | height = 992, |
||
| Optional[str] | tesseract_cmd = None |
||
| ) |
Constructor for Augmentor class.
| width | Target width for resized images |
| height | Target height for resized images |
| tesseract_cmd | Path to tesseract executable (if not in PATH) |
| Image.Image classification.data.augmentor.Augmentor.augment_image | ( | self, | |
| Image.Image | image | ||
| ) |
Applies augmentation transformations to an image.
| image | PIL Image to augment |
| pd.DataFrame classification.data.augmentor.Augmentor.create_augmented_rows | ( | self, | |
| pd.DataFrame | df, | ||
| int | factor = 2 |
||
| ) |
Creates augmented versions of images in a DataFrame.
| df | DataFrame containing image data |
| factor | Number of augmented versions to create per image |
| Dict[str, Any] classification.data.augmentor.Augmentor.perform_ocr | ( | self, | |
| Image.Image | image, | ||
| Optional[str] | config = None |
||
| ) |
Performs OCR on a single image.
| image | PIL Image to process with OCR |
| config | Optional configuration for tesseract OCR |
Performs OCR on a single image and returns the extracted text and metadata.
Args:
image: PIL Image to process with OCR
config: Optional configuration for tesseract OCR
Returns:
Dictionary containing OCR results including:
- text: Extracted text
- confidence: Confidence scores
- boxes: Bounding boxes for detected text regions
| pd.DataFrame classification.data.augmentor.Augmentor.process_ocr | ( | self, | |
| pd.DataFrame | df, | ||
| int | max_workers = 4, |
||
| Optional[str] | config = None |
||
| ) |
Process a DataFrame with OCR in parallel.
| df | DataFrame containing image data |
| max_workers | Number of parallel workers for OCR processing |
| config | Optional configuration for tesseract OCR |
Process all images in a DataFrame with OCR in parallel.
Args:
df: DataFrame containing image data
max_workers: Number of parallel workers for OCR processing
config: Optional configuration for tesseract OCR
Returns:
DataFrame with added OCR results
| Image.Image classification.data.augmentor.Augmentor.resize_image | ( | self, | |
| Image.Image | image, | ||
| bool | augment = False |
||
| ) |
Resizes an image to the target dimensions.
| image | PIL Image to resize |
| augment | Boolean flag to apply augmentation after resizing |
| classification.data.augmentor.Augmentor.height |
| classification.data.augmentor.Augmentor.pil_transforms |
| classification.data.augmentor.Augmentor.tensor_transforms |
| classification.data.augmentor.Augmentor.width |