diff --git a/02.forge.sh b/02.forge.sh new file mode 100644 index 0000000..43578bc --- /dev/null +++ b/02.forge.sh @@ -0,0 +1,86 @@ +#!/bin/bash +source /sl_folder.sh + +export PATH="/home/abc/miniconda3/bin:$PATH" +export active_clean=0 + +# disable the use of a python venv +export venv_dir="-" + +# Install or update Stable-Diffusion-WebUI +mkdir -p ${SD02_DIR} + +if [ ! -d ${SD02_DIR}/conda-env ]; then + conda create -p ${SD02_DIR}/conda-env -y +fi + +source activate ${SD02_DIR}/conda-env +conda install -n base conda-libmamba-solver -y +conda install -c git python=3.11 pip --solver=libmamba -y + +if [ ! -d ${SD02_DIR}/forge ]; then + git clone https://github.com/lllyasviel/stable-diffusion-webui-forge.git ${SD02_DIR}/forge +fi + +cd ${SD02_DIR}/forge + +# check if remote is ahead of local +# https://stackoverflow.com/a/25109122/1469797 +if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ +sed 's/\// /g') | cut -f1) ]; then + echo "Local branch up-to-date, keeping existing venv" + else + if [ "$CLEAN_ENV" = "true" ]; then + echo "Forced wiping venv for clean packages install" + else + echo "Remote branch is ahead. Wiping venv for clean packages install" + fi + export active_clean=1 + git pull -X ours +fi + +#clean conda env +if [ "$active_clean" = "1" ]; then + conda deactivate + conda remove -p ${SD02_DIR}/conda-env --all -y + conda create -p ${SD02_DIR}/conda-env -y + source activate ${SD02_DIR}/conda-env +fi +conda install -c conda-forge git python=3.11 pip gcc gxx libcurand --solver=libmamba -y + +if [ ! -f "$SD02_DIR/parameters.forge.txt" ]; then + cp -v "/opt/sd-install/parameters/02.forge.txt" "$SD02_DIR/parameters.forge.txt" +fi + +pip install --upgrade pip +pip install packaging +pip install onnxruntime-gpu --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ +pip install insightface +pip install basicsr +#pip install protobuf==3.20.3 + +# Merge Models, vae, lora, and hypernetworks, and outputs +# Ignore move errors if they occur +sl_folder ${SD02_DIR}/forge/models Stable-diffusion ${BASE_DIR}/models stable-diffusion +sl_folder ${SD02_DIR}/forge/models hypernetworks ${BASE_DIR}/models hypernetwork +sl_folder ${SD02_DIR}/forge/models Lora ${BASE_DIR}/models lora +sl_folder ${SD02_DIR}/forge/models VAE ${BASE_DIR}/models vae +sl_folder ${SD02_DIR}/forge embeddings ${BASE_DIR}/models embeddings +sl_folder ${SD02_DIR}/forge/models ESRGAN ${BASE_DIR}/models upscale +sl_folder ${SD02_DIR}/forge/models BLIP ${BASE_DIR}/models blip +sl_folder ${SD02_DIR}/forge/models Codeformer ${BASE_DIR}/models codeformer +sl_folder ${SD02_DIR}/forge/models GFPGAN ${BASE_DIR}/models gfpgan +sl_folder ${SD02_DIR}/forge/models LDSR ${BASE_DIR}/models ldsr +sl_folder ${SD02_DIR}/forge/models ControlNet ${BASE_DIR}/models controlnet + +sl_folder ${SD02_DIR}/forge output ${BASE_DIR}/outputs 02-sd-webui + +echo "Run Stable-Diffusion-WebUI-forge" +cd ${SD02_DIR}/forge +CMD="bash webui.sh" +while IFS= read -r param; do + if [[ $param != \#* ]]; then + CMD+=" ${param}" + fi +done < "${SD02_DIR}/parameters.forge.txt" +eval $CMD diff --git a/02.sh b/02.sh index d9e7334..a0d1402 100755 --- a/02.sh +++ b/02.sh @@ -2,21 +2,21 @@ source /sl_folder.sh export PATH="/home/abc/miniconda3/bin:$PATH" +export active_clean=0 -export use_venv=1 +# disable the use of a python venv +export venv_dir="-" # Install or update Stable-Diffusion-WebUI mkdir -p ${SD02_DIR} -if [ ! -d ${SD02_DIR}/env ]; then - conda create -p ${SD02_DIR}/env -y +if [ ! -d ${SD02_DIR}/conda-env ]; then + conda create -p ${SD02_DIR}/conda-env -y fi -source activate ${SD02_DIR}/env +source activate ${SD02_DIR}/conda-env conda install -n base conda-libmamba-solver -y -conda install -c conda-forge git python=3.11 pip gcc gxx libcurand --solver=libmamba -y - - +conda install -c git python=3.11 pip --solver=libmamba -y if [ ! -d ${SD02_DIR}/webui ]; then git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui ${SD02_DIR}/webui @@ -24,40 +24,40 @@ fi cd ${SD02_DIR}/webui -if [ -d "${SD02_DIR}/webui/venv" ]; then - # check if remote is ahead of local - # https://stackoverflow.com/a/25109122/1469797 - if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ - sed 's/\// /g') | cut -f1) ]; then - echo "Local branch up-to-date, keeping existing venv" - else +# check if remote is ahead of local +# https://stackoverflow.com/a/25109122/1469797 +if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ +sed 's/\// /g') | cut -f1) ]; then + echo "Local branch up-to-date, keeping existing venv" + else if [ "$CLEAN_ENV" = "true" ]; then - echo "Forced wiping venv for clean packages install" + echo "Forced wiping venv for clean packages install" else - echo "Remote branch is ahead. Wiping venv for clean packages install" + echo "Remote branch is ahead. Wiping venv for clean packages install" fi - rm -rf ${SD02_DIR}/webui/venv - git pull -X ours - fi + export active_clean=1 + git pull -X ours fi +#clean conda env +if [ "$active_clean" = "1" ]; then + conda deactivate + conda remove -p ${SD02_DIR}/conda-env --all -y + conda create -p ${SD02_DIR}/conda-env -y + source activate ${SD02_DIR}/conda-env +fi +conda install -c conda-forge git python=3.11 pip gcc gxx libcurand --solver=libmamba -y + if [ ! -f "$SD02_DIR/parameters.txt" ]; then cp -v "/opt/sd-install/parameters/02.txt" "$SD02_DIR/parameters.txt" fi -# Create venv -if [ ! -d ${SD02_DIR}/webui/venv ]; then - cd ${SD02_DIR}/webui - python -m venv venv - cd ${SD02_DIR}/webui - source venv/bin/activate - pip install --upgrade pip - pip install packaging - pip install onnxruntime-gpu - pip install insightface - pip install protobuf==3.20.3 - deactivate -fi +pip install --upgrade pip +pip install packaging +pip install onnxruntime-gpu --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ +pip install insightface +pip install basicsr +#pip install protobuf==3.20.3 # Merge Models, vae, lora, and hypernetworks, and outputs # Ignore move errors if they occur @@ -71,15 +71,12 @@ sl_folder ${SD02_DIR}/webui/models BLIP ${BASE_DIR}/models blip sl_folder ${SD02_DIR}/webui/models Codeformer ${BASE_DIR}/models codeformer sl_folder ${SD02_DIR}/webui/models GFPGAN ${BASE_DIR}/models gfpgan sl_folder ${SD02_DIR}/webui/models LDSR ${BASE_DIR}/models ldsr +sl_folder ${SD02_DIR}/webui/models ControlNet ${BASE_DIR}/models controlnet sl_folder ${SD02_DIR}/webui outputs ${BASE_DIR}/outputs 02-sd-webui echo "Run Stable-Diffusion-WebUI" cd ${SD02_DIR}/webui -source venv/bin/activate -export PATH="/config/02-sd-webui/webui/venv/lib/python3.11/site-packages/onnxruntime/capi:$PATH" -pip install --upgrade pip - CMD="bash webui.sh" while IFS= read -r param; do if [[ $param != \#* ]]; then diff --git a/50.sh b/50.sh index 336eabd..5d834c6 100755 --- a/50.sh +++ b/50.sh @@ -3,8 +3,8 @@ source /sl_folder.sh export PATH="/home/abc/miniconda3/bin:$PATH" -mkdir -p "${SD50_DIR}" -mkdir -p /config/outputs/50-Lama-cleaner +mkdir -p "${SD50_DIR}/IOPaint" +mkdir -p /config/outputs/50-IOPaint if [ ! -d ${SD50_DIR}/env ]; then conda create -p ${SD50_DIR}/env -y @@ -18,13 +18,13 @@ if [ ! -f "$SD50_DIR/parameters.txt" ]; then cp -v "${SD_INSTALL_DIR}/parameters/50.txt" "$SD50_DIR/parameters.txt" fi -if [ ! -d ${SD50_DIR}/lama-cleaner ]; then - cd "${SD50_DIR}" && git clone https://github.com/Sanster/lama-cleaner -fi +#if [ ! -d ${SD50_DIR}/IOPaint ]; then +# cd "${SD50_DIR}" && git clone https://github.com/Sanster/IOPaint +#fi -cd ${SD50_DIR}/lama-cleaner -git config --global --add safe.directory ${SD50_DIR}/lama_cleaner -git pull -X ours +#cd ${SD50_DIR}/IOPaint +#git config --global --add safe.directory ${SD50_DIR}/lama_cleaner +#git pull -X ours # chown -R diffusion:users ${BASE_DIR} @@ -32,10 +32,14 @@ git pull -X ours # su -w SD50_DIR - diffusion -c 'cd ${SD50_DIR} && python3 -m venv venv' # fi -cd ${SD50_DIR}/lama-cleaner -pip install -r requirements.txt -CMD="python main.py" +cd ${SD50_DIR}/IOPaint +#pip install -r requirements.txt + +pip3 install iopaint + + +CMD="iopaint start" while IFS= read -r param; do if [[ $param != \#* ]]; then CMD+=" ${param}" diff --git a/Dockerfile b/Dockerfile index 1a5b8e8..4ddbc3a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ ENV BASE_DIR=/config \ SD07_DIR=/config/07-StableSwarm \ SD08_DIR=/config/08-voltaML \ SD20_DIR=/config/20-kubin \ - SD50_DIR=/config/50-lama-cleaner \ + SD50_DIR=/config/50-IOPaint \ SD51_DIR=/config/51-facefusion \ SD70_DIR=/config/70-kohya \ XDG_CACHE_HOME=/config/temp @@ -24,6 +24,7 @@ RUN apt-get update -y -q=2 && \ apt-get install -y -q=2 curl \ wget \ mc \ + bc \ nano \ rsync \ libgl1-mesa-glx \ diff --git a/entry.sh b/entry.sh index 7ca8c00..5cd4093 100644 --- a/entry.sh +++ b/entry.sh @@ -7,45 +7,8 @@ if [ ! -f "$BASE_DIR/scripts/custom-sample.sh" ]; then cp -v "/custom-sample.sh" "$BASE_DIR/scripts/custom-sample.sh" fi -case $WEBUI_VERSION in - 01) - . /01.sh - ;; - 02) - . /02.sh - ;; - 03) - . /03.sh - ;; - 04) - . /04.sh - ;; - 05) - . /05.sh - ;; - 06) - . /06.sh - ;; - 07) - . /07.sh - ;; - 08) - . /08.sh - ;; - 20) - . /20.sh - ;; - 50) - . /50.sh - ;; - 51) - . /51.sh - ;; - 70) - . /70.sh - ;; - *) - . $BASE_DIR/scripts/$WEBUI_VERSION - echo error in webui selection variable - ;; -esac +. /$WEBUI_VERSION.sh +. /$WEBUI_VERSION +. $BASE_DIR/scripts/$WEBUI_VERSION +. $BASE_DIR/scripts/$WEBUI_VERSION.sh +echo error in webui selection variable \ No newline at end of file diff --git a/parameters/02.forge.txt b/parameters/02.forge.txt new file mode 100644 index 0000000..32fef65 --- /dev/null +++ b/parameters/02.forge.txt @@ -0,0 +1,16 @@ +# Web + Network +--listen +--port 9000 + +# options +--enable-insecure-extension-access +--xformers +--api +--cuda-malloc +--cuda-stream + +#--no-half-vae +#--disable-nan-check +#--update-all-extensions +#--reinstall-xformers +#--reinstall-torch diff --git a/parameters/02.txt b/parameters/02.txt index f7a2a25..cd191ee 100644 --- a/parameters/02.txt +++ b/parameters/02.txt @@ -12,4 +12,4 @@ #--disable-nan-check #--update-all-extensions #--reinstall-xformers -#--reinstall-torch +#--reinstall-torch diff --git a/parameters/50.txt b/parameters/50.txt index ca29ea0..c7d9ba2 100644 --- a/parameters/50.txt +++ b/parameters/50.txt @@ -1,10 +1,9 @@ ##### Web + Network ##### ---host 0.0.0.0 ---port 9000 +--host=0.0.0.0 +--port=9000 ##### Directories ##### -#--output-dir /config/outputs/50-Lama-Cleaner ##### Options ##### ---device cuda ---enable-xformers +--device=cuda +--model=lama \ No newline at end of file