用ALEXNET训练自己数据集,测试阶段出现的BUG:
一、
错误原因:测试要求用RGB图3通道,而我用的是灰度图。
解决方法:原代码
# load image
img_path = "../5.JPG"
assert os.path.exists(img_path), "file: '{}' dose not exist.".format(img_path)
img = Image.open(img_path)
plt.imshow(img)
改过后的代码,加一句img = img.covert('RGB')
# load image
img_path = "../5.JPG"
assert os.path.exists(img_path), "file: '{}' dose not exist.".format(img_path)
img = Image.open(img_path)
#add
img = img.convert('RGB')
plt.imshow(img)
完美解决:
在使用ALEXNET训练自定义数据集时遇到测试阶段的错误,原因是输入图像为灰度图而非RGB三通道图像。通过在加载图片后添加一行代码`img = img.convert('RGB')`,成功将图像转换为RGB格式,从而解决了问题。
3268

被折叠的 条评论
为什么被折叠?



