You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-18-37f467c4f834> in <module>
1 for epoch in range(1, epochs + 1):
----> 2 train(epoch)
3 test(epoch)
4 with torch.no_grad():
5 sample = torch.randn(2, 2048).to(device)
<ipython-input-16-2c647e00a259> in train(epoch)
2 model.train()
3 train_loss = 0
----> 4 for batch_idx, (data, _) in enumerate(train_loader_food):
5 data = data.to(device)
6 data = transforms.ToPILImage()(data)
~/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py in __next__(self)
361
362 def __next__(self):
--> 363 data = self._next_data()
364 self._num_yielded += 1
365 if self._dataset_kind == _DatasetKind.Iterable and \
~/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py in _next_data(self)
987 else:
988 del self._task_info[idx]
--> 989 return self._process_data(data)
990
991 def _try_put_index(self):
~/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py in _process_data(self, data)
1012 self._try_put_index()
1013 if isinstance(data, ExceptionWrapper):
-> 1014 data.reraise()
1015 return data
1016
~/anaconda3/lib/python3.7/site-packages/torch/_utils.py in reraise(self)
393 # (https://bugs.python.org/issue2651), so we work around it.
394 msg = KeyErrorMessage(msg)
--> 395 raise self.exc_type(msg)
TypeError: Caught TypeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/mona/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 185, in _worker_loop
data = fetcher.fetch(index)
File "/home/mona/anaconda3/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 "/home/mona/anaconda3/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 "/home/mona/anaconda3/lib/python3.7/site-packages/torchvision/datasets/folder.py", line 139, in __getitem__
sample = self.transform(sample)
File "/home/mona/anaconda3/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 61, in __call__
img = t(img)
File "/home/mona/anaconda3/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 244, in __call__
return F.resize(img, self.size, self.interpolation)
File "/home/mona/anaconda3/lib/python3.7/site-packages/torchvision/transforms/functional.py", line 319, in resize
raise TypeError('img should be PIL Image. Got {}'.format(type(img)))
TypeError: img should be PIL Image. Got <class 'torch.Tensor'>
The text was updated successfully, but these errors were encountered:
How should I fix this error?
https://gist.github.com/monajalal/8f0226aba24c98235667a5f0a1216aca
The text was updated successfully, but these errors were encountered: