ModelProvider

interface ModelProvider

Known direct subclasses
AiPackModelProvider

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


A model provider that provides a model file and relevant information.

Summary

Nested types

Model files could be either an asset or a file.

Public companion functions

ModelProvider
@<Error class: unknown class>
staticModel(
    type: ModelProvider.Type,
    path: String,
    vararg accelerators: Accelerator
)

Creates a model provider that represents a model available on the device.

Public functions

suspend Unit

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

open <Error class: unknown class><Void?>

Returns a future that completes when the model is downloaded.

Set<Accelerator>

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

String

Returns the path to the model asset or file.

ModelProvider.Type
Boolean

Returns true if the model is ready to be used.

Public companion functions

staticModel

@<Error class: unknown class>
fun staticModel(
    type: ModelProvider.Type,
    path: String,
    vararg accelerators: Accelerator
): ModelProvider

Creates a model provider that represents a model available on the device.

Public functions

download

suspend fun download(): Unit

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

downloadFuture

open fun downloadFuture(lifecycleOwner: <Error class: unknown class>): <Error class: unknown class><Void?>

Returns a future that completes when the model is downloaded.

NOTE: Kotlin callers should use download instead.

getCompatibleAccelerators

fun getCompatibleAccelerators(): Set<Accelerator>

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

getPath

fun getPath(): String

Returns the path to the model asset or file.

getType

fun getType(): ModelProvider.Type

isReady

fun isReady(): Boolean

Returns true if the model is ready to be used.