赞
踩
from PIL import Image
from torchvision import transforms
img = Image.open('./test.jpg')
img.show() #输出打开图片
new_img = transforms.Resize((100,100))(img) #调用缩放函数
new_img.show()
from PIL import Image
from torchvision import transforms
img = Image.open('./test.jpg')
img.show()
new_img = transforms.RandomCrop((150,150))(img) #(150,150)为随机截取图片大小
new_img.show()
from PIL import Image
from torchvision import transforms
img = Image.open('./test.jpg')
img.show()
new_img = transforms.CenterCrop((150,150))(img)
new_img.show()
from PIL import Image
from torchvision import transforms
img = Image.open('./test.jpg')
img.show()
new_img = transforms.RandomHorizontalFlip()(img)
new_img.show()
new_img = transforms.RandomVerticalFlip()(img)
new_img.show()
img = Image.open('./test.jpg')
img.show()
new_img = transforms.RandomRotation(30)(img) #30度
new_img.show()
img = Image.open('./test.jpg')
img.show()
new_img = transforms.ColorJitter(brightness=1,contrast=1,hue=0.1)(img) #参数分别亮度、对比度、饱和度
new_img.show()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。