I have an iOS Message Filter App Extension
set-up and I have a CoreML .mlmodel
file that I want to use in this extension.
The mlmodel
has a Target Membership for both the app, and the app extension.
But when I try to use it from the ILMessageFilterExtension
class, I am getting the following error:
Error Domain=com.apple.CoreML Code=0 "initialization of text classifier model with model data failed" UserInfo={NSLocalizedDescription=initialization of text classifier model with model data failed}
This is my code (MessageClassifier
is my model's generated class name) :
do {
let config = MLModelConfiguration()
let model = try MessageClassifier(configuration: config)
let messageClassifier = MessageClassifierInput(text: message)
let prediction = try model.prediction(input: messageClassifier)
let classification = MessageClassification(stringLiteral: prediction.label)
return classification.messageFilterAction
} catch {
logger.log(level: .os, icon: "‼️", "Message classification failure: \(error)")
}
Any idea why this could happen? Couldn't find anything online or any permissions I need to add for this.