I converted my model with coremltools:
model = tf.keras.models.load_model('mymodel')
mlmodel = ct.convert(model, convert_to="mlprogram",inputs=[ct.ImageType( name="sequential_1_input", shape=(1, 192, 192, 3),
scale=1.0 / 255.0, bias=[-10,-10,-10], color_layout="RGB"], source="tensorflow", classifier_config=ct.ClassifierConfig(class_labels) )
Set model author name
mlmodel.author = 'name'
Set the license of the model
mlmodel.license ="license"
Set a short description for the Xcode UI
mlmodel.short_description ="desc "
Set a version for the model
mlmodel.version = "1.0"
mlmodel.save("my model.mlpackage") `
Then use this on my iOS app
let buffer = unwrapImage.buffer(with: CGSize(width:192, height:192)) # making sure the image is 192x192
let config = MLModelConfiguration()
let imageClassifier = try MyModel(configuration: config)
let result = try imageClassifier.prediction(sequential_1_input: buffer!)
let className: String = result.classLabel
let confidence: Double = result.classLabel_probs[result.classLabel] ?? 1.0
self.the_text = ("\(className)\nWith Confidence:\n\(confidence)")
For testing prediction on Core ML I'm using exactly the same image I'm using in python, but the predictions are all the time wrong, not even close!
So I'm guessing I'm doing something wrong, either when I do the conversion or after, any ideas?