odegeasslbc / FastGAN-pytorch

Official implementation of the paper "Towards Faster and Stabilized GAN Training for High-fidelity Few-shot Image Synthesis" in ICLR 2021
GNU General Public License v3.0
606 stars 100 forks source link

Bug Report: Using some provided training sets, results in "IndexError: index -1 is out of bounds for axis 0 with size 0" #52

Open haltingstate opened 1 year ago

haltingstate commented 1 year ago

1> If the dog face dataset is used the program works and trains. However if the anime face dataset or other larger datasets are used the error below occurs

ml1@ml1:~/home/ml2FastGAN-pytorch$ python train.py --name test1 --path /home/ml1/datasets/fast-gan-datasets/anime-face/
/home/ml1/anaconda3/lib/python3.9/site-packages/scipy/__init__.py:146: UserWarning: A NumPy version >=1.16.5 and <1.23.0 is required for this version of SciPy (detected version 1.23.2
  warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"
Setting up Perceptual loss...
/home/ml1/anaconda3/lib/python3.9/site-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and will be removed in 0.15, please use 'weights' instead.
  warnings.warn(
/home/ml1/anaconda3/lib/python3.9/site-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and will be removed in 0.15. The current behavior is equivalent to passing `weights=VGG16_Weights.IMAGENET1K_V1`. You can also use `weights=VGG16_Weights.DEFAULT` to get the most up-to-date weights.
  warnings.warn(msg)
Loading model from: /home/ml1/home/ml2FastGAN-pytorch/lpips/weights/v0.1/vgg.pth
...[net-lin [vgg]] initialized
...Done
Namespace(path='/home/ml1/datasets/fast-gan-datasets/anime-face/', cuda=0, name='test1', iter=50000, start_iter=0, batch_size=8, im_size=1024, ckpt='None')
Traceback (most recent call last):
  File "/home/ml1/home/ml2FastGAN-pytorch/train.py", line 202, in <module>
    train(args)
  File "/home/ml1/home/ml2FastGAN-pytorch/train.py", line 92, in train
    dataloader = iter(DataLoader(dataset, batch_size=batch_size, shuffle=False,
  File "/home/ml1/anaconda3/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 444, in __iter__
    return self._get_iterator()
  File "/home/ml1/anaconda3/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 390, in _get_iterator
    return _MultiProcessingDataLoaderIter(self)
  File "/home/ml1/anaconda3/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1115, in __init__
    self._reset(loader, first_iter=True)
  File "/home/ml1/anaconda3/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1148, in _reset
    self._try_put_index()
  File "/home/ml1/anaconda3/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1382, in _try_put_index
    index = self._next_index()
  File "/home/ml1/anaconda3/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 671, in _next_index
    return next(self._sampler_iter)  # may raise StopIteration
  File "/home/ml1/anaconda3/lib/python3.9/site-packages/torch/utils/data/sampler.py", line 247, in __iter__
    for idx in self.sampler:
  File "/home/ml1/home/ml2FastGAN-pytorch/operation.py", line 16, in InfiniteSampler
    yield order[i]
IndexError: index -1 is out of bounds for axis 0 with size 0

Also

2> Needs upgrade for

/home/ml1/anaconda3/lib/python3.9/site-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and will be removed in 0.15, please use 'weights' instead.
/home/ml1/anaconda3/lib/python3.9/site-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and will be removed in 0.15. The current behavior is equivalent to passing `weights=VGG16_Weights.IMAGENET1K_V1`. You can also use `weights=VGG16_Weights.DEFAULT` to get the most up-to-date weights.
superPLJ commented 1 year ago

I got the same issue as you. In my situation, it's cased by the format of pictures. I used .JPG not .jpg as suffix

liuyisu commented 10 months ago

1> 如果使用狗脸数据集,程序可以工作和训练。但是,如果使用动漫人脸数据集或其他更大的数据集,则会出现以下错误

ml1@ml1:~/home/ml2FastGAN-pytorch$ python train.py --name test1 --path /home/ml1/datasets/fast-gan-datasets/anime-face/
/home/ml1/anaconda3/lib/python3.9/site-packages/scipy/__init__.py:146: UserWarning: A NumPy version >=1.16.5 and <1.23.0 is required for this version of SciPy (detected version 1.23.2
  warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"
Setting up Perceptual loss...
/home/ml1/anaconda3/lib/python3.9/site-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and will be removed in 0.15, please use 'weights' instead.
  warnings.warn(
/home/ml1/anaconda3/lib/python3.9/site-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and will be removed in 0.15. The current behavior is equivalent to passing `weights=VGG16_Weights.IMAGENET1K_V1`. You can also use `weights=VGG16_Weights.DEFAULT` to get the most up-to-date weights.
  warnings.warn(msg)
Loading model from: /home/ml1/home/ml2FastGAN-pytorch/lpips/weights/v0.1/vgg.pth
...[net-lin [vgg]] initialized
...Done
Namespace(path='/home/ml1/datasets/fast-gan-datasets/anime-face/', cuda=0, name='test1', iter=50000, start_iter=0, batch_size=8, im_size=1024, ckpt='None')
Traceback (most recent call last):
  File "/home/ml1/home/ml2FastGAN-pytorch/train.py", line 202, in <module>
    train(args)
  File "/home/ml1/home/ml2FastGAN-pytorch/train.py", line 92, in train
    dataloader = iter(DataLoader(dataset, batch_size=batch_size, shuffle=False,
  File "/home/ml1/anaconda3/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 444, in __iter__
    return self._get_iterator()
  File "/home/ml1/anaconda3/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 390, in _get_iterator
    return _MultiProcessingDataLoaderIter(self)
  File "/home/ml1/anaconda3/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1115, in __init__
    self._reset(loader, first_iter=True)
  File "/home/ml1/anaconda3/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1148, in _reset
    self._try_put_index()
  File "/home/ml1/anaconda3/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1382, in _try_put_index
    index = self._next_index()
  File "/home/ml1/anaconda3/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 671, in _next_index
    return next(self._sampler_iter)  # may raise StopIteration
  File "/home/ml1/anaconda3/lib/python3.9/site-packages/torch/utils/data/sampler.py", line 247, in __iter__
    for idx in self.sampler:
  File "/home/ml1/home/ml2FastGAN-pytorch/operation.py", line 16, in InfiniteSampler
    yield order[i]
IndexError: index -1 is out of bounds for axis 0 with size 0

2> 需要升级

/home/ml1/anaconda3/lib/python3.9/site-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and will be removed in 0.15, please use 'weights' instead.
/home/ml1/anaconda3/lib/python3.9/site-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and will be removed in 0.15. The current behavior is equivalent to passing `weights=VGG16_Weights.IMAGENET1K_V1`. You can also use `weights=VGG16_Weights.DEFAULT` to get the most up-to-date weights.

Hello, I have encountered the same problem as you. Do you have a solution? Thank you