The-Learning-And-Vision-Atelier-LAVA / DASR

[CVPR 2021] Unsupervised Degradation Representation Learning for Blind Super-Resolution
MIT License
387 stars 50 forks source link

'IndexError: too many indices for array: array is 2-dimensional, but 3 were indexed'您好,我用自己的数据训练时出现这个错误 #67

Open gwp2021 opened 2 years ago

gwp2021 commented 2 years ago

非常感谢您的分享,但是我在测试自己的训练集时遇到一个问题,我的数据集是灰度图片,猜测应该是矩阵维数错误,可是我没有找到读取图片的代码在哪里,应该如何修改代码?感谢!

*(DASR) # ./main.sh ./data_set/benchmark/Set14/HR ./data_set/benchmark/Set14/LR_bicubic Making model... Preparing loss function: 1.000 L1 [Epoch 1] Learning rate: 1.00e-3 Traceback (most recent call last): File "main.py", line 19, in t.train() File "/home/jovyan/sr/DASR-main/trainer.py", line 63, in train for batch, (hr, _, idx_scale) in enumerate(self.loader_train): File "/home/jovyan/sr/DASR/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 582, in next return self._process_next_batch(batch) File "/home/jovyan/sr/DASR/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 608, in _process_next_batch raise batch.exc_type(batch.exc_msg) IndexError: Traceback (most recent call last): File "/home/jovyan/sr/DASR-main/dataloader.py", line 38, in _ms_loop samples = collate_fn([dataset[i] for i in batch_indices]) File "/home/jovyan/sr/DASR-main/dataloader.py", line 38, in samples = collate_fn([dataset[i] for i in batch_indices]) File "/home/jovyan/sr/DASR-main/data/multiscalesrdata.py", line 123, in getitem hr = self.get_patch(hr) File "/home/jovyan/sr/DASR-main/data/multiscalesrdata.py", line 164, in get_patch hr = common.augment(hr) if not self.args.no_augment else hr File "/home/jovyan/sr/DASR-main/data/common.py", line 44, in augment if hflip: img = img[:, ::-1, :] IndexError: too many indices for array: array is 2-dimensional, but 3 were indexed**

gwp2021 commented 2 years ago

已解决,手动将图片转换成RGB格式,可以正常train