Termux-Diffusion Logo

Termux-Diffusion

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

Advanced Parameters & High-Precision Controls

Direct low-level control over the underlying Bionic C++ sd-cli (stable-diffusion.cpp) engine with robust error isolation, automatic boundary clamping, and zero-overhead defaults.

Parameter Quick Reference Table

Parameter (Python / JS) CLI Flag Valid Choices / Range Default Description
sampling_method / samplingMethod --sampler euler, euler_a, heun, dpm2, dpm++2s_a, dpm++2m, dpm++2mv2, ipndm, lcm euler_a Denoising sampler algorithm
schedule --schedule default, discrete, karras, exponential, ays, gits default Noise sigma schedule
vae_tiling / vaeTiling --vae-tiling true / false false Reduces peak memory by ~70% during VAE decoding
init_img / initImg -i, --init-img Valid image filepath (PNG/JPG) None Source image for Image-to-Image (Img2Img)
strength --strength 0.0 to 1.0 0.75 Img2Img denoising strength
lora_dir / loraDir --lora-dir Valid directory path None Directory containing LoRA adapter weights
clip_skip / clipSkip --clip-skip 1 or 2 None Skips final CLIP text encoder layers
control_net / controlNet --control-net Valid ControlNet model path None Spatial conditioning model
control_image / controlImage --control-image Valid guide image path None Guide image for ControlNet
control_strength / controlStrength --control-strength 0.0 to 2.0 0.9 Influence weight of ControlNet conditioning
taesd --taesd Valid TAESD model path None Tiny AutoEncoder for 0.1s VAE decoding

1. Samplers & Schedulers

Pairing dpm++2m with the karras scheduler yields photorealistic facial textures and skin micro-details in only 10 to 12 steps.

# Python SDK
from termux_diffusion import generate

result = generate(
    "hyperrealistic portrait of a cyberpunk hacker, neon lighting, 8k",
    model="realistic",
    sampling_method="dpm++2m",
    schedule="karras",
    steps=12,
    cfg_scale=4.0
)

2. VAE Tiling (Mobile Peak RAM Reduction)

Splits latent decoding into 64x64 spatial tiles, slashing peak VRAM/RAM consumption by 70% to prevent Android Low Memory Killer (LMK) termination.

# Python SDK
generate("futuristic landscape", width=768, height=768, vae_tiling=True)

3. Image-to-Image (Img2Img)

Transform sketches, rough drawings, or existing photos into finished AI art.

# CLI Execution
termux-diffusion generate "convert sketch into oil painting" -i /sdcard/Pictures/sketch.png --strength 0.70

Safety, Boundary Clamping & Fail-Fast Isolation

  • Missing File Safety: If init_img or control_net points to a non-existent file, the wrapper immediately halts with a clear FileNotFoundError to avoid unintended generation.
  • Automatic Clamping: Out-of-bounds numbers (e.g. strength=999 or clip_skip=50) are automatically clamped to valid ranges (1.0 and 2) with actionable warning logs.
  • Zero-Overhead Defaults: Unset parameters are cleanly omitted from the C++ command line, preserving 100% baseline speed.