意思是加载的一批图片里面存在大小不一致的情况,分别是[1100,1070]和[776,710]
然后根据这个问题,仔细看了下图片大小,确实存在不一样的尺寸
将图片一致化的方法:
from PIL import Image
import os.path
import glob
def Resize(file, outdir, width, height):
imgFile = Image.open(file)
try:
newImage = imgFile.resize((width, height), Image.BILINEAR)
newImage.save(os.path.join(outdir, os.path.basename(file)))
except Exception as e:
print(e)
for file in glob.glob("C:\\Users\\user\\PycharmProjects\\attention1\\result\\2\\*.png"): # 图片所在的目录
Resize(file, "C:\\Users\\user\\PycharmProjects\\attention1\\result1\\2", 145, 121) # 新图片存放的目录,需要统一的尺寸