crumpets.torch.randomizer module

class crumpets.torch.randomizer.Randomizer(*args: Any, **kwargs: Any)[source]

Bases: torch.nn.

Given a network (or in general, some pytorch module), it is wrapped around the nets forward pass. If the randomizer’s forward function is invoked, it first randomizes the image in the sample dictionary. That means it basically works like randomize_image(), which is usually applied to the image in one of the workers. The major difference here is that all augmentations are gpu powered, and thus faster. Also not all augmentation operations are supported. The randomizer does not rotate or resize. The values used for augmenting are picked out of the dictionary. Therefore the sample dictionary must contain these. Usually crumpets worker take care of that.

Parameters

net – some network the randomizer shall be wrapped around

cpu()[source]
cuda(device_id=None)[source]
forward(sample, *args, **kwargs)[source]

Applies different randomizing augmentations to input images and then forwards result through net, if given.

Parameters

sample

dictonary with {“image”: Tensor of shape n,c,h,w,

”augmentation”: list of augmentation parameters per image in batch}

Returns

modified dictionary with randomized image and network modified entries