简体   繁体   English

ValueError: x 和 y 必须具有相同的第一维,但具有形状 (1,) 和 (224, 224, 3)

[英]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.

相关问题 ValueError:x 和 y 必须具有相同的第一维,但具有形状 (6,) 和 (8,) - ValueError: x and y must have same first dimension, but have shapes (6,) and (8,) ValueError:x 和 y 必须具有相同的第一维,但具有形状 (1, 2) 和 (2,) - ValueError: x and y must have same first dimension, but have shapes (1, 2) and (2,) ValueError:x 和 y 必须具有相同的第一维,但具有形状 - ValueError: x and y must have same first dimension, but have shapes 线性回归模型形状 - ValueError:x 和 y 必须具有相同的第一维,但具有形状 (5,) 和 (1, 5) - Linear regression model shapes - ValueError: x and y must have same first dimension, but have shapes (5,) and (1, 5) ValueError: x 和 y 必须具有相同的第一维,但具有形状 (10, 1) 和 (90,) - ValueError: x and y must have same first dimension, but have shapes (10, 1) and (90,) 线性回归:ValueError:x 和 y 必须具有相同的第一维,但具有形状 (10, 1) 和 (1, 1) - Linear Regression : ValueError: x and y must have same first dimension, but have shapes (10, 1) and (1, 1) ValueError:x 和 y 必须具有相同的第一维,但具有形状 (165,) 和 (166,) - ValueError: x and y must have same first dimension, but have shapes (165,) and (166,) Matplotlib 中的 Plot K-Means:ValueError:x 和 y 必须具有相同的第一个维度,但具有形状 (10,) 和 (1,) - Plot K-Means in Matplotlib: ValueError: x and y must have same first dimension, but have shapes (10,) and (1,) ValueError:x 和 y 必须具有相同的第一维,但具有形状 (512,) 和 (256,) - ValueError: x and y must have same first dimension, but have shapes (512,) and (256,) ValueError: x 和 y 必须具有相同的第一个维度,但具有形状 (99955,) 和 (15000,) - ValueError: x and y must have same first dimension, but have shapes (99955,) and (15000,)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM