meetps / pytorch-semseg

Semantic Segmentation Architectures Implemented in PyTorch
https://meetshah.dev/semantic-segmentation/deep-learning/pytorch/visdom/2017/06/01/semantic-segmentation-over-the-years.html
MIT License
3.39k stars 796 forks source link

Dataloader Type Error #226

Open ReinaFeng opened 5 years ago

ReinaFeng commented 5 years ago

Thank you for your code. I met a problem: /content/pytorch-semseg RUNDIR: runs/fcn8s_cityscapes/19903 Found 2975 train images Found 500 val images INFO:ptsemseg:Using cross_entropy with {'size_average': False} params INFO:ptsemseg:Using loss functools.partial(<function cross_entropy2d at 0x7f347b02a730>, size_average=False) Traceback (most recent call last): File "train.py", line 229, in train(cfg, writer, logger) File "train.py", line 118, in train for (images, labels) in trainloader: File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 336, in next return self._process_next_batch(batch) File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 357, in _process_next_batch raise batch.exc_type(batch.exc_msg) TypeError: Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 106, in _worker_loop samples = collate_fn([dataset[i] for i in batch_indices]) File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 106, in samples = collate_fn([dataset[i] for i in batch_indices]) File "/content/pytorch-semseg/ptsemseg/loader/cityscapes_loader.py", line 166, in getitem img, lbl = self.transform(img, lbl) File "/content/pytorch-semseg/ptsemseg/loader/cityscapes_loader.py", line 176, in transform img = m.imresize(img, (self.img_size[0], self.img_size[1])) # uint8 with RGB mode File "/usr/local/lib/python3.6/dist-packages/scipy/misc/pilutil.py", line 490, in imresize imnew = im.resize(size, resample=func[interp]) File "/usr/local/lib/python3.6/dist-packages/PIL/Image.py", line 1745, in resize return self._new(self.im.resize(size, resample, box)) TypeError: an integer is required (got type str)

Here's the configs: model: arch: fcn8s data: dataset: cityscapes train_split: train val_split: val img_rows: 'same' img_cols: 'same' path: /content/pytorch-segmentation/data/cityscapes/ training: train_iters: 85000 batch_size: 2 val_interval: 1000 n_workers: 4 print_interval: 50 optimizer: name: 'sgd' lr: 1.0e-10 weight_decay: 0.0005 momentum: 0.99 loss: name: 'cross_entropy' size_average: False lr_schedule: name: constant_lr resume:

Can you help me solve it?

Aurevious commented 5 years ago

Hi,have you solved the problem? I had a similar problem.

thanhhau097 commented 4 years ago

You should take a look at config file, and change img_rows, img_cols to integer