yunxiaoshi / Neural-IMage-Assessment

A PyTorch Implementation of Neural IMage Assessment
Other
508 stars 92 forks source link

I met this error when run python3 main.py #18

Closed bemoregt closed 3 years ago

bemoregt commented 4 years ago

Hi, @kentsyx @George3d6

I met this error when run python3 main.py

/home/tezro/.local/lib/python3.7/site-packages/torchvision/transforms/transforms.py:187: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead. warnings.warn("The use of the transforms.Scale transform is deprecated, " + Trainable params: 14.97 million /home/tezro/cocoapi/PythonAPI/Neural-IMage-Assessment/data_loader.py:31: FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead. annotations = self.annotations.iloc[idx, 1:].as_matrix() /home/tezro/cocoapi/PythonAPI/Neural-IMage-Assessment/data_loader.py:31: FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead. annotations = self.annotations.iloc[idx, 1:].as_matrix() /home/tezro/cocoapi/PythonAPI/Neural-IMage-Assessment/data_loader.py:31: FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead. annotations = self.annotations.iloc[idx, 1:].as_matrix() /home/tezro/cocoapi/PythonAPI/Neural-IMage-Assessment/data_loader.py:31: FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead. annotations = self.annotations.iloc[idx, 1:].as_matrix() Traceback (most recent call last): File "main.py", line 241, in main(config) File "main.py", line 96, in main for i, data in enumerate(train_loader): File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 819, in next return self._process_data(data) File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 846, in _process_data data.reraise() File "/usr/local/lib/python3.7/dist-packages/torch/_utils.py", line 385, in reraise raise self.exc_type(msg) RuntimeError: Caught RuntimeError in DataLoader worker process 0. Original Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop data = fetcher.fetch(index) File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 47, in fetch return self.collate_fn(data) File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/collate.py", line 74, in default_collate return {key: default_collate([d[key] for d in batch]) for key in elem} File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/collate.py", line 74, in return {key: default_collate([d[key] for d in batch]) for key in elem} File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/collate.py", line 55, in default_collate return torch.stack(batch, 0, out=out) RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 3 and 1 in dimension 1 at /pytorch/aten/src/TH/generic/THTensor.cpp:689

My System: Ubuntu 19.04, Pytorch 1.4, Torchvision 0.4.2, TitanXP.

Thanks in advance. Best from @bemoregt.

yunxiaoshi commented 4 years ago

Hi, that's because there are some grayscale images in the dataset and the model expects 3-channel rgb image. I updated the code this should no longer be a problem