xwjabc / hed

A PyTorch reimplementation of Holistically-Nested Edge Detection
170 stars 42 forks source link

When I reduce the number of samples, the following problems will occur #50

Closed peiyunju closed 2 years ago

peiyunju commented 2 years ago

Traceback (most recent call last): File "hed.py", line 309, in main() File "hed.py", line 189, in main train(train_loader, net, opt, lr_schd, epoch, save_dir=join(output_dir, 'epoch-{}-train'.format(epoch))) File "hed.py", line 214, in train for batch_index, (images, edges) in enumerate(tqdm(train_loader)): File "C:\Users\Administrator\anaconda3\envs\37\lib\site-packages\tqdm\std.py", line 1195, in iter for obj in iterable: File "C:\Users\Administrator\anaconda3\envs\37\lib\site-packages\torch\utils\data\dataloader.py", line 521, in next data = self._next_data() File "C:\Users\Administrator\anaconda3\envs\37\lib\site-packages\torch\utils\data\dataloader.py", line 561, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "C:\Users\Administrator\anaconda3\envs\37\lib\site-packages\torch\utils\data_utils\fetch.py", line 49, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "C:\Users\Administrator\anaconda3\envs\37\lib\site-packages\torch\utils\data_utils\fetch.py", line 49, in data = [self.dataset[idx] for idx in possibly_batched_index] File "F:\hed\datasets.py", line 43, in getitem edge = edge[np.newaxis, :, :] # Add one channel at first (CHW). TypeError: 'NoneType' object is not subscriptable

xwjabc commented 2 years ago

Hi @peiyunju, the error shows that the edge variable is not correctly loaded. It is highly possible that you have some pairs in the training list file (i.e., train_pair.lst) that are not available (e.g., you remove the image and corresponding edge files to reduce the number of samples but forget to remove those in the list file). Please double check the existence of all the pairs in the training list file.