Differences with torchvision.transforms.RandomRotation

View Source On Gitee

torchvision.transforms.RandomRotation

class torchvision.transforms.RandomRotation(degrees, interpolation=<InterpolationMode.NEAREST: 'nearest'>, expand=False, center=None, fill=0, resample=None)

For more information, see torchvision.transforms.RandomRotation.

mindspore.dataset.vision.RandomRotation

class mindspore.dataset.vision.RandomRotation(degrees, resample=Inter.NEAREST, expand=False, center=None, fill_value=0)

For more information, see mindspore.dataset.vision.RandomRotation.

Differences

PyTorch: Rotate the input image randomly within a specified range of degrees.

MindSpore: Rotate the input image randomly within a specified range of degrees.

Categories

Subcategories

PyTorch

MindSpore

Difference

Parameter

Parameter1

degrees

degrees

-

Parameter2

interpolation

resample

-

Parameter3

expand

expand

-

Parameter4

center

center

-

Parameter5

fill

fill_value

-

Parameter6

resample

-

Deprecated in PyTorch, same with interpolation

Code Example

from download import download
from PIL import Image

url = "https://mindspore-website.obs.cn-north-4.myhuaweicloud.com/notebook/datasets/flamingos.jpg"
download(url, './flamingos.jpg', replace=True)
orig_img = Image.open('flamingos.jpg')

# PyTorch
import torch
import torchvision.transforms as T
torch.manual_seed(1)

affine_transfomer = T.RandomRotation(degrees=(30, 70), center=(0, 0))
img_torch = affine_transfomer(orig_img)
print(img_torch.size)
# Out: (471, 292)

# MindSpore
import mindspore as ms
import mindspore.dataset.vision as vision
ms.dataset.config.set_seed(2)

affine_transfomer = vision.RandomRotation(degrees=(30, 70), center=(0, 0))
img_ms = affine_transfomer(orig_img)
print(img_ms.size)
# Out: (471, 292)