thaoshibe / BeautyGAN-PyTorch-reimplementation

A re-implementation of BeautyGAN: Instance-level Facial Makeup Transfer with Deep Generative Adversarial Network (ACM MM'18)
MIT License
77 stars 16 forks source link

IndexError: Cannot choose from an empty sequence #4

Closed pirate-zhang closed 3 years ago

pirate-zhang commented 3 years ago

When I tried to run this code, it reported such an error: Traceback (most recent call last): File "train.py", line 76, in train_net() File "train.py", line 59, in train_net solver.train() File "/data/home/scv0004/BeautyGAN-pytorch-reimplementation/solver_makeup.py", line 264, in train for self.i, (img_A, img_B, mask_A, mask_B) in enumerate(tqdm(self.data_loader_train)): File "/data/home/scv0004/.conda/envs/beautygan/lib/python3.7/site-packages/tqdm/std.py", line 1178, in iter for obj in iterable: File "/data/home/scv0004/.conda/envs/beautygan/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 517, in next data = self._next_data() File "/data/home/scv0004/.conda/envs/beautygan/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 557, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "/data/home/scv0004/.conda/envs/beautygan/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 "/data/home/scv0004/.conda/envs/beautygan/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/data/home/scv0004/BeautyGAN-pytorch-reimplementation/data_loaders/makeup.py", line 29, in getitem idxA = random.choice(range(self.noiA)) File "/data/home/scv0004/.conda/envs/beautygan/lib/python3.7/random.py", line 261, in choice raise IndexError('Cannot choose from an empty sequence') from None IndexError: Cannot choose from an empty sequence Can you take a look at it for me when you have time?

thaoshibe commented 3 years ago

Hello there, Please make sure that there're images in input folder. You can try to debug from here dataloader.

self.As, self.Bs, etc. should be a list of filenames.