【发布时间】:2019-03-28 10:00:52
【问题描述】:
CoreML 有问题,因为当我希望程序验证图像时出现错误:
[coreml] Error Domain=com.apple.CoreML Code=1 "输入图片特征 图片与型号描述不符” UserInfo={NSLocalizedDescription=输入图像特征图像不 匹配模型描述,NSUnderlyingError=0x2807c0cf0 {Error Domain=com.apple.CoreML Code=1 "图片不是预期类型 OneComponent8,而是 32ARGB" UserInfo={NSLocalizedDescription=图像不是预期类型 OneComponent8, 而不是 32ARGB}}} 2018-10-24 06:47:53.975118+0200 identifyMyFood[25848:7075048] [coreml] 验证输入失败。
下面有一段代码在我进行图像转换的地方被截断:
UIGraphicsBeginImageContextWithOptions(CGSize(width: 343, height: 447), true, 2.0)
image.draw(in: CGRect(x: 0, y: 0, width: 343, height: 447))
let newImage = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
let attrs = [kCVPixelBufferCGImageCompatibilityKey: kCFBooleanTrue, kCVPixelBufferCGBitmapContextCompatibilityKey: kCFBooleanTrue] as CFDictionary
var pixelBuffer : CVPixelBuffer?
let status = CVPixelBufferCreate(kCFAllocatorDefault, Int(newImage.size.width), Int(newImage.size.height), kCVPixelFormatType_32ARGB, attrs, &pixelBuffer)
guard (status == kCVReturnSuccess) else {
return
}
如果有人能帮助我,我将不胜感激!
【问题讨论】: