mmagic.models.archs.ensemble
¶
Module Contents¶
Classes¶
Apply spatial and temporal ensemble and compute outputs. |
- class mmagic.models.archs.ensemble.SpatialTemporalEnsemble(is_temporal_ensemble: Optional[bool] = False)[源代码]¶
Bases:
torch.nn.Module
Apply spatial and temporal ensemble and compute outputs.
- 参数
is_temporal_ensemble (bool, optional) – Whether to apply ensemble temporally. If True, the sequence will also be flipped temporally. If the input is an image, this argument must be set to False. Default: False.
- _transform(imgs: torch.Tensor, mode: str) torch.Tensor [源代码]¶
Apply spatial transform (flip, rotate) to the images.
- 参数
imgs (torch.Tensor) – The images to be transformed/
mode (str) – The mode of transform. Supported values are ‘vertical’, ‘horizontal’, and ‘transpose’, corresponding to vertical flip, horizontal flip, and rotation, respectively.
- 返回
Output of the model with spatial ensemble applied.
- 返回类型
torch.Tensor
- spatial_ensemble(imgs: torch.Tensor, model: torch.nn.Module) torch.Tensor [源代码]¶
Apply spatial ensemble.
- 参数
imgs (torch.Tensor) – The images to be processed by the model. Its size should be either (n, t, c, h, w) or (n, c, h, w).
model (nn.Module) – The model to process the images.
- 返回
Output of the model with spatial ensemble applied.
- 返回类型
torch.Tensor
- forward(imgs: torch.Tensor, model: torch.nn.Module) torch.Tensor [源代码]¶
Apply spatial and temporal ensemble.
- 参数
imgs (torch.Tensor) – The images to be processed by the model. Its size should be either (n, t, c, h, w) or (n, c, h, w).
model (nn.Module) – The model to process the images.
- 返回
Output of the model with spatial ensemble applied.
- 返回类型
torch.Tensor