Run Stable Diffusion on Apple Silicon using MLX. This repo focuses on SD 1.x models, with a fast, minimal pipeline and a simple CLI. By default it loads NovelAI/nai-anime-v2 UNet + VAE with the SD 1.4 text stack, but you can also run most SD1.5 checkpoints from CivitAI with a single file.
Highlights
- SD 1.4 + SD 1.5 model support on MLX
- Works great on older Macs
- CivitAI
.safetensorsSD1.5 checkpoint loading (UNet + text encoder) - Optional custom VAE from checkpoint
- Simple environment-variable driven prompts
Install deps and generate your first image:
pip install -r requirements.txt
SD_PROMPT="flowers, flower field, sunset, no humans" \
SD_NEGATIVE_PROMPT="humans" \
SD_SEED=56 \
python3 t2i_sd.pyOutput defaults to output.png (use -o to change the filename).
Most SD1.5 models from CivitAI are now supported. Download a SD1.5 .safetensors file and run:
python3 t2i_sd.py --ckpt /path/to/model.safetensorsIf you need a different base config/tokenizer:
python3 t2i_sd.py --ckpt /path/to/model.safetensors --base-model runwayml/stable-diffusion-v1-5By default the VAE comes from the base model for max compatibility. To use the checkpoint’s VAE:
python3 t2i_sd.py --ckpt /path/to/model.safetensors --use-ckpt-vae-o output.png: output filename-n, --no-novelai: useCompVis/stable-diffusion-v1-4--ckpt /path/to/model.safetensors: load SD1.5 checkpoint--base-model runwayml/stable-diffusion-v1-5: base configs/tokenizer--use-ckpt-vae: use the checkpoint’s VAE
SD_PROMPT: positive promptSD_NEGATIVE_PROMPT: negative promptSD_CFG: classifier-free guidance (default 7.5)SD_STEPS: denoising steps (default 50)SD_SEED: seed (0 picks a random one)
Example:
SD_PROMPT="1girl, cinematic lighting" \
SD_NEGATIVE_PROMPT="ugly, disfigured" \
SD_CFG=7.0 SD_STEPS=28 SD_SEED=123 \
python3 t2i_sd.py --ckpt /path/to/model.safetensorsWith SD_STEPS around 28 you can get strong results quickly; 50 steps is the default for higher detail.
- SD 1.4 is especially strong for stylized artwork.
- SD 1.5 shares the same CLIP ViT-L/14 text encoder, which this repo uses.
- SD2/SDXL checkpoints are not supported.