SaoYan / DnCNN-PyTorch

PyTorch implementation of the TIP2017 paper "Beyond a Gaussian Denoiser: Residual Learning of Deep CNN for Image Denoising"
http://ieeexplore.ieee.org/document/7839189/
GNU General Public License v3.0
407 stars 117 forks source link

h5py wrong #10

Closed bollossom closed 1 year ago

bollossom commented 2 years ago

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\h5f.pyx", line 106, in h5py.h5f.open OSError: Unable to open file (file signature not found) 下面这段代码出错(wrong) class Dataset(udata.Dataset): def init(self, train=True): super(Dataset, self).init() self.train = train if self.train: h5f = h5py.File('train.h5', 'r')

h5f = h5py.File('C:/pytorch/DnCNN-PyTorch-master/train.py', 'r')

    else:
        h5f = h5py.File('val.h5', 'r')
    self.keys = list(h5f.keys())
    random.shuffle(self.keys)
    h5f.close()
def __len__(self):
    return len(self.keys)
def __getitem__(self, index):
    if self.train:
        h5f = h5py.File('train.h5', 'r')
    else:
        h5f = h5py.File('val.h5', 'r')
    key = self.keys[index]
    data = np.array(h5f[key])
    h5f.close()
    return torch.Tensor(data)
XDUqinian commented 1 year ago

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\h5f.pyx", line 106, in h5py.h5f.open OSError: Unable to open file (file signature not found) 下面这段代码出错(wrong) class Dataset(udata.Dataset): def init(self, train=True): super(Dataset, self).init() self.train = train if self.train: h5f = h5py.File('train.h5', 'r') # h5f = h5py.File('C:/pytorch/DnCNN-PyTorch-master/train.py', 'r') else: h5f = h5py.File('val.h5', 'r') self.keys = list(h5f.keys()) random.shuffle(self.keys) h5f.close() def len(self): return len(self.keys) def getitem(self, index): if self.train: h5f = h5py.File('train.h5', 'r') else: h5f = h5py.File('val.h5', 'r') key = self.keys[index] data = np.array(h5f[key]) h5f.close() return torch.Tensor(data)

你看他写的文档,运行train的时候要输入命令行参数