天道酬勤,学无止境

mlmodel

无法从 CoreML 模型部署中检索 MLModel(unable to retrieve MLModel from CoreML Model Deployment)

问题 我对 CoreMl 非常陌生,我想从今年在 WWDC 上发布的 Coreml 模型部署中检索模型。 我制作了一个只对特殊和稀有事物进行分类的应用程序,并将该 model.archive 上传到 CoreMl 模型部署仪表板。 我成功部署了模型并显示为活动状态。 现在的问题是我无法检索该模型,我已经尝试了很多,我什至看到了该模型上的所有 WWDC 会话,甚至从该会话中复制了该代码,但都是徒劳的 这是我的整个模型加载和检索代码 我的视觉请求代码 func coremlmodel(using: VNCoreMLModel) -> VNCoreMLRequest { let request = VNCoreMLRequest(model: using, completionHandler: { [weak self] request, error in self?.processClassifications(for: request, error: error) }) request.imageCropAndScaleOption = .centerCrop return request } 我的分类学院将拍摄图像 func updateClassifications(for image: UIImage) { classificationLabel.text =

2021-10-30 12:54:56    分类:技术分享    uikit   coreml   vision   mlmodel

MLModel 适用于 MultiArray 输出,但无法成功将输出更改为图像(MLModel works with MultiArray output but cannot successfully change the output to an image)

问题 我已经使用 coremltools 4.0 将 Keras 模型转换为 MLModel,但成功率有限。 它有效,但前提是我使用 MLMultiArray 进行输出并转换为图像。 转换为图像所需的时间比推理长; 使其无法使用。 如果我尝试更改 MLModel 规范以使用图像进行输出,我会在运行预测时遇到此错误: 无法将输出标识转换为图像: 输出{名称:“身份”类型{图像类型{宽度:2048高度:2048颜色空间: RGB }}} 如果我使用 MultiArray(有效)Xcode 报告: 输出:Float32 1 x 2048 x 2048 x 3 数组 我怀疑问题是第一个维度,即批号,但未显示任何维度,因此我无法删除批维度: 输出 { 名称:“身份”类型 { multiArrayType { 数据类型:FLOAT32 } } } 我不认为我可以只向 Keras Conv2D 输出层添加输出形状,因为它有多个不同形状的入站节点。 以下是输出形状: >>> print(outputLayer.get_output_shape_at(0)) (None, None, None, 3) >>> print(outputLayer.get_output_shape_at(1)) (1, 512, 512, 3) >>> print(outputLayer.get_output

2021-10-30 07:37:41    分类:技术分享    python   keras   coreml   coremltools   mlmodel

unable to retrieve MLModel from CoreML Model Deployment

I am very new to CoreMl and I want to retrieve a model from Coreml model deployment which was released this year at WWDC. I made an app that just classifies special and rare things and I uploaded that model.archive to the CoreMl Model deployment dashboard. I successfully deployed the model and its showing as active. now the problem is I am unable to retrieve that model, I have tried a lot, I even saw all the WWDC sessions on that one and even copied that code from that session but all in vain Here is my whole model loading and retrieving code my Vision request code func coremlmodel(using

2021-10-20 10:06:06    分类:问答    uikit   coreml   vision   mlmodel

MLModel works with MultiArray output but cannot successfully change the output to an image

I have converted a Keras model to a MLModel using coremltools 4.0 with limited success. It works but only if I use an MLMultiArray for the output and covert to an image. Converting to an image takes magnitudes longer than inferencing; making it unusable. If I try to change the MLModel spec to use images for output I get this error running prediction: Failed to convert output Identity to image: NSUnderlyingError=0x2809bad00 {Error Domain=com.apple.CoreML Code=0 "Invalid array shape ( 2048, 2048, 3 ) for converting to gray image" Even though I have specified RGB for the output color: output {

2021-10-11 05:21:11    分类:问答    python   keras   coreml   coremltools   mlmodel