transforms
anomaly_match.image_processing.transforms
¶
Image transform pipelines for weak, strong, and prediction augmentation.
NumpyToTensor
¶
Convert numpy array to torch tensor for N-channel images.
Handles HWC to CHW conversion for arbitrary channel counts.
__call__(img)
¶
Convert numpy array (H, W, C) to tensor (C, H, W).
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Image tensor in CHW format. |
Source code in anomaly_match/image_processing/transforms.py
NumpyRandomHorizontalFlip(p=0.5)
¶
Random horizontal flip for numpy arrays.
Source code in anomaly_match/image_processing/transforms.py
__call__(img)
¶
Apply random horizontal flip to the image.
Returns:
| Type | Description |
|---|---|
ndarray | Tensor
|
Image with random horizontal flip applied. |
Source code in anomaly_match/image_processing/transforms.py
NumpyRandomTranslate(translate=(0, 0.125))
¶
Random translation for numpy arrays.
Source code in anomaly_match/image_processing/transforms.py
__call__(img)
¶
Apply random translation to the image.
Returns:
| Type | Description |
|---|---|
ndarray | Tensor
|
Image with random translation applied. |
Source code in anomaly_match/image_processing/transforms.py
get_weak_transforms(num_channels=3)
¶
Get weak augmentation transforms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_channels
|
int
|
Number of image channels (3 for RGB, other for multispectral) |
3
|
Returns:
| Type | Description |
|---|---|
Compose
|
torchvision.transforms.Compose: transforms. |
Source code in anomaly_match/image_processing/transforms.py
get_prediction_transforms(num_channels=3)
¶
Get the standard image transform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_channels
|
int
|
Number of image channels (3 for RGB, other for multispectral) |
3
|
Returns:
| Type | Description |
|---|---|
Compose
|
torchvision.transforms.Compose: transforms. |
Source code in anomaly_match/image_processing/transforms.py
get_strong_transforms(num_channels=3)
¶
Get strong augmentations for FixMatch.
Includes RandAugment followed by the same transforms as weak (ToTensor, RandomHorizontalFlip, RandomAffine).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_channels
|
int
|
Number of image channels (3 for RGB, other for multispectral) |
3
|
Returns:
| Type | Description |
|---|---|
Compose
|
torchvision.transforms.Compose: Strong augmentation pipeline. |