Pure command-line image generation using Stable Diffusion. No UI, no web server - just a simple Python script.
✅ Pure CLI - no web interface needed ⚡ SDXL Lightning - ultra-fast 4-step generation 🎮 Optimized for RTX 4090 (works on any NVIDIA GPU) 🚀 1-2 second generation time 📦 Uses HuggingFace Diffusers (industry standard)
cd imgen_cli
pip install -r requirements.txtOptional but recommended for RTX 4090:
pip install xformerspython generate.py -p "a beautiful sunset over mountains"That's it! Your image will be saved in the outputs/ folder.
python generate.py -p "a cyberpunk cityscape at night, neon lights"python generate.py -p "portrait of a cat" -n "blurry, low quality, distorted"python generate.py -p "detailed fantasy landscape" -s 8python generate.py -p "abstract art" -w 768 -h 768python generate.py -p "red sports car" --seed 42python generate.py \
-p "majestic dragon flying over castle" \
-n "blurry, low quality" \
-s 8 \
-w 1024 \
-h 1024 \
--seed 12345 \
-o my_images| Option | Short | Description | Default |
|---|---|---|---|
--prompt |
-p |
Image description (required) | - |
--negative |
-n |
Negative prompt | "" |
--steps |
-s |
Number of steps | 4 |
--width |
-w |
Image width | 1024 |
--height |
-h |
Image height | 1024 |
--seed |
- | Random seed | Random |
--output |
-o |
Output directory | outputs |
--model |
-m |
Model to use | SDXL-Lightning |
With RTX 4090:
- First run: ~30 seconds (model download + loading)
- Subsequent runs: ~1-2 seconds per image
- VRAM usage: ~8-10 GB
- Resolution: Up to 1024x1024
python generate.py -p "your prompt"- Ultra-fast (4 steps)
- Excellent quality
- Best for most use cases
You can use other models from HuggingFace:
# Stable Diffusion XL Base
python generate.py -p "your prompt" -m "stabilityai/stable-diffusion-xl-base-1.0" -s 20
# Stable Diffusion 2.1
python generate.py -p "your prompt" -m "stabilityai/stable-diffusion-2-1" -s 30- Reduce resolution:
-w 768 -h 768 - Use fewer steps:
-s 2
- Make sure you have CUDA installed
- Install xformers:
pip install xformers - Check GPU usage:
nvidia-smi
The model will auto-download on first run. Make sure you have internet connection and ~7GB free disk space.
-
Be specific in prompts: "portrait of elderly wizard with long white beard, magical staff, fantasy art" is better than "wizard"
-
Use negative prompts: Add "-n 'blurry, low quality, distorted'" to avoid common issues
-
Experiment with steps: SDXL Lightning works great at 4 steps, but try 6-8 for even better quality
-
Use seeds for iteration: When you get a good image, note its seed and reuse it with variations of the prompt
-
Batch generation: Create a simple loop in bash/PowerShell to generate multiple variations
- Python 3.10+
- NVIDIA GPU with 8GB+ VRAM (RTX 4090 recommended)
- CUDA 11.8+ or 12.x
- ~10GB free disk space (for models)
Uses HuggingFace Diffusers library. Model licenses vary by model.