Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Avaray committed Aug 5, 2024
2 parents 7ffe4b3 + cdef6a2 commit 176991e
Show file tree
Hide file tree
Showing 16 changed files with 815 additions and 157 deletions.
42 changes: 35 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# 🌟 Stable Diffusion Templates
# 🗃 Stable Diffusion Templates

This is curated collection of templates for [Vast.ai](https://cloud.vast.ai/create/?ref_id=62878) and [Runpod.io](https://runpod.io/console/deploy?ref=gzvzzzv9) services. Their main purpose is to simplify the process of getting started with Stable Diffusion. These templates gives ready to use [Automatic1111 WebUI](https://github.com/AUTOMATIC1111/stable-diffusion-webui) thanks to [AI-Dock](https://github.com/ai-dock/stable-diffusion-webui). Plus they have some nice Lora's and useful Extensions preinstalled.
This is curated collection of templates for [Vast.ai](https://cloud.vast.ai/create/?ref_id=62878) and [Runpod.io](https://runpod.io/console/deploy?ref=gzvzzzv9) services.
Their main purpose is to simplify the process of getting started with Stable Diffusion.
These templates gives ready to use [Automatic1111 WebUI](https://github.com/AUTOMATIC1111/stable-diffusion-webui) thanks to [AI-Dock](https://github.com/ai-dock/stable-diffusion-webui). Plus they have some nice Lora's and useful Extensions preinstalled.

Mentioned services give you access to powerful GPUs like [RTX4090](https://www.nvidia.com/en-us/geforce/graphics-cards/40-series/rtx-4090/) at low cost.

Additional informations will be added soon.
### Start generating graphics in minutes with just few clicks 😎

# 🦓 SDXL

Expand Down Expand Up @@ -35,7 +35,35 @@ Templates with checkpoints based on Pony Diffusion XL.
| - | [AutismMix](https://civitai.com/models/288584?modelVersionId=324619) | `V1` | <a href="https://cloud.vast.ai/create/?ref_id=62878&template_id=a4b369ebca71a4b53e01037239fbd76a"><img src="images/vastai.svg" alt="Vast.ai" width="42" height="42"></a> | <a href="https://runpod.io/console/deploy?ref=gzvzzzv9&template=os43pc1362"><img src="images/runpodio.svg" alt="Runpod.io" width="42" height="42"></a> |
| - | [fennfoto](https://civitai.com/models/503537?modelVersionId=676770) | `V3` | <a href="https://cloud.vast.ai/create/?ref_id=62878&template_id=46f4a5f0eb3a6355aa58acfc66cb95db"><img src="images/vastai.svg" alt="Vast.ai" width="42" height="42"></a> | <a href="https://runpod.io/console/deploy?ref=gzvzzzv9&template=rncvdgx8kj"><img src="images/runpodio.svg" alt="Runpod.io" width="42" height="42"></a> |

## 📋 TODO's
# 🙊 What is [Vast.ai](https://cloud.vast.ai/create/?ref_id=62878) and [Runpod.io](https://runpod.io/console/deploy?ref=gzvzzzv9) ?

These are services that gives you access to powerful [GPUs](https://en.wikipedia.org/wiki/Graphics_processing_unit) like [RTX4090](https://www.nvidia.com/en-us/geforce/graphics-cards/40-series/rtx-4090/) at low cost.
They let you run [Docker images](https://docs.docker.com/guides/docker-overview/#what-can-i-use-docker-for) on their servers.

If you can't afford to buy a powerful Graphics Card (that is mandatory in graphics generation), these services are for you. In my opinion, services like these are the best way to get started with Stable Diffusion when you have weak graphics card and you don't have money to buy a powerful one. Btw. You can read [my old article](https://dav.one/the-ways-and-costs-of-generating-graphics-using-stable-diffusion) about _"the ways and costs of generating graphics"_.

These two services offer a lot of different machines with different hardware. There are also community machines that are cheaper. Both services have machine browsers where you can find the best machine for your needs. Currently renting community machine with RTX4090 on [Vast.ai](https://cloud.vast.ai/create/?ref_id=62878) costs about $0.2 per hour. On [Runpod.io](https://runpod.io/console/deploy?ref=gzvzzzv9) it's a little bit more expensive.

When you are registered on these services and logged in, you can use the links above to rent a machine with selected template. **It's super easy.**

# 🙉 What is [AI-Dock](https://github.com/ai-dock/stable-diffusion-webui) and [Provisioning Script](https://github.com/ai-dock/base-image/wiki/4.0-Running-the-Image#provisioning-script) ?

[AI-Dock](https://github.com/ai-dock/stable-diffusion-webui) allows users to run _Stable Diffusion_ with latest version of [Automatic1111 WebUI](https://github.com/AUTOMATIC1111/stable-diffusion-webui) in a Docker container. In my opinion the biggest advantage of this solution is that it starts quickly and you are able to connect to machine before all the checkpoints are downloaded. Because of that you can know at the beginning if docker image will work on machine you rented. Without AI-Dock you might waste few minutes waiting for checkpoints to download and then you will find out that something is wrong and you need to rent another machine. Except that AI-Dock comes with [Provisioning Script](https://github.com/ai-dock/base-image/wiki/4.0-Running-the-Image#provisioning-script), which is a script that installs all the necessary dependencies and downloads the checkpoints before starting the WebUI. So you don't need to do anything manually and you don't need to restart the container after installing specific extensions.

Except [Automatic1111](https://github.com/AUTOMATIC1111/stable-diffusion-webui), AI-Dock supports also other popular WebUIs like [ComfyUI](https://github.com/comfyanonymous/ComfyUI), [InvokeAI](https://github.com/invoke-ai/InvokeAI) and [Foooocus](https://github.com/lllyasviel/Fooocus). All templates in this repository are based on Auto1111, because it's my favorite one.

# 🙈 Provisioning scripts in my Templates

Provisioning scripts in this Collection are based on official [Provisioning Script](https://github.com/ai-dock/stable-diffusion-webui/blob/main/config/provisioning/default.sh).
In process of creating my provisioning scripts I'm replacing some parts of original script with my own stuff. Currently it includes:

- Each script has just one spedific checkpoint. Does not include stock checkpoints.
- Each script has some useful Lora's that will work with that checkpoint. Basically there are two lists of Lora's - one for checkpoints based on SDXL and one for checkpoints based on PDXL.
- Each script has some useful Extensions. Basically the same for all scripts. Except `taggers`.

In near future I will also add some useful Embeddings (Textual Inversions).

# 📋 TODO's

- [x] Create Workflows for automatic updates.
- [x] Create Workflow for detecting changes in original Provisioning script.
Expand All @@ -47,7 +75,7 @@ Templates with checkpoints based on Pony Diffusion XL.
- [ ] Create Lite versions (without Loras).
- [ ] Find a way to automate the creation and modification of templates so that Playwright isn't needed.

## 🗃 FAQ
# ♻️ FAQ

`Q` Will you add more models?
`A` Yes. Currently I need to create templates manually, because these services does not provide API for managing templates. Believe me, it's a pain.
Expand Down
62 changes: 52 additions & 10 deletions scripts/autismmixsdxl_autismmixpony.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

DISK_GB_REQUIRED=40

PIP_PACKAGES=()
APT_PACKAGES=(
#"package-1"
#"package-2"
)

PIP_PACKAGES=(
#"package-1"
#"package-2"
)

EXTENSIONS=(
'https://github.com/Mikubill/sd-webui-controlnet'
Expand Down Expand Up @@ -68,13 +76,18 @@ CONTROLNET_MODELS=()
EMBEDDINGS=()

function provisioning_start() {

if [[ ! -d /opt/environments/python ]]; then
export MAMBA_BASE=true
fi
source /opt/ai-dock/etc/environment.sh
source /opt/ai-dock/bin/venv-set.sh webui

DISK_GB_AVAILABLE=$(($(df --output=avail -m "${WORKSPACE}" | tail -n1) / 1000))
DISK_GB_USED=$(($(df --output=used -m "${WORKSPACE}" | tail -n1) / 1000))
DISK_GB_ALLOCATED=$(($DISK_GB_AVAILABLE + $DISK_GB_USED))
provisioning_print_header
provisioning_get_apt_packages
provisioning_get_pip_packages
provisioning_get_extensions
provisioning_get_models \
Expand All @@ -100,17 +113,36 @@ function provisioning_start() {
PROVISIONING_ARGS="--skip-python-version-check --no-download-sd-model --do-not-download-clip --port 11404 --exit"
ARGS_COMBINED="${PLATFORM_ARGS} $(cat /etc/a1111_webui_flags.conf) ${PROVISIONING_ARGS}"

cd /opt/stable-diffusion-webui && \
source "$WEBUI_VENV/bin/activate"
LD_PRELOAD=libtcmalloc.so python launch.py \
${ARGS_COMBINED}
deactivate
cd /opt/stable-diffusion-webui
if [[ -z $MAMBA_BASE ]]; then
source "$WEBUI_VENV/bin/activate"
LD_PRELOAD=libtcmalloc.so python launch.py \
${ARGS_COMBINED}
deactivate
else
micromamba run -n webui -e LD_PRELOAD=libtcmalloc.so python launch.py \
${ARGS_COMBINED}
fi
provisioning_print_end
}

function pip_install() {
if [[ -z $MAMBA_BASE ]]; then
"$WEBUI_VENV_PIP" install --no-cache-dir "$@"
else
micromamba run -n webui pip install --no-cache-dir "$@"
fi
}

function provisioning_get_apt_packages() {
if [[ -n $APT_PACKAGES ]]; then
$APT_INSTALL ${APT_PACKAGES[@]}
fi
}

function provisioning_get_pip_packages() {
if [[ -n $PIP_PACKAGES ]]; then
"$WEBUI_VENV_PIP" install --no-cache-dir ${PIP_PACKAGES[@]}
pip_install ${PIP_PACKAGES[@]}
fi
}

Expand All @@ -127,13 +159,13 @@ function provisioning_get_extensions() {
fi

if [[ -e $requirements ]]; then
"$WEBUI_VENV_PIP" install --no-cache-dir -r "$requirements"
pip_install -r "$requirements"
fi
else
printf "Downloading extension: %s...\n" "${repo}"
git clone "${repo}" "${path}" --recursive
if [[ -e $requirements ]]; then
"$WEBUI_VENV_PIP" install --no-cache-dir -r "${requirements}"
pip_install -r "${requirements}"
fi
fi
done
Expand Down Expand Up @@ -171,7 +203,17 @@ function provisioning_print_end() {
}

function provisioning_download() {
wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
if [[ -n $HF_TOKEN && $1 =~ ^https://([a-zA-Z0-9_-]+\.)?huggingface\.co(/|$|\?) ]]; then
auth_token="$HF_TOKEN"
elif
[[ -n $CIVITAI_TOKEN && $1 =~ ^https://([a-zA-Z0-9_-]+\.)?civitai\.com(/|$|\?) ]]; then
auth_token="$CIVITAI_TOKEN"
fi
if [[ -n $auth_token ]];then
wget --header="Authorization: Bearer $auth_token" -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
else
wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
fi
}

provisioning_start
62 changes: 52 additions & 10 deletions scripts/chinook_v10.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

DISK_GB_REQUIRED=40

PIP_PACKAGES=()
APT_PACKAGES=(
#"package-1"
#"package-2"
)

PIP_PACKAGES=(
#"package-1"
#"package-2"
)

EXTENSIONS=(
'https://github.com/Mikubill/sd-webui-controlnet'
Expand Down Expand Up @@ -46,13 +54,18 @@ CONTROLNET_MODELS=()
EMBEDDINGS=()

function provisioning_start() {

if [[ ! -d /opt/environments/python ]]; then
export MAMBA_BASE=true
fi
source /opt/ai-dock/etc/environment.sh
source /opt/ai-dock/bin/venv-set.sh webui

DISK_GB_AVAILABLE=$(($(df --output=avail -m "${WORKSPACE}" | tail -n1) / 1000))
DISK_GB_USED=$(($(df --output=used -m "${WORKSPACE}" | tail -n1) / 1000))
DISK_GB_ALLOCATED=$(($DISK_GB_AVAILABLE + $DISK_GB_USED))
provisioning_print_header
provisioning_get_apt_packages
provisioning_get_pip_packages
provisioning_get_extensions
provisioning_get_models \
Expand All @@ -78,17 +91,36 @@ function provisioning_start() {
PROVISIONING_ARGS="--skip-python-version-check --no-download-sd-model --do-not-download-clip --port 11404 --exit"
ARGS_COMBINED="${PLATFORM_ARGS} $(cat /etc/a1111_webui_flags.conf) ${PROVISIONING_ARGS}"

cd /opt/stable-diffusion-webui && \
source "$WEBUI_VENV/bin/activate"
LD_PRELOAD=libtcmalloc.so python launch.py \
${ARGS_COMBINED}
deactivate
cd /opt/stable-diffusion-webui
if [[ -z $MAMBA_BASE ]]; then
source "$WEBUI_VENV/bin/activate"
LD_PRELOAD=libtcmalloc.so python launch.py \
${ARGS_COMBINED}
deactivate
else
micromamba run -n webui -e LD_PRELOAD=libtcmalloc.so python launch.py \
${ARGS_COMBINED}
fi
provisioning_print_end
}

function pip_install() {
if [[ -z $MAMBA_BASE ]]; then
"$WEBUI_VENV_PIP" install --no-cache-dir "$@"
else
micromamba run -n webui pip install --no-cache-dir "$@"
fi
}

function provisioning_get_apt_packages() {
if [[ -n $APT_PACKAGES ]]; then
$APT_INSTALL ${APT_PACKAGES[@]}
fi
}

function provisioning_get_pip_packages() {
if [[ -n $PIP_PACKAGES ]]; then
"$WEBUI_VENV_PIP" install --no-cache-dir ${PIP_PACKAGES[@]}
pip_install ${PIP_PACKAGES[@]}
fi
}

Expand All @@ -105,13 +137,13 @@ function provisioning_get_extensions() {
fi

if [[ -e $requirements ]]; then
"$WEBUI_VENV_PIP" install --no-cache-dir -r "$requirements"
pip_install -r "$requirements"
fi
else
printf "Downloading extension: %s...\n" "${repo}"
git clone "${repo}" "${path}" --recursive
if [[ -e $requirements ]]; then
"$WEBUI_VENV_PIP" install --no-cache-dir -r "${requirements}"
pip_install -r "${requirements}"
fi
fi
done
Expand Down Expand Up @@ -149,7 +181,17 @@ function provisioning_print_end() {
}

function provisioning_download() {
wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
if [[ -n $HF_TOKEN && $1 =~ ^https://([a-zA-Z0-9_-]+\.)?huggingface\.co(/|$|\?) ]]; then
auth_token="$HF_TOKEN"
elif
[[ -n $CIVITAI_TOKEN && $1 =~ ^https://([a-zA-Z0-9_-]+\.)?civitai\.com(/|$|\?) ]]; then
auth_token="$CIVITAI_TOKEN"
fi
if [[ -n $auth_token ]];then
wget --header="Authorization: Bearer $auth_token" -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
else
wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
fi
}

provisioning_start
Loading

0 comments on commit 176991e

Please sign in to comment.