sovit-123 / fasterrcnn-pytorch-training-pipeline

PyTorch Faster R-CNN Object Detection on Custom Dataset
MIT License
223 stars 75 forks source link

KeyError: tensor(25) #155

Closed chaser682 closed 2 months ago

chaser682 commented 2 months ago

Traceback (most recent call last): File "train.py", line 584, in main(args) File "train.py", line 419, in main batch_loss_rpn_list = train_one_epoch( File "D:\Codes\PaperCode\crop_weed_detection_fasterrcnn\torch_utils\engine.py", line 49, in train_one_epoch for images, targets in metric_logger.log_every(data_loader, print_freq, header): File "D:\Codes\PaperCode\crop_weed_detection_fasterrcnn\torch_utils\utils.py", line 173, in log_every for obj in iterable: File "D:\Anaconda\envs\CWDetection\lib\site-packages\torch\utils\data\dataloader.py", line 630, in next data = self._next_data() File "D:\Anaconda\envs\CWDetection\lib\site-packages\torch\utils\data\dataloader.py", line 673, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "D:\Anaconda\envs\CWDetection\lib\site-packages\torch\utils\data_utils\fetch.py", line 52, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "D:\Anaconda\envs\CWDetection\lib\site-packages\torch\utils\data_utils\fetch.py", line 52, in data = [self.dataset[idx] for idx in possibly_batched_index] File "D:\Codes\PaperCode\crop_weed_detection_fasterrcnn\datasets.py", line 355, in getitem sample = self.transforms(image=image_resized, File "C:\Users\luowe\AppData\Roaming\Python\Python38\site-packages\albumentations\core\composition.py", line 334, in call self.preprocess(data) File "C:\Users\luowe\AppData\Roaming\Python\Python38\site-packages\albumentations\core\composition.py", line 368, in preprocess p.preprocess(data) File "C:\Users\luowe\AppData\Roaming\Python\Python38\site-packages\albumentations\core\utils.py", line 125, in preprocess data = self.add_label_fields_to_data(data) File "C:\Users\luowe\AppData\Roaming\Python\Python38\site-packages\albumentations\core\utils.py", line 185, in add_label_fields_to_data encoded_labels = encoder.fit_transform(data[label_field]) File "C:\Users\luowe\AppData\Roaming\Python\Python38\site-packages\albumentations\core\utils.py", line 61, in fittransform return self.transform(y) File "C:\Users\luowe\AppData\Roaming\Python\Python38\site-packages\albumentations\core\utils.py", line 57, in transform return np.array([self.classes[label] for label in y]) File "C:\Users\luowe\AppData\Roaming\Python\Python38\site-packages\albumentations\core\utils.py", line 57, in return np.array([self.classes_[label] for label in y]) KeyError: tensor(25)

sovit-123 commented 2 months ago

Hello. It looks like something broke with the updated version of Albumentations. Can you please try with albumentations==1.1.0?

chaser682 commented 2 months ago

@sovit-123 Thank you, the problem is solved now. image

sovit-123 commented 2 months ago

Thanks for the update. Closing the issue for now.