Skip to main content

command line tool for stable diffusion

Project description

sd-tools

pip install sd-tools

Basics

sdxl 'locomotive comming' --size 512

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 resolution:

sdxl 'locomotive comming' --size 720 --steps 4

Generate more with different resolution:

sdxl 'locomotive comming' --size 1024x576 --steps 4 --count 4

Interactive Mode

The loading of the model can task some time, use -i to enter interactive mode, keeping the model loaded:

sdxl 'locomotive comming' --size 1024x576 --steps 4 -i

Edited prompt and press enter:

> locomotive comming

size, count and cfg can also be set on the fly:

> locomotive comming size=1024

Custom Models

To use a specific model:

sdxl --model Lykon/dreamshaper-xl-lightning \
 --steps 6 \
 --size 1024x576 \
 --scheduler 'DPM++ SDE Karras' \
 --cfg 2 \
 'locomotive comming'

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 and safetensor format, add --no-fp16 and --no-safetensor

sdxl --model RunDiffusion/Juggernaut-XL-Lightning \
 --cfg 1.5 \
 --steps 6 \
 --size 832x1216 \
 --scheduler 'DPM++ SDE' \
 --no-fp16 --no-safetensor \
 'locomotive comming'

To use models downloaded from civitai:

sdxl --model ./model.safetensors 'locomotive comming'

Loras

Loras are like plugins for the base model, multiple loras can be used:

sdxl \
 --model SG161222/RealVisXL_V4.0_Lightning \
 --steps 8 \
 --size 1024x576 \
 --loras ./lora1.safetensors ./lora2.safetensors:0.8 \
 'locomotive comming'

Speed Up Generation

Using --lcm, --tcd or --lightning to speed up generation, not necessary for turbo/lightning models:

sdxl \
 --model SG161222/RealVisXL_V4.0 \
 --steps 4 \
 --size 1024x576 \
 --tcd 1 \
 'locomotive comming'

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

Style and Face

Photo Maker

pip install sd-tools[photomaker]

use img to indicate the reference target

sdxl \
 --model Lykon/dreamshaper-xl-lightning \
 --steps 8 \
 --size 1024 \
 --scheduler 'DPM++ SDE Karras' \
 --photo-maker ./photos \
 'portrait of a man img'

reference images can also be specified by filenames

--photo-maker 1.png 2.png

IP-Adapter Plus

style reference

sdxl 'Mario' --ipa-plus ./styles/

face reference

sdxl 'Mario' --ipa-plus-face face1.png face2.png

combined

sdxl 'Mario' --ipa-plus ./styles --ipa-plus-face ./faces

IP-Adapter FaceID Plus

pip install sd-tools[faceid]
sdxl 'Mario' --ipa-faceid face.png

InstantID

pip install sd-tools[faceid]
sdxl 'Mario' --instanceid face.png

HTTP Server

sdxl 'Mario' --listen '127.0.0.1:8800'

invoke using curl:

curl '127.0.0.1:8800?prompt=shell&seed=1' > image.webp

More Examples

sdxl --model RunDiffusion/Juggernaut-XL-Lightning \
 --prompt 'portrait of a woman' \
 --cfg 1.5 \
 --steps 5 \
 --size 832x1216 \
 --scheduler 'DPM++ SDE' \
 --no-fp16 --no-safetensor

SD 1.5

TBD

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sd_tools-1.0.0.tar.gz (31.7 kB view details)

Uploaded Source

Built Distribution

sd_tools-1.0.0-py3-none-any.whl (43.7 kB view details)

Uploaded Python 3

File details

Details for the file sd_tools-1.0.0.tar.gz.

File metadata

  • Download URL: sd_tools-1.0.0.tar.gz
  • Upload date:
  • Size: 31.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for sd_tools-1.0.0.tar.gz
Algorithm Hash digest
SHA256 bc332d8dba0a5e7489c25cea847dc801061c785906c2141f1cdaa9ac156538d8
MD5 4b07bcd5fe498982268a1227257ba04e
BLAKE2b-256 5e5aec09a7ef9b43280fc1a83dc6c30d8e37f0438e464bb8d194f3d92cdee979

See more details on using hashes here.

File details

Details for the file sd_tools-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: sd_tools-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 43.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for sd_tools-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 753076d60d74f47298705ef9267459927e02de325fb99cdd4af56963c167dda6
MD5 3899944ff8c90c4ad4ea6f2cbaed9ca3
BLAKE2b-256 b44f245943775e3498c538cee61b10cd50b9bc2ed3affe85f020864405418612

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page