ModelDownloader
public class ModelDownloader
Downloader to manage custom model downloads.
-
Model downloader with default app.
Declaration
Swift
public static func modelDownloader() -> ModelDownloader
-
Model Downloader with custom app.
Declaration
Swift
public static func modelDownloader(app: FirebaseApp) -> ModelDownloader
-
Downloads a custom model to device or gets a custom model already on device, with an optional handler for progress.
Declaration
Swift
public func getModel(name modelName: String, downloadType: ModelDownloadType, conditions: ModelDownloadConditions, progressHandler: ((Float) -> Void)? = nil, completion: @escaping (Result<CustomModel, DownloadError>) -> Void)
Parameters
modelName
The name of the model, matching Firebase console.
downloadType
ModelDownloadType used to get the model.
conditions
Conditions needed to perform a model download.
progressHandler
Optional. Returns a float in [0.0, 1.0] that can be used to monitor model download progress.
completion
Returns either a
CustomModel
on success, or aDownloadError
on failure, at the end of a model download. -
Gets the set of all downloaded models saved on device.
Declaration
Swift
public func listDownloadedModels(completion: @escaping (Result<Set<CustomModel>, DownloadedModelError>) -> Void)
Parameters
completion
Returns either a set of
CustomModel
models on success, or aDownloadedModelError
on failure. -
Deletes a custom model file from device as well as corresponding model information saved in UserDefaults.
Declaration
Swift
public func deleteDownloadedModel(name modelName: String, completion: @escaping (Result<Void, DownloadedModelError>) -> Void)
Parameters
modelName
The name of the model, matching Firebase console and already downloaded to device.
completion
Returns a
DownloadedModelError
on failure.