如何读取 CoreML 模型预测 MLMultiArray

How to read CoreML model Prediction MLMultiArray

提问人:Qazi Ammar 提问时间:4/20/2022 更新时间:4/20/2022 访问量:358

问:

我是 CoreML 的新手,我生成了一个 coreML 模型,该模型返回 Double 9 × 4 矩阵矩阵,如图像吹奏所示。

enter image description here

这是运行良好的代码,并为我提供了MLMultiArray。

 let outFeatures = try model.prediction(from: input)
        
        // get all 4 featrue array from image
        
        // MLFeature Value
        //1 × 3 × 20 × 20 × 8
        let confidence = outFeatures.featureValue(for: "confidence")?.multiArrayValue
        let coordinates = outFeatures.featureValue(for: "coordinates")?.multiArrayValue

现在我必须读取 MLMultiArray 的每一行以及每行列的值。我在互联网上搜索了很多,但没有找到任何可以迭代 MLMultiArray 的循环方法。任何解决方案。

iOS Swift Xcode Swift3 CoreML

评论


答:

0赞 Alejandro L.Rocha 4/20/2022 #1

看看这 https://github.com/pytorch/ios-demo-app/tree/master/ObjectDetection 帮助我理解了一堆东西,还搜索了一些 yolo coreML

评论

0赞 Qazi Ammar 4/21/2022
是的,我已经看到了这个,但它返回的VNVisionRectangeObject已经具有正确数组的框和信心。