我已经将.mlmodel
转换为.mlmodelc
,我把它放在资源文件夹中。我使用Vision framework
和MNIST
模型,遵循本教程(https://www.youtube.com/watch?v=bOg8AZSFvOc),但使用swift playground。
我错过了什么? (我使用.playground文件,而不是.playgroundbook文件)
代码行:
guard let visionModel = try? VNCoreMLModel(for: MNIST().modelc) else {fatalError("can not load Vision ML model")}
错误信息:
使用未定义的标识符'MNIST'
截图:
Playground默认不识别.mlmodel
文件,因此我们需要一个iOS项目来帮助我们找到已编译的mlmodelc
文件夹,并将mlmodelc
文件夹复制到playground的资源文件夹,并将自动生成的助手类复制到playground的源文件夹并将其更改为上市。然后它的作品!
试试这个项目:https://github.com/DocRace/AnimalClassifier-Swift-Playground