HI,
I have archived CoreML model and deployed it in CoreML Model deployment site. If I try to access it in app, facing issue like "Failed to begin access for model collection with identifier". I have double checked the identifiers in my app and CoreML model deployment, both are same. Not sure what mistake I'm making, Thanks in advance.
func asddasd() {
if #available(iOS 14.0, *) {
let progress = MLModelCollection.beginAccessing(identifier: "MainCoreMLCollection", completionHandler: modelCollectionAvailable)
debugPrint(progress)
} else {
// Fallback on earlier versions
}
}
@available(iOS 14.0, *)
func modelCollectionAvailable(result: Result<MLModelCollection, Error>) {
switch result {
case .success(let collection):
debugPrint("Model collection \(collection.identifier) is now available.")
// Load a model from the collection.
loadModel("BCGSearchClassifier", from: collection)
case .failure(let error):
debugPrint("Error accessing a model collection: \(error)")
}
}
@available(iOS 14.0, *)
func loadModel(_ modelName: String, from collection: MLModelCollection) {
debugPrint(collection.entries[modelName])
guard let entry = collection.entries[modelName] else {
debugPrint("Couldn't find model \(modelName) in \(collection.identifier).")
return
}
MLModel.load(contentsOf: entry.modelURL) { result in
switch result {
case .success(let modelFromCollection):
// Use the modelFromCollection instance.
debugPrint("success")
debugPrint(modelFromCollection)
case .failure(let error):
debugPrint("Error loading model \(modelName) in \(collection.identifier): \(error).")
}
}
}
ERROR:
MLModelCollection: namespace (TeamID.BCGCoreMLCollection) download failed. Error Domain=com.apple.trial Code=0 "Unknown error." UserInfo={NSLocalizedDescription=Unknown error.}
Error Domain=com.apple.CoreML Code=10 \"Failed to begin access for model collection with identifier \'MainCoreMLCollection\': invalid identifier\" UserInfo={NSLocalizedDescription=Failed to begin access for model collection with identifier \'MainCoreMLCollection\': invalid identifier}"
Post
Replies
Boosts
Views
Activity
HI,
I have archived CoreML model and deployed it in CoreML Model deployment. If I try to access it in app, facing issue like "Failed to begin access for model collection with identifier". I have double checked the identifiers in my app and CoreML model deployment, both are same. Not sure what mistake I'm making, Thanks in advance.
Please view my code used in Xcode as below:
func asddasd() {
if #available(iOS 14.0, *) {
let progress = MLModelCollection.beginAccessing(identifier: "MainCoreMLCollection", completionHandler: modelCollectionAvailable)
debugPrint(progress)
} else {
// Fallback on earlier versions
}
}
@available(iOS 14.0, *)
func modelCollectionAvailable(result: Result<MLModelCollection, Error>) {
switch result {
case .success(let collection):
debugPrint("Model collection \(collection.identifier) is now available.")
// Load a model from the collection.
loadModel("BCGSearchClassifier", from: collection)
case .failure(let error):
debugPrint("Error accessing a model collection: \(error)")
}
}
@available(iOS 14.0, *)
func loadModel(_ modelName: String, from collection: MLModelCollection) {
debugPrint(collection.entries[modelName])
guard let entry = collection.entries[modelName] else {
debugPrint("Couldn't find model \(modelName) in \(collection.identifier).")
return
}
MLModel.load(contentsOf: entry.modelURL) { result in
switch result {
case .success(let modelFromCollection):
// Use the modelFromCollection instance.
debugPrint("success")
debugPrint(modelFromCollection)
case .failure(let error):
debugPrint("Error loading model \(modelName) in \(collection.identifier): \(error).")
}
}
}
ERROR:
MLModelCollection: namespace (TeamID.BCGCoreMLCollection) download failed. Error Domain=com.apple.trial Code=0 "Unknown error." UserInfo={NSLocalizedDescription=Unknown error.}
Error Domain=com.apple.CoreML Code=10 \"Failed to begin access for model collection with identifier \'MainCoreMLCollection\': invalid identifier\" UserInfo={NSLocalizedDescription=Failed to begin access for model collection with identifier \'MainCoreMLCollection\': invalid identifier}"