H5py报错:OSError: Can't read data (inflate() failed)

转载请注明出处

事故描述:

      我原先写了个程序提取.mat文件的数据。以前用没问题,结果今天我准备再提取一次的时候报错如下:

Traceback (most recent call last):
  File "create_dataset.py", line 123, in
    create_dataset(args.mat_file_path)
  File "create_dataset.py", line 106, in create_dataset
    temp.append(np.array((Image.fromarray(f[f[f['labeled'][0][i]][j][k]][:].transpose(2,1,0))).resize((60,160))) / 255.)
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "E:\Anaconda\lib\site-packages\h5py\_hl\dataset.py", line 496, in __getitem__
    self.id.read(mspace, fspace, arr, mtype, dxpl=self._dxpl)
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py\h5d.pyx", line 181, in h5py.h5d.DatasetID.read
  File "h5py\_proxy.pyx", line 130, in h5py._proxy.dset_rw
  File "h5py\_proxy.pyx", line 84, in h5py._proxy.H5PY_H5Dread

OSError: Can't read data (inflate() failed)

原因分析:

我意识到.mat数据实际上已经损坏了。
我认为如果一个文件被损坏了那么无法从中提取任何东西,但事实证明,只是不能提取被损坏的特定那块,可能只是几个bit。
所以当程序跑到那一块时就会报错

你可能感兴趣的:(python,机器学习,图像处理)