Skip to main content

//clika-runtime/io.clika.modelverse/ImageGenerationModel

ImageGenerationModel

[common]
class ImageGenerationModel : PreTrainedModel

An image-generation model: a prompt in, pictures out (the text-to-image kind), each as the RGBA pixels an Android bitmap takes.

Open it with open from a checkpoint the model library's image-generation families claim (a family that declares a picture out of text). Hand it a prompt with generate; the pictures arrive through the listener on the model's own worker thread, one request at a time per model. close frees the weights.

Types​

NameSummary
Companion[common]
object Companion

Properties​

NameSummary
capabilities[common]
val capabilities: Capabilities
What the model takes and gives, read when it opened: Capabilities.defaultImageWidth and Capabilities.defaultImageHeight are the picture size a request of 0 by 0 takes.
config[common]
open override val config: PretrainedConfig
The checkpoint's identity, read when the model opened.

Functions​

NameSummary
close[common]
open fun close()
Free the model. A running request is canceled first and the call waits for it to return; called from inside a listener callback, the free runs right after that callback's request ends instead. Idempotent.
generate[common]
fun generate(prompt: String, options: ImageGenerationOptions = ImageGenerationOptions(), listener: ImageGenerationListener): ImageGenerationHandle
Generate pictures for prompt under options. Returns at once; the worker runs the request and calls listener on its thread: ImageGenerationListener.onImages with the pictures and the seed the model drew, then ImageGenerationListener.onDone with the ImageGenerationReport. A knob left at its zero keeps the model's own default.
residency[common]
open override fun residency(): ResidencyReport
What the model holds on each device right now (ResidencyReport); a closed model refuses with ModelverseException.