Tencent/Real-SR

train error

lxy5513 opened this issue · 3 comments

Thanks for your awesome code, I train it by my custom dataset, but some problems happened,

Original Traceback (most recent call last):
  File "/data/computervision/liuxingyu/envs/server31/anaconda3/envs/torch/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 198, in _worker_loop
    data = fetcher.fetch(index)
  File "/data/computervision/liuxingyu/envs/server31/anaconda3/envs/torch/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/data/computervision/liuxingyu/envs/server31/anaconda3/envs/torch/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/data/computervision/liuxingyu/projects/super_resolution/Real-SR/codes/data/LQGT_dataset.py", line 147, in __getitem__
    noise = self.noises[np.random.randint(0, len(self.noises))]
  File "mtrand.pyx", line 746, in numpy.random.mtrand.RandomState.randint
  File "_bounded_integers.pyx", line 1254, in numpy.random._bounded_integers._rand_int64
ValueError: low >= high

Could you give some advice to handle it, Thanks a lot!

When you do np.random.randint(0, len(self.noises)), most likely length of the noises is 0. Check how you specify location of the noise_data in .yml file. It should be:
noise_data: ../datasets/DF2K/Corrupted_noise**/**
Forward slash is important, because in data_loader.py script they rely on it:
self.noise_imgs = sorted(glob.glob(base + '*.png'))

The problem is that sorted(glob.glob(base + '*.png')) gives an empty list.
Replace it by ```

self.noise_imgs = [os.path.join(root,name)
             for root, dirs, files in os.walk(base)
             for name in files
             if name.endswith(('png'))]

`This would solve your error. Let me know whether it worked for you. `
Lcjgh commented

因为提取噪声的图像块的尺寸太大了,默认是256*256,对你输入的图像而言可能太大了。