【发布时间】:2016-09-04 09:41:09
【问题描述】:
我在 hdf5 文件中有大量图像,我想加载和分析这些图像。每个图像都是 1920x1920 uint16 并且将它们全部加载到内存中会使计算机崩溃。有人告诉我,其他人通过切片图像来解决这个问题,例如如果数据是 1920x1920x100(100 张图像),那么他们读取每个图像的前 80 行并分析该切片,然后移动到下一个切片。我可以毫无问题地做到这一点,但是当我尝试在 hdf5 文件中创建数据集时,它得到一个 TypeError: Can't convert element 0 ... to hsize_t
我可以用这个非常简化的代码重现问题:
with h5py.File('h5file.hdf5','w') as f:
data = np.random.randint(100, size=(15,15,20))
data_set = f.create_dataset('data', data, dtype='uint16')
给出输出:
TypeError: Can't convert element 0 ([[29 50 75...4 50 28 36 13 72]]) to hsize_t
我也尝试过省略“data_set =”和“dtype='uint16'”,但仍然遇到同样的错误。那么代码是:
with h5py.File('h5file.hdf5','w') as f:
data = np.random.randint(100, size=(15,15,20))
f.create_dataset('data', data)
谁能给我任何关于问题所在的提示? 干杯!
【问题讨论】: