svpino / tf_object_detection_cm

Confusion Matrix in Object Detection with TensorFlow
78 stars 36 forks source link

IndexError: index 8 is out of bounds for axis 0 with size 3 #3

Closed soumitra9 closed 5 years ago

soumitra9 commented 5 years ago

Hi, I am getting the following error. Need help.

Traceback (most recent call last): File "confusion_matrix.py", line 134, in tf.app.run(main) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "confusion_matrix.py", line 129, in main confusion_matrix = process_detections(FLAGS.detections_record, categories) File "confusion_matrix.py", line 90, in process_detections confusion_matrix[groundtruth_classes[i] - 1][confusion_matrix.shape[1] - 1] += 1 IndexError: index 8 is out of bounds for axis 0 with size 3

svpino commented 5 years ago

It seems to be a problem with the classes you have specified. Make sure the ground truth classes are all represented properly.

wbowditch commented 5 years ago

I'm getting a similar error, I'll debug to make sure the matches dimensions make sense:

$ python confusion_matrix.py --detections_record=detections.record --label_map=label_map.pbtxt 
Traceback (most recent call last):
  File "confusion_matrix.py", line 133, in <module>
    tf.app.run(main)
  File "/Users/williamhackathon/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "confusion_matrix.py", line 128, in main
    confusion_matrix = process_detections(FLAGS.detections_record, categories)
  File "confusion_matrix.py", line 87, in process_detections
    confusion_matrix[groundtruth_classes[i] - 1][detection_classes[int(matches[matches[:,0] == i, 1][0])] - 1] += 1 
IndexError: index 6 is out of bounds for axis 0 with size 3
wbowditch commented 5 years ago

Found the issue, max_num_classes is hardcoded to 2 on line 129: categories = label_map_util.convert_label_map_to_categories(label_map, max_num_classes=2, use_display_name=True)

svpino commented 5 years ago

Good catch. I fixed it already.