ModelDownloader
public class ModelDownloaderDownloader 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
modelNameThe name of the model, matching Firebase console.
downloadTypeModelDownloadType used to get the model.
conditionsConditions needed to perform a model download.
progressHandlerOptional. Returns a float in [0.0, 1.0] that can be used to monitor model download progress.
completionReturns either a
CustomModelon success, or aDownloadErroron 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
completionReturns either a set of
CustomModelmodels on success, or aDownloadedModelErroron 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
modelNameThe name of the model, matching Firebase console and already downloaded to device.
completionReturns a
DownloadedModelErroron failure.