如何在 Swift Playground 中使用 .mlmodel? [英] How do I get the .mlmodel to be used in Swift Playground?
问题描述
我已经将 .mlmodel
转换为 .mlmodelc
,并将其放在资源文件夹中.我使用 Vision framework
和 MNIST
模型,遵循本教程 (
I have already converted the .mlmodel
to .mlmodelc
, and I have put it in the resources folder. Im using Vision framework
and MNIST
model, following this tutorial (https://www.youtube.com/watch?v=bOg8AZSFvOc), but using swift playground.
What am i missing? (im using .playground files, not .playgroundbook files)
line of code:
guard let visionModel = try? VNCoreMLModel(for: MNIST().modelc) else {fatalError("can not load Vision ML model")}
Error message:
use of undefined identifier 'MNIST'
Screenshot:
Playground doesn't recognize the .mlmodel
file by default, so we need an iOS Project to help us find the compiled mlmodelc
folder, and copy the mlmodelc
folder to playground's resource folder, and the auto generated helper class to playground's source folder and change it to public. Then it works!
Try this project: https://github.com/DocRace/AnimalClassifier-Swift-Playground
这篇关于如何在 Swift Playground 中使用 .mlmodel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!