Search code examples
swiftimage-recognitionios11coreml

Core ML iOS 11 not recognizing images properly


I tried Core ML which was recently introduced in iOS to recognise and classify images. The problem is, it is not giving proper results for the images sent.

If i send an earth image(Globe) it is giving me the class as bubble. Below is the code i used,

            let model = Resnet50()

            let pixelBuffer: CVPixelBuffer =  (modelImg.pixelBuffer())!

            if let prediction = try? model.prediction(image: pixelBuffer) {
                print( "Found it!! It is a/an \(prediction.classLabel)")
            }

Is it possible to train the Model with custom use cases on top of the existing Core ML model?(For ex. Resnet50)


Solution

  • Core ML can only be used for inference with already trained models. You will have to use some other tool to previously train your model, and then convert it to Core ML, using Core ML Tools. You can find the supported third-party machine learning tools and formats in the documentation:

    https://developer.apple.com/documentation/coreml/converting_trained_models_to_core_ml