RandomZoomOut¶
- class torchvision.transforms.v2.RandomZoomOut(fill: Union[int, float, Sequence[int], Sequence[float], None, Dict[Union[Type, str], Optional[Union[int, float, Sequence[int], Sequence[float]]]]] = 0, side_range: Sequence[float] = (1.0, 4.0), p: float = 0.5)[源代码]¶
“SSD: Single Shot MultiBox Detector” 中的“缩小”变换。
此变换会随机填充图像、视频、边界框和掩码,从而创建缩小效果。输出空间大小从原始大小随机采样,最大不超过由
side_range
参数配置的最大尺寸。r = uniform_sample(side_range[0], side_range[1]) output_width = input_width * r output_height = input_height * r
如果输入是
torch.Tensor
或TVTensor
(例如Image
、Video
、BoundingBoxes
等),它可以具有任意数量的领先批次维度。例如,图像可以具有[..., C, H, W]
的形状。边界框可以具有[..., 4]
的形状。- 参数:
fill (数字 或 元组 或 字典, 可选) – 在
padding_mode
为 constant 时使用的像素填充值。默认值为 0。如果是一个长度为 3 的元组,它分别用于填充 R、G、B 通道。填充值也可以是一个将数据类型映射到填充值的字典,例如fill={tv_tensors.Image: 127, tv_tensors.Mask: 0}
,其中Image
将用 127 填充,Mask
将用 0 填充。side_range (由 python:floats 组成的序列, 可选) – 由两个浮点数组成的元组,定义了缩放输入尺寸的最小和最大因子。
p (浮点数, 可选) – 执行缩放操作的概率。
使用
RandomZoomOut
的示例