Unable to load CoreML model using MLModel.compileModel(at:)

走远了吗. 提交于 2019-12-13 05:08:00

问题


I am trying to load a .mlmodel file using the following code:

let paths =  FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
var documentsUrl = paths[0]
documentsUrl.appendPathComponent("parallel.mlmodel")
do {
    let compiledModelUrl = try MLModel.compileModel(at: documentsUrl)
    let model = try? MLModel(contentsOf: compiledModelUrl)
} catch {
    print(error.localizedDescription)
}

But I get the error The file couldn’t be saved., the model does exist at that location.


回答1:


I found the answer. I also encountered this problem when I deploy an app to an iphone from Mac in debug mode. Actually, there is nothing wrong with the code, it is something else. I did two things, first signed in to icloud (does icloud have anything to do with its provisioning profile for development?), secondly delete the app and re-deploy the app to the iphone. It solves the problem now. Although I am not sure which one solves my problem, I assume it is the second thing I did. Let me know if anyone found the reason behind.

See my original post. Unable to load CoreML model using MLModel.compileModel



来源:https://stackoverflow.com/questions/53852591/unable-to-load-coreml-model-using-mlmodel-compilemodelat

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!