Tried to follow https://www.appcoda.com/core-ml-model-with-python/ To build pictures recognition I use Core ML(Turi Create) + Python + Swift(iOS).
Tried to upload the same image that I've used to train for ".mlmodel" file. Didn't help. Tried to load picture 100x100 size. The same error. What else can I try?
Output:
2018-04-17 20:54:19.076605+0200 [2516:1111075] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2018-04-17 20:54:19.077580+0200 [2516:1111075] [MC] Reading from public effective user settings.
2018-04-17 20:54:54.795691+0200 [2516:1111075] [coreml] Error Domain=com.apple.CoreML Code=1 "Input image feature image does not match model description" UserInfo={NSLocalizedDescription=Input image feature image does not match model description, NSUnderlyingError=0x1c024cf90 {Error Domain=com.apple.CoreML Code=1 "Image is not valid width 227, instead is 224" UserInfo={NSLocalizedDescription=Image is not valid width 227, instead is 224}}}
2018-04-17 20:54:54.795728+0200 [2516:1111075] [coreml] Failure verifying inputs.
Due to request from comments:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String: Any]) {
if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {
previewImg.image = image
if let buffer = image.buffer(with: CGSize(width: 224, height: 224)) {
guard let prediction = try? mlModel.prediction(image: buffer) else {
fatalError("Unexpected runtime error")
}
descriptionLbl.text = prediction.foodType
print(prediction.foodTypeProbability)
} else {
print("failed buffer")
}
}
dismiss(animated: true, completion: nil)
}