xingyizhou / CenterNet

Object detection, 3D detection, and pose estimation using center point detection:
MIT License
7.26k stars 1.92k forks source link

It shows that Keyerror:0 when running main.py #423

Open terminal-zyx opened 4 years ago

terminal-zyx commented 4 years ago

==> initializing coco 2017 val data. loading annotations into memory... Done (t=0.00s) creating index... index created! Loaded val 170 samples ==> initializing coco 2017 train data. loading annotations into memory... Done (t=0.04s) creating index... index created! Loaded train 1431 samples Starting training... False ctdet/coco_dlaTraceback (most recent call last): File "main.py", line 108, in main(opt) File "main.py", line 76, in main log_dicttrain, = trainer.train(epoch, train_loader) File "/home/ubuntu/cocoapi/PythonAPI/CenterNet/src/lib/trains/base_trainer.py", line 119, in train return self.run_epoch('train', epoch, data_loader) File "/home/ubuntu/cocoapi/PythonAPI/CenterNet/src/lib/trains/base_trainer.py", line 61, in run_epoch for iter_id, batch in enumerate(data_loader): File "/home/ubuntu/anaconda3/envs/CenterNet/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 314, in next batch = self.collate_fn([self.dataset[i] for i in indices]) File "/home/ubuntu/anaconda3/envs/CenterNet/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 314, in batch = self.collate_fn([self.dataset[i] for i in indices]) File "/home/ubuntu/cocoapi/PythonAPI/CenterNet/src/lib/datasets/sample/ctdet.py", line 102, in getitem cls_id = int(self.cat_ids[ann['category_id']]) KeyError: 0

matt-teng commented 4 years ago

Just add the background to the class of the coco.py.

xingyizhou commented 4 years ago

Please make sure you are using the original version of COCO annotation. The category_id should start from 1.