AiPackModelProvider

class AiPackModelProvider : ModelProvider


A ModelProvider that's backed by on-demand Google Play AI Pack.

To use this class, you need to declare the following permission in your manifest:

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

NOTE: For install-time AiPack, use ModelProvider.staticModel instead.

Summary

Public constructors

AiPackModelProvider(
    context: <Error class: unknown class>,
    aiPackName: String,
    modelPath: String,
    accelerator: Accelerator,
    vararg moreAccelerators: Accelerator
)

Public functions

open suspend Unit

Downloads the model if it is not available on the device.

open <Error class: unknown class>

Returns the set of accelerators that the model is compatible with.

open String

Returns the absolute path to the model file.

open ModelProvider.Type

It's always a file, for on-demand AiPack.

open Boolean

Returns true if the model is ready to be used.

Inherited functions

From com.google.ai.edge.litert.ModelProvider
open <Error class: unknown class><Void?>

Returns a future that completes when the model is downloaded.

Public constructors

AiPackModelProvider

AiPackModelProvider(
    context: <Error class: unknown class>,
    aiPackName: String,
    modelPath: String,
    accelerator: Accelerator,
    vararg moreAccelerators: Accelerator
)

Public functions

download

open suspend fun download(): Unit

Downloads the model if it is not available on the device.

getCompatibleAccelerators

open fun getCompatibleAccelerators(): <Error class: unknown class>

Returns the set of accelerators that the model is compatible with.

getPath

open fun getPath(): String

Returns the absolute path to the model file.

Throws
java.lang.IllegalStateException

if the AiPack is not ready yet.

getType

open fun getType(): ModelProvider.Type

It's always a file, for on-demand AiPack.

isReady

open fun isReady(): Boolean

Returns true if the model is ready to be used.