MLModel.compileModel Throws Exception "A valid manifest does not exist"
I am building an image recognition app for iPhone, using Swift, Vision, CoreML and Resnet50. When I run MLUpdateTask, it gives me an error that my model needs to be re-compiled. So I added a bit of code to re-compile the model, but the added code also throws an error about not finding a valid manifest.
Here's a code snippet:
struct ImageCoreML {
let modelURL = Bundle.main.url(forResource: "Resnet50", withExtension: ".mlmodelc")!
init() {
let url = self.modelURL
Task {
do {
let url = try await MLModel.compileModel(at: url)
} catch {
print("EXCEPTION: cannot compile model due to error:\n\(error)")
return
}
}
}
}
And here's the error message:
EXCEPTION: cannot compile model due to error:
Error Domain=com.apple.CoreML Code=3 "Failed to read model package at file:///private/var/containers/Bundle/Application/4C04FEA8-AC82-404B-AB45-5BD326C2F423/FaceID.app/Resnet50.mlmodelc/. Error: A valid manifest does not exist at path: /private/var/containers/Bundle/Application/4C04FEA8-AC82-404B-AB45-5BD326C2F423/FaceID.app/Resnet50.mlmodelc/Manifest.json" UserInfo={NSLocalizedDescription=Failed to read model package at file:///private/var/containers/Bundle/Application/4C04FEA8-AC82-404B-AB45-5BD326C2F423/FaceID.app/Resnet50.mlmodelc/. Error: A valid manifest does not exist at path: /private/var/containers/Bundle/Application/4C04FEA8-AC82-404B-AB45-5BD326C2F423/FaceID.app/Resnet50.mlmodelc/Manifest.json}
Thanks,
Scott