DAPPER (Document Analysis, Processing, and Pattern Extraction Repository)
Statistical Learning Final Project for Document Classification
 
Loading...
Searching...
No Matches
classification.data.augmentor.Augmentor Class Reference

Image augmentation class for document classification. More...

Collaboration diagram for classification.data.augmentor.Augmentor:
Collaboration graph

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
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __init__()

classification.data.augmentor.Augmentor.__init__ (   self,
int   width = 768,
int   height = 992,
Optional[str]   tesseract_cmd = None 
)

Constructor for Augmentor class.

Parameters
widthTarget width for resized images
heightTarget height for resized images
tesseract_cmdPath to tesseract executable (if not in PATH)

Member Function Documentation

◆ augment_image()

Image.Image classification.data.augmentor.Augmentor.augment_image (   self,
Image.Image  image 
)

Applies augmentation transformations to an image.

Parameters
imagePIL Image to augment
Returns
Augmented PIL Image

◆ create_augmented_rows()

pd.DataFrame classification.data.augmentor.Augmentor.create_augmented_rows (   self,
pd.DataFrame  df,
int   factor = 2 
)

Creates augmented versions of images in a DataFrame.

Parameters
dfDataFrame containing image data
factorNumber of augmented versions to create per image
Returns
DataFrame containing original and augmented images

◆ perform_ocr()

Dict[str, Any] classification.data.augmentor.Augmentor.perform_ocr (   self,
Image.Image  image,
Optional[str]   config = None 
)

Performs OCR on a single image.

Parameters
imagePIL Image to process with OCR
configOptional configuration for tesseract OCR
Returns
Dictionary containing OCR results
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

◆ process_ocr()

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.

Parameters
dfDataFrame containing image data
max_workersNumber of parallel workers for OCR processing
configOptional configuration for tesseract OCR
Returns
DataFrame with added OCR results
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

◆ resize_image()

Image.Image classification.data.augmentor.Augmentor.resize_image (   self,
Image.Image  image,
bool   augment = False 
)

Resizes an image to the target dimensions.

Parameters
imagePIL Image to resize
augmentBoolean flag to apply augmentation after resizing
Returns
Resized (and optionally augmented) PIL Image

Member Data Documentation

◆ height

classification.data.augmentor.Augmentor.height

◆ pil_transforms

classification.data.augmentor.Augmentor.pil_transforms

◆ tensor_transforms

classification.data.augmentor.Augmentor.tensor_transforms

◆ width

classification.data.augmentor.Augmentor.width

The documentation for this class was generated from the following file: