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


Posted on Jul 30, 2023 1:09 PM

Reply

Similar questions

2 replies

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

MLModel.compileModel Throws Exception "A valid manifest does not exist"

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.