Загрузка
Rotate the input by angle.
If the input is a torch.Tensor or a TVTensor (e.g. Image,
Video, BoundingBoxes etc.)
it can have arbitrary number of leading batch dimensions. For example,
the image can have [..., C, H, W] shape. A bounding box can have [..., 4] shape.
degrees (sequence or number) – Range of degrees to select from.
If degrees is a number instead of sequence like (min, max), the range of degrees
will be [-degrees, +degrees]. [90, 90] will rotate the image by 90 degrees anticlockwise.
interpolation (str or InterpolationMode, optional) – Desired interpolation enum defined by
torchvision.transforms.v2.InterpolationMode.
Accepted string values are "nearest", "nearest-exact", , ,
, , and .
, , and are only supported for PIL images.
Default is .
The corresponding enum values and Pillow integer
constants, e.g. are accepted as well.
Examples using RandomRotation:
Get parameters for rotate for a random rotation.
angle parameter to be passed to for random rotation.
"bicubic""box""hamming""lanczos""box""hamming""lanczos""nearest"InterpolationModePIL.Image.BILINEARexpand (bool, optional) – Optional expansion flag. If true, expands the output to make it large enough to hold the entire rotated image. If false or omitted, make the output image the same size as the input image. Note that the expand flag assumes rotation around the center (see note below) and no translation.
center (sequence, optional) –
Optional center of rotation, (x, y). Origin is the upper left corner. Default is the center of the image.
fill (number or tuple or dict, optional) – Pixel fill value used when the padding_mode is constant.
Default is 0. If a tuple of length 3, it is used to fill R, G, B channels respectively.
Fill value can be also a dictionary mapping data type to the fill value, e.g.
fill={tv_tensors.Image: 127, tv_tensors.Mask: 0} where Image will be filled with 127 and
Mask will be filled with 0.