mlvbench.stimuli.transforms¶
Image transforms.
BinarizeSegmentation
¶
Threshold the segmentation map in a sample dict to the values 0 and 1.
Non-segmentation values are passed through unchanged.
__call__(sample)
¶
Binarize the segmentation in the sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
dict[str, str | Tensor]
|
A dictionary with a "segmentation" tensor. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str | Tensor]
|
A new dictionary where "segmentation" is a |
CenterCrop
¶
Crop a single square at the center.
The crop size is the shorter dimension of the input image.
__call__(sample)
¶
Transform the given sample.
Resize
¶
ToNumpy
¶
Convert tensors in a sample dict to numpy arrays.
ToTensor
¶
Convert PIL Images in a sample dict to tensors.
Images with shape (H, W) are converted to (1, H, W). Images with shape
(H, W, C) are converted to (C, H, W). The "image" key is additionally
converted from grayscale to RGB if it has a single channel.
Non-image values are passed through unchanged.
__call__(sample)
¶
Convert PIL Images in the sample to tensors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
dict[str, str | Image]
|
A dictionary whose values may be PIL Images or other types. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str | Tensor]
|
A new dictionary with PIL Images replaced by |