SDXL done properly
Lesson "sdxl", in the group Pictures: models of the lesson list. Steps: 9.
What you will be able to do
You set an SDXL graph to the size and the settings the family was trained for.
What you need
- It goes on from A first picture from text. The card says so; it is a hint, not a lock.
- Model files the lesson checks:
- an SDXL checkpoint (SDXL, Pony, Illustrious), not SD 1.5, Flux or a diffusion-only file:
models/checkpoints, for examplesd_xl_base_1.0.safetensors.
- an SDXL checkpoint (SDXL, Pony, Illustrious), not SD 1.5, Flux or a diffusion-only file:
- Nodes: Load Checkpoint, CLIP Text Encode (Prompt), Empty Latent Image, KSampler, VAE Decode, Save Image / Preview Image.
- The app downloads and installs nothing. The step texts below say which files and folders, and which ComfyUI template names them.
The steps
The words of each step, as the lesson shows them. Node names are in bold.
What SDXL is (reading)
SDXL by Stability AI is a family of one base model and thousands of models trained further from it: Juggernaut XL, RealVis XL and many more. Each is one checkpoint file with the model, two text encoders and the VAE.
SDXL was trained at about one megapixel. At 512 by 512, the size of SD 1.5, it draws badly: repeated objects, broken faces. This lesson sets the graph to its own numbers, as ComfyUI's template "SDXL1.0: Text to Image (Simple)" does.
A picture graph is needed
This lesson goes on from the graph of the lesson "A first picture from text". The canvas must have Load Checkpoint, two CLIP Text Encode (Prompt) nodes, Empty Latent Image, KSampler, VAE Decode and Save Image with their links.
If they are not there, do that lesson first.
Choose an SDXL model
In the
ckpt_namefield of Load Checkpoint choose an SDXL model: the basesd_xl_base_1.0.safetensorsor one trained further from it. The files lie in models/checkpoints.An SDXL file is about 6.5 GB; an SD 1.5 one is 2 to 4 GB. Pony and Illustrious are SDXL too, and have a lesson of their own.
Set the size of SDXL
In Empty Latent Image set
widthandheightto 1024.Other sizes of the same area: 896 by 1152, 832 by 1216, 768 by 1344, and the same turned on its side. Keep near one megapixel and both sides divisible by 64.
Set the sampler
In KSampler set:
steps: 25;cfg: 7;sampler_name:dpmpp_2m;scheduler:karras.
These are the numbers of ComfyUI's template. A model trained further may ask for others on its page: then its page wins.
Both texts work
Write the prompt in the
textfield of CLIP Text Encode (Prompt), and in thetextfield of the other text node what is not wanted: blurry, low quality, watermark.SDXL works with cfg above 1, so its negative is read. It understands short sentences and comma lists equally; the models trained further on tags have their own lesson.
Two encoders, one text (reading)
SDXL reads the prompt with two encoders, CLIP-L and the larger OpenCLIP-G. The usual text node gives the same text to both, as the template does, and this is right for nearly every case.
The node CLIP Text Encode (SDXL) has a field for each,
text_gandtext_l, and fields for the size. Few people need it.The refiner: a piece of history (reading)
SDXL 1.0 came with a second model, the refiner, which finished the last steps. ComfyUI's template "SDXL Simple" still shows it: the base does 20 of 25 steps and hands the rest over.
Models trained further do not need it and it can spoil their faces. Today a second pass is done by redrawing with any model you like: the lesson "Refining with a second model".
The graph is ready (reading)
Save the graph with "File ▸ Save workflow for ComfyUI…", open the file in ComfyUI and run it there. This app runs nothing in ComfyUI itself.
If the result is bad:
- doubled people or objects: the size is far from one megapixel;
- burnt, oversharp colours:
cfgtoo high, try 5; - a washed-out picture: the model may need a VAE file of its own; its page says so.
What the lesson checks
A reading step is done when you press Got it, next. A doing step ticks itself off when the canvas holds:
- Step 2, A picture graph is needed:
- a Load Checkpoint node.
- a CLIP Text Encode (Prompt) node.
- a CLIP Text Encode (Prompt) node.
- a Empty Latent Image node.
- a KSampler node.
- a VAE Decode node.
- a Save Image or Preview Image node.
CLIPof Load Checkpoint intoclipof CLIP Text Encode (Prompt) (prompt) (a Load LoRA or CLIP Set Last Layer in between is accepted).CLIPof Load Checkpoint intoclipof CLIP Text Encode (Prompt) (negative prompt) (a Load LoRA or CLIP Set Last Layer in between is accepted).MODELof Load Checkpoint intomodelof KSampler (a Load LoRA or LoraLoaderModelOnly or ModelSamplingSD3 in between is accepted).CONDITIONINGof CLIP Text Encode (Prompt) (prompt) intopositiveof KSampler.CONDITIONINGof CLIP Text Encode (Prompt) (negative prompt) intonegativeof KSampler.LATENTof Empty Latent Image intolatent_imageof KSampler.LATENTof KSampler intosamplesof VAE Decode.VAEof Load Checkpoint intovaeof VAE Decode.IMAGEof VAE Decode intoimagesof Save Image or Preview Image.
- Step 3, Choose an SDXL model:
ckpt_nameof Load Checkpoint holds an SDXL checkpoint (SDXL, Pony, Illustrious), not SD 1.5, Flux or a diffusion-only file; such a file lies inmodels/checkpoints, for examplesd_xl_base_1.0.safetensors.
- Step 4, Set the size of SDXL:
widthof Empty Latent Image is from 640 to 1536; Do this for me sets 1024. Why: SDXL was trained near one megapixel; at 512 it repeats objects.heightof Empty Latent Image is from 640 to 1536; Do this for me sets 1024. Why: SDXL was trained near one megapixel; at 512 it repeats objects.
- Step 5, Set the sampler:
stepsof KSampler is from 20 to 40; Do this for me sets 25. Why: the SDXL template uses 25 steps.cfgof KSampler is from 4 to 9; Do this for me sets 7. Why: a cfg that is too high burns the colors; the SDXL template uses 7.sampler_nameof KSampler isdpmpp_2m.schedulerof KSampler iskarras.
- Step 6, Both texts work:
textof CLIP Text Encode (Prompt) (prompt) holds at least 20 characters.textof CLIP Text Encode (Prompt) (negative prompt) holds at least 5 characters.
What next
These lessons go on from this one: Pony and Illustrious: tags instead of sentences, SD 3.5: one file and a new empty latent.