ssd.pytorch icon indicating copy to clipboard operation
ssd.pytorch copied to clipboard

KeyError: Caught KeyError in DataLoader worker process 0.

Open GeLee-Q opened this issue 4 years ago • 6 comments

GeLee-Q avatar May 12 '20 09:05 GeLee-Q

/content/drive/My Drive/ssd/ssd.pytorch/ssd.py:34: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead. self.priors = Variable(self.priorbox.forward(), volatile=True) Loading base network... Initializing weights... train.py:214: UserWarning: nn.init.xavier_uniform is now deprecated in favor of nn.init.xavier_uniform_. init.xavier_uniform(param) Loading the dataset... Training SSD on: VOC0712 Using the specified args: Namespace(basenet='vgg16_reducedfc.pth', batch_size=16, cuda=True, dataset='VOC', dataset_root='/content/drive/My Drive/ssd/ssd.pytorch/data/VOCdevkit/', gamma=0.1, lr=0.0001, momentum=0.9, num_workers=4, resume=None, save_folder='weights/', start_iter=0, visdom=False, weight_decay=0.0005) Traceback (most recent call last): File "train.py", line 255, in train() File "train.py", line 165, in train images, targets = next(batch_iterator) File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 345, in next data = self._next_data() File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 856, in _next_data return self._process_data(data) File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 881, in _process_data data.reraise() File "/usr/local/lib/python3.6/dist-packages/torch/_utils.py", line 395, in reraise raise self.exc_type(msg) KeyError: Caught KeyError in DataLoader worker process 0. Original Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop data = fetcher.fetch(index) File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/content/drive/My Drive/ssd/ssd.pytorch/data/voc0712.py", line 116, in getitem im, gt, h, w = self.pull_item(index) File "/content/drive/My Drive/ssd/ssd.pytorch/data/voc0712.py", line 131, in pull_item target = self.target_transform(target, width, height) File "/content/drive/My Drive/ssd/ssd.pytorch/data/voc0712.py", line 73, in call label_idx = self.class_to_ind[name] KeyError: 'traffic sign'

GeLee-Q avatar May 12 '20 09:05 GeLee-Q

I just want to detect one traffic sign. but it doesn't work and it report the error. I can't find error and it's solutions looks like it.

GeLee-Q avatar May 12 '20 09:05 GeLee-Q

I just want to detect one traffic sign. but it doesn't work and it report the error. I can't find error and it's solutions looks like it.

@GeLee-Q You must adjust something:

  1. in data/voc0712.py, change VOC_CLASSES to VOC_CLASSES = [('traffic sign')]
  2. change num_classes in VOC in data/config.py to 2 (included background class)
  • Try to change and if have any problem, comment here

AnhPC03 avatar Jul 24 '20 09:07 AnhPC03

I just want to detect one traffic sign. but it doesn't work and it report the error. I can't find error and it's solutions looks like it.

@GeLee-Q You must adjust something:

  1. in data/voc0712.py, change VOC_CLASSES to VOC_CLASSES = [('traffic sign')]
  2. change num_classes in VOC in data/config.py to 2 (included background class)
  • Try to change and if have any problem, comment here

Same like above, I just wanna detect one class 'smoke', and I did what you said similarly, I rewrite a file similar to voc0712.py name smoke.py the structure is alike and other alternations, changed num_classes in VOC in data/config.py to 2,

but it still didn't work

same errors:

Loading base network... Initializing weights... Loading the dataset... Training SSD on: SMOKE Using the specified args: Namespace(basenet='vgg16_reducedfc.pth', batch_size=8, cuda=True, dataset='VOC', dataset_root='E:/ssd.pytorch/data/VOCdevkit/VOCsmoke/', gamma=0.1, lr=1e-05, momentum=0.9, num_workers=4, resume=None, save_folder='E:/ssd.pytorch/weights/', start_iter=0, visdom=False, weight_decay=0.0005) Traceback (most recent call last): File "train.py", line 254, in train() File "train.py", line 156, in train images, targets = next(batch_iterator) File "D:\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 363, in next data = self._next_data() File "D:\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 989, in _next_data return self._process_data(data) File "D:\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 1014, in _process_data data.reraise() File "D:\Anaconda3\lib\site-packages\torch_utils.py", line 395, in reraise raise self.exc_type(msg) KeyError: Caught KeyError in DataLoader worker process 0. Original Traceback (most recent call last): File "D:\Anaconda3\lib\site-packages\torch\utils\data_utils\worker.py", line 185, in _worker_loop data = fetcher.fetch(index) File "D:\Anaconda3\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "D:\Anaconda3\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "E:\ssd.pytorch\data\smoke.py", line 114, in getitem im, gt, h, w = self.pull_item(index) File "E:\ssd.pytorch\data\smoke.py", line 129, in pull_item target = self.target_transform(target, width, height) File "E:\ssd.pytorch\data\smoke.py", line 68, in call label_idx = self.class_to_ind[name] KeyError: 'smoke

jayphone17 avatar Mar 20 '22 12:03 jayphone17

@jayphone17 Check your VOC classes name again. As I saw, you defined 'smoke class name but it has to be smoke (notice the apostrophe precede of smoke word)

AnhPC03 avatar Mar 24 '22 07:03 AnhPC03

@jayphone17 Check your VOC classes name again. As I saw, you defined 'smoke class name but it has to be smoke (notice the apostrophe precede of smoke word)

THX A LOT ! After I checked my dataset, there is a damaged label. Relabel and it worked !

jayphone17 avatar Apr 02 '22 04:04 jayphone17