PeterL1n / BackgroundMattingV2

Real-Time High-Resolution Background Matting
MIT License
6.81k stars 950 forks source link

ZeroDivisionError: integer division or modulo by zero #115

Closed xiaobao886 closed 3 years ago

xiaobao886 commented 3 years ago

When I execute the train, The following error occurred

Traceback (most recent call last): File "C:/Users/lijunwen/BackgroundMattingV2-master/train_base.py", line 265, in train() File "C:/Users/lijunwen/BackgroundMattingV2-master/train_base.py", line 142, in train for i, ((true_pha, true_fgr), true_bgr) in enumerate(tqdm(dataloader_train)): File "C:\anaconda\envs\bgmattev2\lib\site-packages\tqdm\std.py", line 1171, in iter for obj in iterable: File "C:\anaconda\envs\bgmattev2\lib\site-packages\torch\utils\data\dataloader.py", line 435, in next data = self._next_data() File "C:\anaconda\envs\bgmattev2\lib\site-packages\torch\utils\data\dataloader.py", line 475, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "C:\anaconda\envs\bgmattev2\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "C:\anaconda\envs\bgmattev2\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "C:\Users\lijunwen\BackgroundMattingV2-master\dataset\zip.py", line 17, in getitem x = tuple(d[idx % len(d)] for d in self.datasets) File "C:\Users\lijunwen\BackgroundMattingV2-master\dataset\zip.py", line 17, in x = tuple(d[idx % len(d)] for d in self.datasets) ZeroDivisionError: integer division or modulo by zero

Is this a question of training background image?

PeterL1n commented 3 years ago

It happens when the script didn't load your dataset correctly. It detected zero images in the dataset and got the error. You probably didn't structure your dataset correctly.

Datura0822 commented 3 years ago

@PeterL1n I have the same problem when running train_refine.py, but there is no problem when running train_base.py with the same dataset. I want to know what kind of dataset requirements train_refine.py has?

Datura0822 commented 3 years ago

@xiaobao886 I have the same problem when running train_refine.py, have you found a solution?