【发布时间】:2021-08-30 01:54:28
【问题描述】:
我正在尝试从包含 1768 张图像的列表中创建 numpy 数组。这是我的代码:
w = []
directory = os.listdir(PATH)
directory = sorted(directory, key=len)
for item in directory:
img = Image.open(os.path.join(PATH, item))
w.append(img)
count+=1
print('w_shape: ', np.array(w, dtype='float32').shape)
当运行它时,我遇到了这个错误:
TypeError: float() argument must be a string or a number, not 'JpegImageFile'
谁能帮我解决?
【问题讨论】:
-
你希望得到的数组是什么样子的?它的
shape应该是什么?你希望通过创建数组来解决什么问题? -
问题与
artificial-intelligence无关 - 请不要向无关标签发送垃圾邮件(已删除)。