Reputation: 23
I'm using MLKit with iOS in a react native project.
Basically using this code: https://firebase.google.com/docs/ml/ios/label-images-with-automl
It used to work fine but now i get this error:
downloadModel: notificationDidFail:
name = com.google.mlkit.notif.model-download-did-fail,
object = Optional(<MLKModelDownloader: 0x281a86300>),
userInfo = Optional([AnyHashable("MLKModelDownloadUserInfoKeyError"): Error Domain=com.google.mlkit Code=2 "Failed to save AutoML remote model labels file." UserInfo={NSLocalizedDescription=Failed to save AutoML remote model labels file.}, AnyHashable("MLKModelDownloadUserInfoKeyRemoteModel"): name: lepidoptera_underside])
Xcode prints: [MLKit][I-MLK018012] AutoML remote model inference info contains no labels
One model seems to work more often than the others.
This gets executed:
NotificationCenter.default.addObserver(
forName: .mlkitModelDownloadDidFail,
object: nil,
queue: nil
) { notification in
self.failed("downloadModel: notification error: \(notification)")
}
The whole download model function:
func downloadModel() {
guard let remoteModel = remoteModel else {
failed("downloadModel: remoteModel error")
return
}
let downloadConditions = ModelDownloadConditions(
allowsCellularAccess: true,
allowsBackgroundDownloading: true
)
_ = ModelManager.modelManager().download(
remoteModel,
conditions: downloadConditions
)
NotificationCenter.default.addObserver(
forName: .mlkitModelDownloadDidSucceed,
object: nil,
queue: nil
) { [weak self] notification in
guard let strongSelf = self,
let userInfo = notification.userInfo,
let model = userInfo[ModelDownloadUserInfoKey.remoteModel.rawValue]
as? RemoteModel,
model.name == strongSelf.modelName
else { return }
strongSelf.createLabeler()
}
NotificationCenter.default.addObserver(
forName: .mlkitModelDownloadDidFail,
object: nil,
queue: nil
) { notification in
self.failed("downloadModel: notification error: \(notification)")
}
}
Upvotes: 2
Views: 625
Reputation: 882
The documentation provided (https://firebase.google.com/docs/ml/ios/label-images-with-automl) contains outdated information. ML Kit has fully deprecated and removed the GoogleMLKit/ImageLabelingAutoML
pod in its recent versions. That pod is now replaced by the GoogleMLKit/ImageLabelingCustom
pod. The latest version of MLKitImageLabelingCustom
pod is 1.2.0
. Please refer to the full migration guide here:
https://developers.google.com/ml-kit/vision/image-labeling/automl/migrate-automl
Upvotes: 2