Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gwp2021 opened this issue Apr 1, 2022 · 1 comment

Comments

@gwp2021
Copy link

gwp2021 commented Apr 1, 2022

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

(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 gwp2021 changed the title 您好,我用自己的数据训练时出现这个错误,您可以帮我看一下吗? 'IndexError: too many indices for array: array is 2-dimensional, but 3 were indexed'您好,我用自己的数据训练时出现这个错误 Apr 2, 2022
@gwp2021
Copy link
Author

gwp2021 commented Apr 2, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant