minivision-ai / photo2cartoon

人像卡通化探索项目 (photo-to-cartoon translation project)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: img should be PIL Image. Got <class 'NoneType'>

bhadreshpsavani opened this issue · comments

Got error while model training

Traceback (most recent call last):
  File "/notebooks/photo2cartoon/models/UGATIT_sadalin_hourglass.py", line 175, in train
    real_A, _ = trainA_iter.next()
  File "/usr/local/lib/python3.9/dist-packages/torch/utils/data/dataloader.py", line 652, in __next__
    data = self._next_data()
  File "/usr/local/lib/python3.9/dist-packages/torch/utils/data/dataloader.py", line 692, in _next_data
    data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
  File "/usr/local/lib/python3.9/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/usr/local/lib/python3.9/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/notebooks/photo2cartoon/dataset.py", line 68, in __getitem__
    sample = self.transform(sample)
  File "/usr/local/lib/python3.9/dist-packages/torchvision/transforms/transforms.py", line 94, in __call__
    img = t(img)
  File "/usr/local/lib/python3.9/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/torchvision/transforms/transforms.py", line 349, in forward
    return F.resize(img, self.size, self.interpolation, self.max_size, self.antialias)
  File "/usr/local/lib/python3.9/dist-packages/torchvision/transforms/functional.py", line 430, in resize
    return F_pil.resize(img, size=size, interpolation=pil_interpolation, max_size=max_size)
  File "/usr/local/lib/python3.9/dist-packages/torchvision/transforms/functional_pil.py", line 249, in resize
    raise TypeError(f"img should be PIL Image. Got {type(img)}")
TypeError: img should be PIL Image. Got <class 'NoneType'>

It seems do not read the images, please check the data path.