randaugment
anomaly_match.datasets.augmentation.randaugment
¶
RandAugment data augmentation implementation.
RandAugment(n, m)
¶
Random augmentation pipeline implementation.
Randomly applies a series of image transformations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of augmentation operations to apply |
required |
m
|
int
|
Magnitude parameter [0, 30] (deprecated) |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
n |
Number of augmentation operations to apply |
|
m |
Magnitude parameter (deprecated) |
|
augment_list |
List of available augmentation operations |
Source code in anomaly_match/datasets/augmentation/randaugment.py
__call__(img)
¶
Apply random augmentations to the input image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Image
|
PIL Image to be augmented |
required |
Returns:
| Type | Description |
|---|---|
Image
|
Augmented PIL Image |
Source code in anomaly_match/datasets/augmentation/randaugment.py
AutoContrast(img, _)
¶
Apply automatic contrast to the image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Image
|
PIL Image to be processed |
required |
Returns:
| Type | Description |
|---|---|
Image
|
PIL Image with automatic contrast applied |
Source code in anomaly_match/datasets/augmentation/randaugment.py
Brightness(img, v)
¶
Adjust the brightness of the image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Image
|
PIL Image to be processed |
required |
v
|
float
|
Brightness factor (must be >= 0.0) |
required |
Returns:
| Type | Description |
|---|---|
Image
|
PIL Image with adjusted brightness |
Source code in anomaly_match/datasets/augmentation/randaugment.py
Color(img, v)
¶
Adjust the color saturation of the image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Image
|
PIL Image to be processed |
required |
v
|
float
|
Color saturation factor (must be >= 0.0) |
required |
Returns:
| Type | Description |
|---|---|
Image
|
PIL Image with adjusted color saturation |
Source code in anomaly_match/datasets/augmentation/randaugment.py
Contrast(img, v)
¶
Adjust the contrast of the image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Image
|
PIL Image to be processed |
required |
v
|
float
|
Contrast factor (must be >= 0.0) |
required |
Returns:
| Type | Description |
|---|---|
Image
|
PIL Image with adjusted contrast |
Source code in anomaly_match/datasets/augmentation/randaugment.py
Equalize(img, _)
¶
Equalize the histogram of the image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Image
|
PIL Image to be processed |
required |
Returns:
| Type | Description |
|---|---|
Image
|
PIL Image with equalized histogram |
Source code in anomaly_match/datasets/augmentation/randaugment.py
Identity(img, v)
¶
Return the image unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Image
|
PIL Image to be processed |
required |
v
|
float
|
Unused parameter |
required |
Returns:
| Type | Description |
|---|---|
Image
|
The original PIL Image |
Posterize(img, v)
¶
Reduce the number of bits for each color channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Image
|
PIL Image to be processed |
required |
v
|
float
|
Number of bits to keep for each channel (range [4, 8]) |
required |
Returns:
| Type | Description |
|---|---|
Image
|
PIL Image with reduced color channels |
Source code in anomaly_match/datasets/augmentation/randaugment.py
Rotate(img, v)
¶
Rotate the image by v degrees.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Image
|
PIL Image to be processed |
required |
v
|
float
|
Rotation angle in degrees (range [-30, 30]) |
required |
Returns:
| Type | Description |
|---|---|
Image
|
Rotated PIL Image |
Source code in anomaly_match/datasets/augmentation/randaugment.py
Sharpness(img, v)
¶
Adjust the sharpness of the image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Image
|
PIL Image to be processed |
required |
v
|
float
|
Sharpness factor (must be >= 0.0) |
required |
Returns:
| Type | Description |
|---|---|
Image
|
PIL Image with adjusted sharpness |
Source code in anomaly_match/datasets/augmentation/randaugment.py
ShearX(img, v)
¶
Apply horizontal shear to the image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Image
|
PIL Image to be processed |
required |
v
|
float
|
Shear factor (range [-0.3, 0.3]) |
required |
Returns:
| Type | Description |
|---|---|
Image
|
PIL Image with horizontal shear applied |
Source code in anomaly_match/datasets/augmentation/randaugment.py
ShearY(img, v)
¶
Apply vertical shear to the image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Image
|
PIL Image to be processed |
required |
v
|
float
|
Shear factor (range [-0.3, 0.3]) |
required |
Returns:
| Type | Description |
|---|---|
Image
|
PIL Image with vertical shear applied |
Source code in anomaly_match/datasets/augmentation/randaugment.py
TranslateX(img, v)
¶
Translate the image horizontally by a percentage of its width.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Image
|
PIL Image to be processed |
required |
v
|
float
|
Translation factor as a percentage of image width (range [-0.3, 0.3]) |
required |
Returns:
| Type | Description |
|---|---|
Image
|
PIL Image with horizontal translation applied |
Source code in anomaly_match/datasets/augmentation/randaugment.py
TranslateY(img, v)
¶
Translate the image vertically by a percentage of its height.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Image
|
PIL Image to be processed |
required |
v
|
float
|
Translation factor as a percentage of image height (range [-0.3, 0.3]) |
required |
Returns:
| Type | Description |
|---|---|
Image
|
PIL Image with vertical translation applied |
Source code in anomaly_match/datasets/augmentation/randaugment.py
Solarize(img, v)
¶
Invert all pixel values above a threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Image
|
PIL Image to be processed |
required |
v
|
float
|
Threshold for solarization (range [0, 256]) |
required |
Returns:
| Type | Description |
|---|---|
Image
|
Solarized PIL Image |
Source code in anomaly_match/datasets/augmentation/randaugment.py
Cutout(img, v)
¶
Apply cutout augmentation to the image.
Creates a square mask at a random location in the image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Image | ndarray
|
PIL Image or numpy array to be processed |
required |
v
|
float
|
Size of the cutout as a percentage of image size (range [0.0, 0.5]) |
required |
Returns:
| Type | Description |
|---|---|
Image | ndarray
|
Image with cutout applied |
Source code in anomaly_match/datasets/augmentation/randaugment.py
CutoutAbs(img, v)
¶
Apply cutout augmentation with absolute size to the image.
Creates a square mask at a random location in the image with specified absolute size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Image
|
PIL Image to be processed |
required |
v
|
float
|
Absolute size of the cutout in pixels |
required |
Returns:
| Type | Description |
|---|---|
Image
|
PIL Image with cutout applied |
Source code in anomaly_match/datasets/augmentation/randaugment.py
augment_list()
¶
Return a list of available augmentation operations with their value ranges.
Returns:
| Type | Description |
|---|---|
list[tuple]
|
List of tuples (operation, min_value, max_value) for each augmentation |