代码之家  ›  专栏  ›  技术社区  ›  Simplicity

为什么我不知道图像的大小

  •  0
  • Simplicity  · 技术社区  · 7 年前

    我有 374 32x32 我读取并存储在列表中的图像如下:

    for root, dirs, files in os.walk(image_directory):
        for i in range(number_of_images):
            img = cv2.imread(root + '/' + str(i) + '.jpg')
            real_images.append(img)
    

    当我想要恢复 real_images 通过做: numpy.array(real_images).shape 我得到了 (374,) .

    我为什么不明白 (374, 32, 32, 3) ?也就是说,图像的数量和尺寸?

    谢谢。

    1 回复  |  直到 7 年前
        1
  •  1
  •   Aneesh Palsule Hiadore    7 年前

    哈博姆在评论中所说的可能就是这样。我试了下面的方法,结果和你的一样。

    import numpy as np
    
    a = []
    for i in range(10):
        a.append(np.arange(10))
    print(np.array(a).shape)
    a.append(np.array([1]))
    print(np.array(a).shape)
    
    Output:
    (10,10)
    (11,)
    

    尝试检查个人的形状 np 如果可以,则数组。也许它会告诉你发生了什么。希望这有帮助。