command line tool for stable diffusion
Project description
sd-tools
generating images from commandline
https://github.com/zweifisch/sd-tools/assets/447862/e39bee8d-f7b4-41d9-b1ec-640f341835b5
pip install sd-tools
Basics
sdxl 'locomotive'
If the model can't be downloaded, try using a huggingface mirror:
export HF_MIRROR=https://hf-mirror.com
To get better result, use more steps and higher resolutions:
sdxl 'locomotive' --size 720 --steps 4
Generate more with --count
:
sdxl 'locomotive' --size 1024x576 --steps 4 --count 3
By default, images are save to output/{seed}-{time}.webp
, which can be customized via -o
:
sdxl 'locomotive' -o 'output/{seed}-{size}-{cfg}-{time}.webp'
Interactive Mode
The loading of the model can task some time, use -i
to enter interactive mode, keeping the model loaded:
sdxl 'locomotive' --size 1024x576 --steps 4 -i
Edited prompt and press enter:
> locomotive
size
, count
, steps
and cfg
can also be set on the fly:
> locomotive size=1024 cfg=1.9
Custom Models
To use a specific model:
sdxl 'locomotive' \
--model Lykon/dreamshaper-xl-lightning \
--steps 6 \
--size 1024x576 \
--scheduler 'DPM++ SDE Karras' \
--cfg 2 \
More models can be found on huggingface and civitai, models with Lightning or Turbo can generate image in less than 8 steps.
For models without fp16 variant or safetensor format, add --no-fp16
or --no-safetensor
sdxl 'locomotive' \
--model RunDiffusion/Juggernaut-XL-Lightning \
--cfg 1.5 \
--steps 6 \
--size 832x1216 \
--scheduler 'DPM++ SDE' \
--no-fp16 --no-safetensor
To use models downloaded from civitai:
sdxl 'locomotive' --model ./model.safetensors
Loras
Loras are like plugins for the base model, multiple loras can be used:
sdxl 'locomotive' \
--model SG161222/RealVisXL_V4.0_Lightning \
--steps 8 \
--size 1024x576 \
--loras ./lora1.safetensors ./lora2.safetensors:0.8 \
Speed Up Generation
Using --lcm
, --tcd
or --lightning
to speed up generation, not necessary for turbo/lightning models:
sdxl 'locomotive' \
--model SG161222/RealVisXL_V4.0 \
--steps 4 \
--size 1024x576 \
--tcd 1 \
More Controlling
Canny
sdxl 'protrait of a man' --canny photo.jpg --canny-low 100 --canny-high 200
Depth
sdxl 'protrait of a man' --depth photo.jpg
Pose
sdxl 'protrait of a man' --pose photo.jpg
Inpainting
sdxl 'helmet' \
--inpaint test/tesla.webp \
--inpaint-mask mask.png \
--steps 40 \
-i \
-o output/preview.png
Open mask.png, paint the area to be modified, close image editor, then press Enter to start inpainting.
Style and Face
Photo Maker
pip install 'sd-tools[photomaker]'
use img
to indicate the reference target
sdxl 'man img holding a toy car' \
--model Lykon/dreamshaper-xl-lightning \
--steps 6 \
--cfg 2 \
--photo-maker test/tesla.webp \
--scheduler 'DPM++ SDE Karras'
multiple reference images can be provided:
--photo-maker 1.png 2.png
IP-Adapter Plus
style reference, multiple images can be used:
sdxl 'portrait of a man' \
--model Lykon/dreamshaper-xl-lightning \
--scheduler 'DPM++ SDE Karras' \
--steps 8 --size 1024x576 \
--ipa-plus test/ghibli \
--ipa-plus-scale 0.7 \
--seed 0
face reference, multiple images can be used:
sdxl 'portrait of a man' \
--model Lykon/dreamshaper-xl-lightning \
--scheduler 'DPM++ SDE Karras' \
--steps 8 --size 1024x576 \
--ipa-plus-face test/tesla-s.webp \
--ipa-plus-scale 0.4 \
--seed 0
combined
sdxl 'portrait of a man' \
--model Lykon/dreamshaper-xl-lightning \
--scheduler 'DPM++ SDE Karras' \
--steps 8 --size 1024x576 \
--ipa-plus test/ghibli \
--ipa-plus-face test/tesla-s.webp \
--ipa-plus-scale 0.7 0.4 \
--cfg 2 \
--seed 0
IP-Adapter FaceID Plus
pip install 'sd-tools[faceid]'
sdxl 'man walking on the moon' \
--model Lykon/dreamshaper-xl-lightning \
--scheduler 'DPM++ SDE Karras' \
--steps 6 \
--cfg 2 \
--ipa-faceid-plus test/tesla.webp
InstantID
pip install 'sd-tools[faceid]'
sdxl 'man walking on the moon' \
--model Lykon/dreamshaper-xl-lightning \
--scheduler 'DPM++ SDE Karras' \
--steps 6 \
--cfg 2 \
--instantid test/tesla.webp
IP Composition Adapeter
sdxl 'Arnold Schwarzenegger' \
--model Lykon/dreamshaper-xl-lightning \
--scheduler 'DPM++ SDE Karras' \
--steps 6 \
--cfg 1.2 \
--ip-composition test/tesla.webp
HTTP Server
sdxl 'man walking on the moon' --listen 127.0.0.1:8800
Invoking using curl:
curl '127.0.0.1:8800?prompt=shell&seed=1' > image.webp
Live Preview
sdxl 'locomotive' --size 512 -i -o output/preview.png
Open output folder in Finder, switch to gallery mode, once generated, image preview will be updated.
You can even set a count to generate more images:
> locomotive count=3
To keep the generated images, pass an additional ouput path:
sdxl 'locomotive' --size 512 -i -o output/preview.png 'output/{seed}.webp'
More Examples
Realvis
sdxl 'portrait of a woman img, chinese paint style' \
--model SG161222/RealVisXL_V4.0_Lightning \
--steps 6 --size 768x1024 \
--scheduler 'DPM++ SDE Karras' \
--cfg 2
DreamShaper
sdxl 'locomotive comming' \
--model Lykon/dreamshaper-xl-lightning \
--steps 6 --size 1024x576 \
--scheduler 'DPM++ SDE Karras' \
--cfg 2
Juggernaut
sdxl 'portrait of a woman, chinese painting style, Full Body Shot' \
--model RunDiffusion/Juggernaut-XL-Lightning \
--cfg 1.9 \
--steps 6 \
--size 832x1216 \
--scheduler 'DPM++ SDE' \
--no-fp16 --no-safetensor
SD 1.5
sd -h
IP-Adapeter FaceID Portrait
sd 'portrait of man, masterpiece' \
--model Lykon/dreamshaper-8 \
--steps 8 \
--lcm 1 \
--ipa-portrait photo1.png photo2.png \
-i
IP-Adapter Plus
sd 'man walking down the street' \
--model Lykon/dreamshaper-8 \
--steps 10 \
--size 760 \
--ipa-plus-scale 0.8 \
--ipa-plus-face test/tesla-s.webp \
--lcm 1
IP-Adapter Plus Face
sd 'man in nature' \
--model Lykon/dreamshaper-8 \
--steps 10 \
--size 760 \
--ipa-plus-scale 0.8 \
--ipa-plus test/ghibli \
--lcm 1
IP Composition Adapeter
sd 'Arnold Schwarzenegger' \
--model Lykon/dreamshaper-8 \
--steps 10 \
--lcm 1 \
--seed 4 \
--ip-composition test/tesla.webp
Sketch to Image
sd 'ethereal fantasy concept art of cat, magnificent, celestial, ethereal, painterly, epic, majestic, magical, fantasy art, cover art, dreamy' \
--sketch sketch.png -i -o output/preview.webp
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sd_tools-1.1.0.tar.gz
.
File metadata
- Download URL: sd_tools-1.1.0.tar.gz
- Upload date:
- Size: 942.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fa531431d498f4baa1e089ccec804fd94bb72e1d46565b3d9f779a4103e7347 |
|
MD5 | e30272029cc7cefdb9d17ea61d29295c |
|
BLAKE2b-256 | 85ed5f6d77a73b69a8e62ee5c91edeeac7c03562d954b8c2247429da57997ad7 |
File details
Details for the file sd_tools-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: sd_tools-1.1.0-py3-none-any.whl
- Upload date:
- Size: 61.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4f131e2c9f50530c043c288de9e11f1fca77ed3a3570ac39acee6f77a398ad9 |
|
MD5 | c8e056ed7d99615d0367ec4467ed523f |
|
BLAKE2b-256 | 5a64562b1aaa714438f4e2ba444d905fe2deb0372e1bc421ce3fcd02d876536e |