Search code examples
swiftxcodecoremlcreateml

CoreML image model only recognizing the given data sets, how to include outside data?


I have a trained CoreML image model that is supposed to recognize the front and back of checks. I am facing a problem where the model will see an image of a giraffe, and the model is only trying to decide if the image is the front of a check or the back of a check (with the confidence levels totaling 100%). Ideally, the model would not say 'what is the likelyhood this is the back of a check vs the front of a check' but instead 'is this the back of a check'.


Solution

  • If you model is only trained on images of checks, you can only give it images of checks. If you give it some other image, it will assume it's a check because that's the only thing it knows about.

    To make a model that can also detect "no check" you need to add a new category and also train the model with images of all kinds of objects that are not checks.

    Alternatively, you can use some kind of OOD (out of domain) detection, to verify that the input image is similar to the sorts of things the model has been trained on. But that's not something you can easily do with Core ML.