Fast AI image generation for Apple Silicon. Native CLI with MPS acceleration or containerized with Cog. Lightning LoRA for 4β8 step generation.
Choose your approach:
git clone https://github.com/zsxkib/qwen-image-macos.git
cd qwen-image-macos
pip install -r requirements.txt
python qwen.py generate "cyberpunk cityscape" --ultra-fastgit clone https://github.com/zsxkib/qwen-image-macos.git
cd qwen-image-macos
python3 precache.py # downloads model once (~10 min)
cog predict -i prompt="cyberpunk cityscape" --output city.pngNote: Cog runs ~30x slower on Apple Silicon (60+ min) due to x86_64 emulation. Use native CLI for speed, cog for reproducibility/deployment.
| Method | Time | Platform | GPU | Best For |
|---|---|---|---|---|
| Native CLI | 2 min | Apple Silicon | β MPS | Speed, development |
| Cog (macOS) | 60+ min | x86_64 emulation | β CPU only | Reproducibility |
| Cog (Linux) | ~2-5 min | Native x86_64 | β CUDA | Deployment, cloud |
# Ultra-fast (4 steps with Lightning LoRA)
python qwen.py generate "cyberpunk cityscape" --ultra-fast
# Fast mode (8 steps)
python qwen.py generate "mountain landscape" --fast
# Custom settings
python qwen.py generate "robot on mars" --steps 20 --seed 42
# Test your setup
python qwen.py test- Apple Silicon Mac (M1/M2/M3/M4)
- Python 3.8+
- 32GB+ RAM recommended (64GB+ ideal)
- Native MPS acceleration on macOS
- Simple, single-file CLI (
qwen.py) - Auto-opens generated image in Preview on macOS
- Reproducible seeds and custom sizes
Prerequisites:
- Docker Desktop (macOS: increase memory to 64GB+ in Settings β Resources)
- Cog CLI:
brew install replicate/cog/cog
Quick workflow:
# 1. Pre-download model (recommended, ~10 min)
python3 precache.py
# 2. Generate images
cog predict -i prompt="robot on mars" --output robot.png
cog predict -i prompt="cyberpunk city" -i steps=10 --output city.pngWhen to use cog:
- β Linux/NVIDIA: Fast with CUDA acceleration
- β Reproducible deployments: Exact same environment everywhere
- β Replicate cloud: Deploy to replicate.com
- β Apple Silicon: Use native CLI instead (30x faster)
- Model: Qwen-Image (57GB)
- Acceleration: Lightning LoRA for 4-8 step generation
- Memory: Attention slicing + VAE tiling for efficiency
- Cache: Models stored in
model_cache/(~63GB)
Check Apple Silicon GPU:
python -c "import torch; print('MPS available:', torch.backends.mps.is_available())"Common fixes:
- MPS not available β Update macOS/PyTorch
- Images look unfinished β Increase
--stepsto 20-30 - Cog OOM errors β Increase Docker memory to 64GB+
Native CLI generates high-quality images in ~2 minutes:
Built for Apple Silicon. Optimized for speed. Ready for deployment.
