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

29 篇文章 1 订阅
24 篇文章 0 订阅

转载请注明出处

事故描述:

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

Traceback (most recent call last):
  File "create_dataset.py", line 123, in <module>
    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。
所以当程序跑到那一块时就会报错

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值