作者丨结发授长生@知乎链接丨https://zhuanlan.zhihu.com/p/559887437使用数据增强技术可以增加数据集中图像的多样性,从而提高模型的性能和泛化能力。主要的图像增强技术包括:调整大小灰度变换标准化随机旋转中心裁剪随机裁剪高斯模糊亮度、对比度调节水平翻转垂直翻转高斯噪声随机块中心区域调整大小在开始图像大小的调整之前我们需要导入数据(图像以眼底图像为例)。from PIL import Imagefrom pathlib import Pathimport matplotlib.pyplot as pltimport numpy as npimport sysimport torchimport numpy as npimport torchvision.transforms as Tplt.rcParams["savefig.bbox"] = 'tight'orig_img = Image.open(Path('image/000001.tif'))torch.manual_seed(0) # 设置 CPU 生成随机数的 种子 ,方便下次复现实验结果print(np.asarray(orig_img).shape) #(800, 800, 3)#图像大小的调整resized_imgs = [T.Resize(size=size)(orig_img) for size in [128,256]]# plt.figure('resi
………………………………