按照教程数据增广后,图片没有变化?
Created by: qingweihk
按照教程如下的代码,对图像进行变换:但变换完的图像无变化喔 from ppcls.data.imaug import DecodeImage from ppcls.data.imaug import ResizeImage from ppcls.data.imaug import ToCHWImage from ppcls.data.imaug import GridMask from ppcls.data.imaug import transform
size = 224
图像解码
decode_op = DecodeImage()
图像随机裁剪
resize_op = ResizeImage(size=(size, size))
图像数据的重排
tochw_op = ToCHWImage()
使用GridMask图像增广方法
gridmask_op = GridMask(d1=96, d2=224, rotate=1, ratio=0.6, mode=1, prob=0.8)
ops = [decode_op, resize_op, tochw_op, gridmask_op]
图像路径
imgs_dir = '/content/yolov5/inference/images' fnames = os.listdir(imgs_dir) for f in fnames: data = open(os.path.join(imgs_dir, f),'rb').read() img = transform(data, ops) img = img.transpose((1, 2, 0))