大神们好,这是我想得到模型的mAP时已经到了训练阶段遇到的问题,困惑了我好久,找不到解决的办法,如果有会的大神请赐教,有酬金,谢谢啦
KeyError Traceback (most recent call last)
<ipython-input-85-83fb3ae74319> in <module>
6 learning_rate=config.LEARNING_RATE,
7 epochs=1,
----> 8 layers='heads')
D:\pythonprojects\lib\site-packages\mrcnn\model.py in train(self, train_dataset, val_dataset, learning_rate, epochs, layers, augmentation)
2360 max_queue_size=100,
2361 workers=workers,
-> 2362 use_multiprocessing=True,
2363 )
2364 self.epoch = max(self.epoch, epochs)
D:\pythonprojects\lib\site-packages\keras\legacy\interfaces.py in wrapper(*args, **kwargs)
89 warnings.warn('Update your `' + object_name + '` call to the ' +
90 'Keras 2 API: ' + signature, stacklevel=2)
---> 91 return func(*args, **kwargs)
92 wrapper._original_function = func
93 return wrapper
D:\pythonprojects\lib\site-packages\keras\engine\training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, validation_freq, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)
1656 use_multiprocessing=use_multiprocessing,
1657 shuffle=shuffle,
-> 1658 initial_epoch=initial_epoch)
1659
1660 @interfaces.legacy_generator_methods_support
D:\pythonprojects\lib\site-packages\keras\engine\training_generator.py in fit_generator(model, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, validation_freq, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)
179 batch_index = 0
180 while steps_done < steps_per_epoch:
--> 181 generator_output = next(output_generator)
182
183 if not hasattr(generator_output, '__len__'):
D:\pythonprojects\lib\site-packages\mrcnn\model.py in data_generator(dataset, config, shuffle, augment, augmentation, random_rois, batch_size, detection_targets)
1712 load_image_gt(dataset, config, image_id, augment=augment,
1713 augmentation=augmentation,
-> 1714 use_mini_mask=config.USE_MINI_MASK)
1715
1716 # Skip images that have no instances. This can happen in cases
D:\pythonprojects\lib\site-packages\mrcnn\model.py in load_image_gt(dataset, config, image_id, augment, augmentation, use_mini_mask)
1290 # classes supported in the dataset of this image.
1291 active_class_ids = np.zeros([dataset.num_classes], dtype=np.int32)
-> 1292 source_class_ids = dataset.source_class_ids[dataset.image_info[image_id]["source"]]
1293 active_class_ids[source_class_ids] = 1
1294
KeyError: 'shapes'
```python
困惑了好久有我在不用怕,你把报错复制出来发给我
keyerror一般指的是你在使用字典里不存在的key产生的错误。
解题思路:
通过用Shape.getLocation方法,去给其中key的值,自行确定赋值
参考链接1:https://vimsky.com/examples/detail/python-ex-shape-Shape-getLocation-method.html
参考链接2:https://javajgs.com/archives/78572
mask rcnn测试中遇到的问题解决
https://blog.csdn.net/qq_34713831/article/details/85797622