[英]ValueError: x and y must have same first dimension, but have shapes (1,) and (224, 224, 3)
import os
import cv2
path1 = os.path.abspath('/content/drive/My Drive/dogbreed/test_set/n02085620-Chihuahua')
path2 = os.path.abspath('/content/drive/My Drive/dogbreed/test_set/n02085936-Maltese_dog')
path3 = os.path.abspath('/content/drive/My Drive/dogbreed/test_set/n02088238-basset')
folder = os.path.join(path1, path2, path3)
images = []
for filename in os.listdir(folder):
if filename.endswith(".jpg"):
img = cv2.imread(os.path.join(folder, filename))
if img is not None:
images.append(img)
from matplotlib import pyplot as plt
import numpy as np
img = np.array(images[0])
img = cv2.resize(img, (224, 224), interpolation = cv2.INTER_CUBIC)
plt.plot('image',img)
your call to你的来电
plt.plot('image',img)
is generating the error because the first and the second argument must have the same dimension.正在生成错误,因为第一个和第二个参数必须具有相同的维度。
Maybe, should you consider也许,你应该考虑
plt.imshow(img)
to replace this line?替换这条线?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.