以rotate(旋转)为例
import tensorlayer as tl
from PIL import Image
import numpy as np
file_path = '/Users/qyk/Desktop/py/tensorlayer/data_augment/'
img_name = '2.jpg'#jpg或者JPG都行
img_path = file_path + img_name
img = Image.open(fp=img_path,mode='r')
img.show()
img = np.array(img)#tl.prepro.rotation要求img为numpy array
img1 = tl.prepro.rotation(img,rg=20,is_random=True,row_index=0,col_index=1,channel_index=2,fill_mode='nearest',cval=0.0)
img1 = Image.fromarray(img1)
img1.show()
img1_name = '22.jpg'
img1_path = file_path + img1_name
img1.save(fp=img1_path)