10、随机图片水平翻转 transforms.RandomHorizontalFlip(p=0.5)

transforms.RandomHorizontalFlip(p=0.5)
import torchvision.transforms as transform
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
import torch
img0=Image.open('lin-xiao-xun-000003.jpg')
img1=transform.RandomHorizontalFlip(p=0.8)(img0)
axs = plt.figure().subplots(1, 2)
axs[0].imshow(img0);axs[0].set_title('src');axs[0].axis('off')
axs[1].imshow(img1);axs[1].set_title('RandomHorizontalFlip');axs[1].axis('off')

plt.show()

实图演示:
10、随机图片水平翻转 transforms.RandomHorizontalFlip(p=0.5)_第1张图片

你可能感兴趣的:(pytorch数据增强方法,python,计算机视觉,opencv)