diff --git a/README.md b/README.md index f424a9291..864be07e0 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,18 @@ Fork is as close as up-to-date with origin as time allows All code changes are merged upstream whenever possible +Fork adds extra functionality: +- Ships with additional **extensions** + e.g. `System Info`, `Steps Animation`, etc. +- Ships with set of **CLI** tools that rely on *SD API* for execution: + e.g. `generate`, `train`, `bench`, etc. + [Full list]() + Fork does differ in few things: - Different start script > ./automatic.sh - Drops compatibility with `python` **3.7** and requires **3.10** -- If you're using **PyTorch 2.0** models will be auto-compiled and optimized on load - Using `max-tune` - Updated **Python** libraries to latest known compatible versions e.g. `accelerate`, `transformers`, `numpy`, etc. - Includes opinionated **System** and **Options** configuration @@ -25,8 +30,6 @@ Fork does differ in few things: - Includes reskinned **UI** Black and orange dark theme with fixed width options panels and larger previews - Includes **SD2** configuration files -- Ships with additional **extensions** - e.g. `System Info` - Uses simplified folder structure e.g. `/train`, `/outputs/*` - Modified training templates @@ -38,6 +41,9 @@ I'm currently using **PyTorch 2.0-nightly** compiled with **CUDA 11.8** and with > pip show torch > 2.0.0.dev20230113+cu118 +- Fork is compatible with regular **PyTorch 1.13**, + But if you're using **PyTorch 2.0** models will be auto-compiled and optimized on load using `max-tune` +
diff --git a/TODO.md b/TODO.md index 9369e387c..0bffc5a3f 100644 --- a/TODO.md +++ b/TODO.md @@ -32,6 +32,9 @@ Things I'm looking into... Stuff to be fixed... - Torch 2.0 model compile +- Add DeepSpeed support +- Reconnect WebUI +- Model reload performance Tech that can be integrated as part of the core workflow... diff --git a/automatic.sh b/automatic.sh index fbe69d064..8828fa55a 100755 --- a/automatic.sh +++ b/automatic.sh @@ -1,5 +1,8 @@ #/bin/env bash -export PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.9,max_split_size_mb:512 +export TF_CPP_MIN_LOG_LEVEL=2 +export FORCE_CUDA="1" +export ACCELERATE="True" +export ATTN_PRECISION=fp16export PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.9,max_split_size_mb:512 python launch.py --api --xformers --disable-console-progressbars # python launch.py --api --disable-console-progressbars --opt-channelslast diff --git a/cache.json b/cache.json deleted file mode 100644 index 30b464497..000000000 --- a/cache.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "hashes": { - "checkpoint/sd-v15-runwayml.ckpt": { - "mtime": 1669915088.0, - "sha256": "cc6cb27103417325ff94f52b7a5d2dde45a7515b25c255d8e396c90014281516" - }, - "checkpoint/mood-semireal-v01.ckpt": { - "mtime": 1673181746.8419957, - "sha256": "6a515ebcff5dcdb212830d6ac331752944decdfb4419e2ea6f1f33e6f44c5e58" - }, - "checkpoint/mood-beautyreal-v01.ckpt": { - "mtime": 1673181702.6446307, - "sha256": "bcc0afd3b264ea028928187f56f70840f8d87ccf283b020982beba35d9c7e4ef" - } - } -} \ No newline at end of file diff --git a/config.json b/config.json index 4e74b5481..2d7468bbd 100644 --- a/config.json +++ b/config.json @@ -56,7 +56,7 @@ "training_image_repeats_per_epoch": 1, "training_write_csv_every": 10.0, "training_xattention_optimizations": false, - "sd_model_checkpoint": "sd-v15-runwayml.ckpt", + "sd_model_checkpoint": "db-analog-diffusion-v10.ckpt", "sd_checkpoint_cache": 0, "sd_vae": "vae-ft-mse-840000-ema-pruned.ckpt", "sd_vae_as_default": false, @@ -157,7 +157,7 @@ "training_enable_tensorboard": true, "training_tensorboard_save_images": true, "training_tensorboard_flush_every": 60.0, - "sd_checkpoint_hash": "cc6cb27103417325ff94f52b7a5d2dde45a7515b25c255d8e396c90014281516", + "sd_checkpoint_hash": "93715dbf32da7b9b97310a805118766eddd89f25464b453f501c06801816447a", "print_hypernet_extra": false, "live_previews_enable": true, "live_preview_content": "Prompt" diff --git a/webui.sh b/webui.sh new file mode 100755 index 000000000..c4d6521db --- /dev/null +++ b/webui.sh @@ -0,0 +1,169 @@ +#!/usr/bin/env bash +################################################# +# Please do not make any changes to this file, # +# change the variables in webui-user.sh instead # +################################################# + +# If run from macOS, load defaults from webui-macos-env.sh +if [[ "$OSTYPE" == "darwin"* ]]; then + if [[ -f webui-macos-env.sh ]] + then + source ./webui-macos-env.sh + fi +fi + +# Read variables from webui-user.sh +# shellcheck source=/dev/null +if [[ -f webui-user.sh ]] +then + source ./webui-user.sh +fi + +# Set defaults +# Install directory without trailing slash +if [[ -z "${install_dir}" ]] +then + install_dir="/home/$(whoami)" +fi + +# Name of the subdirectory (defaults to stable-diffusion-webui) +if [[ -z "${clone_dir}" ]] +then + clone_dir="stable-diffusion-webui" +fi + +# python3 executable +if [[ -z "${python_cmd}" ]] +then + python_cmd="python3" +fi + +# git executable +if [[ -z "${GIT}" ]] +then + export GIT="git" +fi + +# python3 venv without trailing slash (defaults to ${install_dir}/${clone_dir}/venv) +if [[ -z "${venv_dir}" ]] +then + venv_dir="venv" +fi + +if [[ -z "${LAUNCH_SCRIPT}" ]] +then + LAUNCH_SCRIPT="launch.py" +fi + +# this script cannot be run as root by default +can_run_as_root=0 + +# read any command line flags to the webui.sh script +while getopts "f" flag > /dev/null 2>&1 +do + case ${flag} in + f) can_run_as_root=1;; + *) break;; + esac +done + +# Disable sentry logging +export ERROR_REPORTING=FALSE + +# Do not reinstall existing pip packages on Debian/Ubuntu +export PIP_IGNORE_INSTALLED=0 + +# Pretty print +delimiter="################################################################" + +printf "\n%s\n" "${delimiter}" +printf "\e[1m\e[32mInstall script for stable-diffusion + Web UI\n" +printf "\e[1m\e[34mTested on Debian 11 (Bullseye)\e[0m" +printf "\n%s\n" "${delimiter}" + +# Do not run as root +if [[ $(id -u) -eq 0 && can_run_as_root -eq 0 ]] +then + printf "\n%s\n" "${delimiter}" + printf "\e[1m\e[31mERROR: This script must not be launched as root, aborting...\e[0m" + printf "\n%s\n" "${delimiter}" + exit 1 +else + printf "\n%s\n" "${delimiter}" + printf "Running on \e[1m\e[32m%s\e[0m user" "$(whoami)" + printf "\n%s\n" "${delimiter}" +fi + +if [[ -d .git ]] +then + printf "\n%s\n" "${delimiter}" + printf "Repo already cloned, using it as install directory" + printf "\n%s\n" "${delimiter}" + install_dir="${PWD}/../" + clone_dir="${PWD##*/}" +fi + +# Check prerequisites +for preq in "${GIT}" "${python_cmd}" +do + if ! hash "${preq}" &>/dev/null + then + printf "\n%s\n" "${delimiter}" + printf "\e[1m\e[31mERROR: %s is not installed, aborting...\e[0m" "${preq}" + printf "\n%s\n" "${delimiter}" + exit 1 + fi +done + +if ! "${python_cmd}" -c "import venv" &>/dev/null +then + printf "\n%s\n" "${delimiter}" + printf "\e[1m\e[31mERROR: python3-venv is not installed, aborting...\e[0m" + printf "\n%s\n" "${delimiter}" + exit 1 +fi + +cd "${install_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/, aborting...\e[0m" "${install_dir}"; exit 1; } +if [[ -d "${clone_dir}" ]] +then + cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; } +else + printf "\n%s\n" "${delimiter}" + printf "Clone stable-diffusion-webui" + printf "\n%s\n" "${delimiter}" + "${GIT}" clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git "${clone_dir}" + cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; } +fi + +printf "\n%s\n" "${delimiter}" +printf "Create and activate python venv" +printf "\n%s\n" "${delimiter}" +cd "${install_dir}"/"${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; } +if [[ ! -d "${venv_dir}" ]] +then + "${python_cmd}" -m venv "${venv_dir}" + first_launch=1 +fi +# shellcheck source=/dev/null +if [[ -f "${venv_dir}"/bin/activate ]] +then + source "${venv_dir}"/bin/activate +else + printf "\n%s\n" "${delimiter}" + printf "\e[1m\e[31mERROR: Cannot activate python venv, aborting...\e[0m" + printf "\n%s\n" "${delimiter}" + exit 1 +fi + +if [[ ! -z "${ACCELERATE}" ]] && [ ${ACCELERATE}="True" ] && [ -x "$(command -v accelerate)" ] +then + printf "\n%s\n" "${delimiter}" + printf "Accelerating launch.py..." + printf "\n%s\n" "${delimiter}" + exec accelerate launch --num_cpu_threads_per_process=6 "${LAUNCH_SCRIPT}" "$@" +else + printf "\n%s\n" "${delimiter}" + printf "Launching launch.py..." + printf "\n%s\n" "${delimiter}" + exec "${python_cmd}" "${LAUNCH_SCRIPT}" "$@" +fi