RandomCropWithMinPositivePixels

class mfai.pytorch.transforms.RandomCropWithMinPositivePixels(crop_size=(512, 512), min_positive_percentage=15.0, tries=5)[source]

Bases: object

Randomly crops an input image to a 512x512 image, with min 15% of positive pixels. The random crop is performed 5 times at the most, or until an image with 15% of positive pixels is found. If such an image is not found, it returns the image with the most positive pixels from the 5 images cropped.

input is a tuple sample with x and y x shape (C, H, W) y shape (1, H, W)

Parameters:
get_crop(y)[source]
Return type:

tuple[int, int]

Parameters:

y (Tensor)

get_one_crop(y)[source]
Return type:

tuple[int, int, float]

Parameters:

y (Tensor)