Termux-Diffusion Logo

Termux-Diffusion

v1.1.1 (Dual Engine)
PyPI (Python) npm (Node.js) 💖 Sponsor GitHub Repository

Quickstart & Integration Recipes

Ready-to-use recipes for programmatic integration across Python and Node.js environments.

Recipe 1: High-Fidelity Photorealism (Python)

from termux_diffusion import generate

result = generate(
    prompt="RAW photo, portrait of a happy smiling young Korean man in his 30s wearing glasses and hoodie, working on laptop, photorealistic, cinematic",
    negative_prompt="blurry, bad anatomy, deformed, distorted",
    model="realistic",
    device="cpu",
    steps=10,
    cfg_scale=4.0,
    output="portrait.png"
)
print(f"Artifact: {result.path}")
print(f"Samsung Gallery: {result.gallery_path}")
print(f"Latency: {result.elapsed_sec:.2f}s")

Recipe 2: Low-Latency Prototyping (Node.js)

const { generate } = require('termux-diffusion');

async function main() {
    const result = await generate({
        prompt: 'retro futuristic robot sipping coffee in cafe, 8k',
        model: 'sdxs',
        device: 'cpu',
        steps: 2,
        output: 'robot.png'
    });
    console.log(`Rendered in: ${result.elapsedSec}s`);
    console.log(`Gallery: ${result.galleryPath}`);
}

main().catch(console.error);

Recipe 3: GPU Hardware Compute Targeting

# Offload compute to mobile GPU (Adreno / Samsung Xclipse)
generate("speedy sports car in city", model="speed", device="gpu")