I'm using a script that comes with TF-Slim to validate my trained model. It works fine but I'd like to get a list of the misclassified files.
The script makes use of https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/slim/python/slim/evaluation.py but even there I cannot find any options for printing the misclassified files.
How can I achieve that?
shadow chris pointed me in the right direction so I share my solution to make it work with a TF-records dataset.
For better unstanding I relate my code to the flower example of TF-Slim.
1) Modify your dataset script to store a filename feature in the TF-records.
2) Add filename parameter to data util's
image_to_tfexample
functionIt should then look like:
3) Modify download and convert script to save filenames
Feed your TF record with the filename.
4) In your evaluation map misclassified imgs to filename
I'm refering to eval_image_classifier.py.
Retrieve filenames with tf.train.batch:
Get misclassified imgs and map them to filenames:
Print:
At a high level, you need to do 3 things:
1) Get your filename from the data loader. If you are using a tf-slim dataset from tfrecords, it is likely that the filenames are not stored in the tfrecord so you may be out of luck there. However if you are consuming image files directly from the filesystem with tf.WholeFileReader, then you can get the tensor of filenames where you form your batch:
2) Mask your filename tensor with your result after doing inference:
3) Put all this into your eval_op:
I don't have a setup to test this, unfortunately. Let me know if it works!