比较与torchvision.transforms.RandomPerspective的差异

查看源文件

torchvision.transforms.RandomPerspective

class torchvision.transforms.RandomPerspective(distortion_scale=0.5, p=0.5, interpolation=InterpolationMode.BILINEAR, fill=0)

更多内容详见torchvision.transforms.RandomPerspective

mindspore.dataset.vision.RandomPerspective

class mindspore.dataset.vision.RandomPerspective(distortion_scale=0.5, prob=0.5, interpolation=Inter.BICUBIC)

更多内容详见mindspore.dataset.vision.RandomPerspective

差异对比

PyTorch:对张量图像应用随机透视变换,可以指定变换区域外的填充像素值。

MindSpore:对输入图像应用随机透视变换,变换区域外的填充像素值为黑色,不支持指定填充颜色。

分类

子类

PyTorch

MindSpore

差异

参数

参数1

distortion_scale

distortion_scale

-

参数2

p

prob

-

参数3

interpolation

interpolation

默认值不同

参数4

fill

-

指定变换区域外的填充像素值

代码示例

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 torchvision.transforms as T

transform = T.RandomPerspective(distortion_scale=0.5, p=0.5, interpolation=T.InterpolationMode.BILINEAR)
img_torch = T.Compose([transform])(orig_img)


# MindSpore
import mindspore.dataset.vision as vision
import mindspore.dataset.transforms as transforms

transform = vision.RandomPerspective(distortion_scale=0.5, prob=0.5, interpolation=vision.Inter.BILINEAR)
img_ms = transforms.Compose([transform])(orig_img)