Package-level declarations

Types

Link copied to clipboard

stable-diffusion.cpp text-to-image engine with streamed progress and cooperative cancellation.

Link copied to clipboard
data class DiffusionEngineOptions(val gpuDevice: Int = 0, val allowBackendFallback: Boolean = true, val keepTextEncoderOnCpu: Boolean = false, val keepVaeOnCpu: Boolean = false, val weightType: Int = WEIGHT_TYPE_AS_STORED)

Diffusion-specific construction options of a DiffusionEngine.

Link copied to clipboard
sealed interface DiffusionEvent

Events of one DiffusionEngine.generate collection.

Link copied to clipboard
data class DiffusionGenerationParams(val prompt: String, val negativePrompt: String = "", val width: Int = DEFAULT_SIZE, val height: Int = DEFAULT_SIZE, val sampleSteps: Int = DEFAULT_SAMPLE_STEPS, val cfgScale: Float = DEFAULT_CFG_SCALE, val distilledGuidance: Float = DEFAULT_DISTILLED_GUIDANCE, val seed: Long = RANDOM_SEED, val sampler: DiffusionSampler = DiffusionSampler.MODEL_DEFAULT, val scheduler: DiffusionScheduler = DiffusionScheduler.MODEL_DEFAULT, val clipSkip: Int = CLIP_SKIP_MODEL_DEFAULT, val vaeTiling: Boolean = false)

One txt2img request. Validated on construction (including via copy); invalid values throw IllegalArgumentException before any native call.

Link copied to clipboard
class DiffusionImage(val width: Int, val height: Int, val channels: Int, val pixels: ByteArray)

A generated image: packed 8-bit RGB (channels = 3), row-major, no row padding, width * height * channels bytes. The pixels were copied out of the native buffer, which is already freed; this object owns plain heap memory.

Link copied to clipboard
data class DiffusionModelFiles(val modelPath: String? = null, val diffusionModelPath: String? = null, val vaePath: String? = null, val taesdPath: String? = null, val clipLPath: String? = null, val clipGPath: String? = null, val t5xxlPath: String? = null, val llmPath: String? = null)

The model files of a DiffusionEngine (UTF-8 paths to .gguf, .safetensors or .ckpt files).

Link copied to clipboard
data class DiffusionModelInfo(val supportsImageGeneration: Boolean, val defaultSampler: DiffusionSampler, val threads: Int)

Static properties of a loaded diffusion model.

Link copied to clipboard
data class DiffusionNativeInfo(val moduleVersion: String, val stableDiffusionCppVersion: String, val stableDiffusionCppCommit: String, val systemInfo: String)

Version information of the native diffusion library.

Link copied to clipboard

Which part of a generation a DiffusionEvent.Progress belongs to.

Link copied to clipboard

stable-diffusion.cpp sampling method (sample_method_t).

Link copied to clipboard

stable-diffusion.cpp noise schedule (scheduler_t).

Functions

Link copied to clipboard
suspend fun DiffusionEngine(model: DiffusionModelFiles, backendConfig: BackendConfig = BackendConfig.DEFAULT, options: DiffusionEngineOptions = DiffusionEngineOptions()): DiffusionEngine

Loads model with stable-diffusion.cpp and returns a ready DiffusionEngine.

suspend fun DiffusionEngine(modelPath: String, backendConfig: BackendConfig = BackendConfig.DEFAULT, options: DiffusionEngineOptions = DiffusionEngineOptions()): DiffusionEngine

Loads a full Stable Diffusion checkpoint (.gguf, .safetensors or .ckpt) with stable-diffusion.cpp and returns a ready DiffusionEngine. Same as the DiffusionModelFiles overload with DiffusionModelFiles(modelPath).