1

So I have followed this tutorial and retrained using my own images. https://www.tensorflow.org/tutorials/image_retraining

So I now have an "output_graph.pb" and a "output_labels.txt" (which I can use with other code to classify images).

But how do I actually generate a confusion matrix using a folder of testing images (or at least with the images it was trained on)?

There is https://www.tensorflow.org/api_docs/python/tf/confusion_matrix but that doesnt seem very helpful.

This thread seems to just be using numbers to represent labels rather than actual files, but not really sure: how to create confusion matrix for classification in tensorflow

And Im not really sure how to use the code in this thread either: How do i create Confusion matrix of predicted and ground truth labels with Tensorflow?

Community
  • 1
  • 1
Bonkoodle
  • 11
  • 2

1 Answers1

0

I would try to create you confusion matrix manually, using something like this steps:

  • Modify the label_image example to print out just the top label.
  • Write a script to call the modified label_image repeatedly for all images in a folder.
  • Have the script print out the ground truth label, and then call label_image to print the predicted one.

You should now have a text list of all your labels in the console, something like this:

apple,apple apple,pear pear,pear pear,orange ...

Now, create a spreadsheet with both row and column names for all the labels:

       | apple | pear | orange
-------+----------------------
apple  |
pear   |
orange |

The value for each cell will be the number of pairs that show up in your console list for row, column. For a small set of images you can compute this manually, or you can write a script to calculate this if there's too many.

Pete Warden
  • 2,866
  • 1
  • 13
  • 12