Recognize that an image does not belong to the other 2 prediction patterns ML.NET

Viewed 84

I use the ML.NET Builder to train an image recognition of dogs and cats. Now, when I finish training I choose a picture of a dog or a cat to identify it will return the results.

The problem would be if I were to choose a photo of a flower that in my training library only had pictures of dogs and cats. So how do I know that the picture is not a dog or a cat?

2 Answers

Taking this project for example, a score is given for both options.

You can always check if you get less then 0.7 from both models, you can consider it unknown.

The canonical rule is: If your 'X' value is between 70% and 80%, you've got a good model. If your 'X' value is between 80% and 90%, you have an excellent model. If your 'X' value is between 90% and 100%, it's a probably an overfitting case.

Taking from the project link posted in Indrit Kello answer:

var input = new ModelInput();
input.ImageSource = imagePathTb.Text;
ModelOutput result = ConsumeModel.Predict(input);
float score = (result.Score[0] > result.Score[1] ? result.Score[0] : result.Score[1]);
if (score<.8)
{
   statusRtb.Text = $"Neither Cat nor Dog";
}
else
{              
   statusRtb.Text =$"Predicted result: {result.Prediction} with a score {score}";
}
Related