Javier Vargas Javier Vargas - 11 months ago 95
Python Question

Tensorflow Image Classification Script

So I am quite new in TensorFlow .

I followed all the CodeLab of TensorFlow For Poets, I trained the model using only Daisies and Roses.

Then I used the label_image.py script to test and classify images.

But when I tried with random images that have no roses or daisies I still get a high score.

How can I modify that script or if you know any other script that it can tell me like if there is a Rose or a Daisy or Nothing there.

Answer Source

Softmax will encourage the network to make a decision so you'll usually end up with something.

As Luis said, you can add an "unknown" class to your categories. This is probably the simplest option :)

As the softmax outputs are probabilities, you could also try setting a threshold where anything with a low enough score is considered a no-result, though as above, softmax is a good decision-maker, so it may not work too well.

Since you're using a two-class prediction, another option is to replace softmax with a sigmoid function to get an output between 0 (e.g. roses) and 1 (e.g. daisies). You could then pick a range in the middle (e.g. 0.4-0.6) that you consider uncertain and use that as your "unknown" label.