Shortcuts

ResizeMix

class mmpretrain.models.utils.batch_augments.ResizeMix(alpha, lam_min=0.1, lam_max=0.8, interpolation='bilinear', cutmix_minmax=None, correct_lam=True)[源代码]

ResizeMix Random Paste layer for a batch of data.

The ResizeMix will resize an image to a small patch and paste it on another image. It’s proposed in ResizeMix: Mixing Data with Preserved Object Information and True Labels

参数:
  • alpha (float) – Parameters for Beta distribution to generate the mixing ratio. It should be a positive number. More details can be found in Mixup.

  • lam_min (float) – The minimum value of lam. Defaults to 0.1.

  • lam_max (float) – The maximum value of lam. Defaults to 0.8.

  • interpolation (str) – algorithm used for upsampling: ‘nearest’ | ‘linear’ | ‘bilinear’ | ‘bicubic’ | ‘trilinear’ | ‘area’. Defaults to ‘bilinear’.

  • prob (float) – The probability to execute resizemix. It should be in range [0, 1]. Defaults to 1.0.

  • cutmix_minmax (List[float], optional) – The min/max area ratio of the patches. If not None, the bounding-box of patches is uniform sampled within this ratio range, and the alpha will be ignored. Otherwise, the bounding-box is generated according to the alpha. Defaults to None.

  • correct_lam (bool) – Whether to apply lambda correction when cutmix bbox clipped by image borders. Defaults to True

  • **kwargs – Any other parameters accpeted by CutMix.

备注

The \(\lambda\) (lam) is the mixing ratio. It’s a random variable which follows \(Beta(\alpha, \alpha)\) and is mapped to the range [lam_min, lam_max].

\[\lambda = \frac{Beta(\alpha, \alpha)} {\lambda_{max} - \lambda_{min}} + \lambda_{min}\]

And the resize ratio of source images is calculated by \(\lambda\):

\[\text{ratio} = \sqrt{1-\lambda}\]
mix(batch_inputs, batch_scores)[源代码]

Mix the batch inputs and batch one-hot format ground truth.

参数:
  • batch_inputs (Tensor) – A batch of images tensor in the shape of (N, C, H, W).

  • batch_scores (Tensor) – A batch of one-hot format labels in the shape of (N, num_classes).

返回:

The mixed inputs and labels.

返回类型:

Tuple[Tensor, Tensor)

Read the Docs v: latest
Versions
latest
stable
mmcls-1.x
mmcls-0.x
dev
Downloads
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.