目录

class info
com.huawei.hms.mlsdk.model.download.MLLocalModelManager
Manager of offline models.

Public Method Summary

Return typeMethod name
com.huawei.hmf.tasks.TaskdeleteModel(MLRemoteModel model)
com.huawei.hmf.tasks.TaskdownloadModel(MLRemoteModel model)
com.huawei.hmf.tasks.TaskdownloadModel(MLRemoteModel model, MLModelDownloadStrategy strategy)
MLLocalModelManagergetInstance()
MLLocalModelManagergetInstance(MLApplication application)
com.huawei.hmf.tasks.Task<setgetModels(Class<T> modelType)
com.huawei.hmf.tasks.TaskgetRecentModelFile(MLRemoteModel model)
com.huawei.hmf.tasks.TaskisModelExist(MLRemoteModel model)

Public Methods

Method

public com.huawei.hmf.tasks.Task<Void> deleteModel(MLRemoteModel model)

Deletes a specified model from the device. If the model has not been downloaded or is being downloaded, a failure message will be returned.

Parameters

Parameter nameParameter desc
modelModel to be deleted.

Return

Typedesc

com.huawei.hmf.tasks.Task<Void>

Task object.
Method

public com.huawei.hmf.tasks.Task<Void> downloadModel(MLRemoteModel model)

Downloads a specified model from the cloud based on the default download condition. If the model does not exist locally or a new version is available on the cloud, the model will be downloaded. Otherwise, the call of this method will stop immediately and onSuccess will be called.

Parameters

Parameter nameParameter desc
modelModel to be downloaded.


Return

Typedesc

com.huawei.hmf.tasks.Task<Void>

Task object.
Method

public com.huawei.hmf.tasks.Task<Void> downloadModel(MLRemoteModel model, MLModelDownloadStrategy strategy)

Downloads a specified model from the cloud based on a specified download condition. If the download condition is not met, a failure message will be returned. If the model does not exist locally or a new version is available on the cloud, the model will be downloaded. Otherwise, the call of this method will stop immediately and onSuccess will be called.

Parameters

Parameter nameParameter desc
modelModel to be downloaded.
strategyCondition for downloading a model.


Return

Typedesc

com.huawei.hmf.tasks.Task<Void>

Task object.
Method
public static synchronized MLLocalModelManager getInstance()
Obtains the current app’s manager instance of offline models.

Return

Typedesc
MLLocalModelManagerManager instance of offline models.
Method
public static synchronized MLLocalModelManager getInstance(MLApplication application)
Obtains a specified app's manager instance of offline models.

Parameters

Parameter nameParameter desc
applicationSpecified app.


Return

Typedesc
MLLocalModelManagerManager instance of offline models.
Method

public com.huawei.hmf.tasks.Task<Set<T>> getModels(Class<T> modelType)

Queries the model set that has been downloaded to a local path.

Parameters

Parameter nameParameter desc
modelTypeModel type to be queried.


Return

Typedesc

com.huawei.hmf.tasks.Task<Set<T>>

Task object that contains the model set.
Method

public com.huawei.hmf.tasks.Task<java.io.File> getRecentModelFile(MLRemoteModel model)

Queries the storage path of a specified model on the device.

Parameters

Parameter nameParameter desc
modelModel to be queried.


Return

Typedesc

com.huawei.hmf.tasks.Task<java.io.File>

Task object that contains the model storage path.
Method

public com.huawei.hmf.tasks.Task<Boolean> isModelExist(MLRemoteModel model)

Checks whether a specified model has been downloaded to the device.

Parameters

Parameter nameParameter desc
modelModel to be queried.


Return

Typedesc

com.huawei.hmf.tasks.Task<Boolean>

Task object that contains the query result. true if the model has been downloaded; false otherwise.