Text-to-Image
Diffusers
stable-diffusion-xl
lora
inference
How to use from the
Use from the
Diffusers library
pip install -U diffusers transformers accelerate
import torch
from diffusers import DiffusionPipeline

# switch to "mps" for apple devices
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", dtype=torch.bfloat16, device_map="cuda")
pipe.load_lora_weights("rajkr/sdxl-pokemon-lora")

prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
image = pipe(prompt).images[0]

🎨 SDXL Text-to-Image Generator

Generate stunning images from text prompts β€” works everywhere: local, Colab, Kaggle.


πŸš€ Quick Start β€” 3 Ways

1️⃣ Local CLI (Like Ollama)

git clone https://huggingface.co/rajkr/sdxl-pokemon-lora
cd sdxl-pokemon-lora
pip install -r clients/requirements.txt

# Download once (~7GB), generate forever β€” auto-cached to ~/.cache/huggingface
python clients/generate.py "a majestic dragon flying over a crystal lake"
python clients/generate.py "an astronaut riding a horse on Mars" --steps 50 --guidance 8.0 --seed 42
python clients/generate.py --list-models
GPU Speed Notes
RTX 4090 (24GB) ~20s/image Best
RTX 3090 (24GB) ~25s/image Great
Colab T4 (16GB) ~60s/image Free
Apple M-series ~5min/image Slow but works
CPU only ~10min/image Very slow

2️⃣ Google Colab (FREE GPU)

Download and open this notebook in Colab, then set GPU Runtime:

πŸ“ Open Colab Notebook

Steps:

  1. Download the notebook from above link
  2. Upload to colab.research.google.com
  3. Set GPU: Runtime β†’ Change runtime type β†’ T4 GPU
  4. Run all cells β€” first run downloads ~7GB, then unlimited free generation

3️⃣ Kaggle (FREE GPU)

πŸ“ Open Kaggle Notebook

Steps:

  1. Download the notebook
  2. Create new Kaggle notebook β†’ Upload
  3. Turn on GPU: Settings β†’ Accelerator β†’ GPU T4
  4. Run all cells

πŸ› οΈ Advanced: Python SDK

from diffusers import AutoPipelineForText2Image
import torch

# Downloads once (~7GB), then runs locally
pipe = AutoPipelineForText2Image.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    torch_dtype=torch.float16,
    variant="fp16",
).to("cuda")

# Generate
image = pipe(
    "a cute fire pokemon with blue flames, anime style",
    num_inference_steps=30,
    guidance_scale=7.5,
).images[0]

image.save("pokemon.png")

πŸ“¦ Files in this Repo

File Description
train_sdxl_lora.py Full training script β€” fine-tune SDXL with LoRA on any image+caption dataset
clients/generate.py CLI tool β€” python generate.py "prompt" β€” works like Ollama
clients/requirements.txt pip install -r this for local setup
clients/colab_notebook.ipynb Google Colab notebook (free T4 GPU)
clients/kaggle_notebook.ipynb Kaggle notebook (free T4 GPU)

🧠 Training Your Own Model

Fine-tune SDXL with LoRA on your own dataset:

pip install torch torchvision diffusers transformers accelerate peft datasets xformers
git clone https://huggingface.co/rajkr/sdxl-pokemon-lora
cd sdxl-pokemon-lora
accelerate launch train_sdxl_lora.py

The LoRA weights will be pushed to: rajkr/sdxl-pokemon-lora

Training Specs

Parameter Value
Base Model stabilityai/stable-diffusion-xl-base-1.0
VAE madebyollin/sdxl-vae-fp16-fix
Dataset reach-vb/pokemon-blip-captions
Method LoRA (rank=16)
Trainable Params ~4.7M (vs. ~2.6B full UNet)
Batch Size 2 Γ— 4 (gradient accumulation)
Resolution 1024Γ—1024
Epochs 3
LR 1e-4 (AdamW, cosine)
Mixed Precision fp16
VRAM ~20-24GB
Hardware A100, A10G, RTX 4090

πŸ–ΌοΈ Sample Prompts

python clients/generate.py "a majestic dragon flying over a crystal lake at sunset, epic fantasy art"
python clients/generate.py "an astronaut riding a horse on Mars, cinematic shot" --steps 50
python clients/generate.py "a cozy coffee shop interior with rain outside" --model stabilityai/stable-diffusion-2-1
python clients/generate.py "a futuristic city skyline at night with neon lights" --guidance 10

πŸ”— Links

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for rajkr/sdxl-pokemon-lora

Adapter
(8378)
this model

Dataset used to train rajkr/sdxl-pokemon-lora