py123d_detection.torch.models.common.grid_mask

Classes

GridMask(use_h, use_w[, rotate, offset, ...])

Grid masking for data augmentation (pure PyTorch, no NumPy/PIL).

class py123d_detection.torch.models.common.grid_mask.GridMask(use_h, use_w, rotate=1, offset=False, ratio=0.5, mode=0, prob=1.0)[source]

Bases: Module

Grid masking for data augmentation (pure PyTorch, no NumPy/PIL).

set_prob(epoch, max_epoch)[source]

Ramp the masking probability linearly over training.

The original PETR schedule starts at nothing and reaches the configured probability at the last epoch, so early training sees whole images. Nothing in this package calls this yet.

forward(x)[source]

Mask a batch of camera images, (B * N_cams, C, H, W).

A no-op outside training, and on the fraction of samples the probability leaves alone.