AAnoosheh / ToDayGAN

http://arxiv.org/abs/1809.09767
BSD 2-Clause "Simplified" License
172 stars 32 forks source link

ValueError: empty range for randrange() (0,0, 0) #9

Closed Ti-tanium closed 5 years ago

Ti-tanium commented 5 years ago

I created directory test0&test1 and put them under ./img as suggested. And test0 is empty. test1 has 6 photos. when I ran the following script, I get ValueError.

python3 test.py --phase test --name night2day --dataroot ./img --n_domains 2 --which_epoch 150 --loadSize 512

The full error log is as follow:

Created 2 Encoder-Decoder pairs
Number of parameters per Encoder: 5099143
Number of parameters per Deocder: 6565770
-----------------------------------------------
Traceback (most recent call last):
  File "test.py", line 24, in <module>
    for i, data in enumerate(dataset):
  File "/home/vehicle/ToDayGAN/data/data_loader.py", line 21, in __iter__
    for i, data in enumerate(self.dataloader):
  File "/usr/local/python3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 582, in __next__
    return self._process_next_batch(batch)
  File "/usr/local/python3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 608, in _process_next_batch
    raise batch.exc_type(batch.exc_msg)
ValueError: Traceback (most recent call last):
  File "/usr/local/python3/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 99, in _worker_loop
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "/usr/local/python3/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 99, in <listcomp>
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "/home/vehicle/ToDayGAN/data/unaligned_dataset.py", line 36, in __getitem__
    index_A = random.randint(0, self.sizes[DA] - 1)
  File "/usr/local/python3/lib/python3.6/random.py", line 220, in randint
    return self.randrange(a, b+1)
  File "/usr/local/python3/lib/python3.6/random.py", line 198, in randrange
    raise ValueError("empty range for randrange() (%d,%d, %d)" % (istart, istop, width))
ValueError: empty range for randrange() (0,0, 0)

It seems that both test0 and test1 cannot be empty.

AAnoosheh commented 5 years ago

Sorry for the delay. Thanks for pointing this out.

Use the --serial_test flag. It will avoid that issue. Without it, it randomly samples test images instead of going through them all in order. (A leftover feature from CycleGAN long ago)