Coreml,验证输入失败。图片无效
Coreml, Failure verifying inputs. Image is not valid
试图关注 https://www.appcoda.com/core-ml-model-with-python/
为了建立图片识别,我使用 Core ML(Turi Create) + Python + Swift(iOS).
试图上传我用于训练“.mlmodel”文件的同一张图片。
没有帮助。试图加载 100x100 尺寸的图片。同样的错误。我还能尝试什么?
输出:
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.
应评论要求:
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)
}
错误消息字面意思是错误的原因是什么:
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}}}
您正在使用的模型(我怀疑它是 SqueezeNet)需要大小为 227x227 的输入图像,而不是 224x224 或任何其他大小。
试图关注 https://www.appcoda.com/core-ml-model-with-python/ 为了建立图片识别,我使用 Core ML(Turi Create) + Python + Swift(iOS).
试图上传我用于训练“.mlmodel”文件的同一张图片。 没有帮助。试图加载 100x100 尺寸的图片。同样的错误。我还能尝试什么?
输出:
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.
应评论要求:
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)
}
错误消息字面意思是错误的原因是什么:
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}}}
您正在使用的模型(我怀疑它是 SqueezeNet)需要大小为 227x227 的输入图像,而不是 224x224 或任何其他大小。