transforms.RandomPerspective(distortion_scale=0.5, p=0.5, interpolation=<InterpolationMode.BILINEAR: 'bilinear'>, fill=0)
distortion_scale:角度的倾斜值,取值(0,1)
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.RandomPerspective(distortion_scale=0.2,p=0.8)(img0)
img2=transform.RandomPerspective(distortion_scale=0.8,p=0.8)(img0)
axs = plt.figure().subplots(1, 3)
axs[0].imshow(img0);axs[0].set_title('src');axs[0].axis('off')
axs[1].imshow(img1);axs[1].set_title('0.2');axs[1].axis('off')
axs[2].imshow(img2);axs[2].set_title('0.8');axs[2].axis('off')
plt.show()
实图演示: