From fcf52e301e988a2dd410316f387167a8a164e3b3 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 15 Jan 2023 13:31:34 -0300 Subject: [PATCH] Are Tests --- docker-compose.yml | 2 + output0/.gitignore | 2 + output1/.gitignore | 2 + services/AUTOMATIC1111/config.json | 10 -- .../Dockerfile | 0 services/AUTOMATIC1111_0/config.json | 10 ++ .../entrypoint.sh | 22 ++--- .../info.py | 0 services/AUTOMATIC1111_1/Dockerfile | 93 +++++++++++++++++++ services/AUTOMATIC1111_1/config.json | 10 ++ services/AUTOMATIC1111_1/entrypoint.sh | 63 +++++++++++++ services/AUTOMATIC1111_1/info.py | 14 +++ 12 files changed, 207 insertions(+), 21 deletions(-) create mode 100644 output0/.gitignore create mode 100644 output1/.gitignore delete mode 100644 services/AUTOMATIC1111/config.json rename services/{AUTOMATIC1111 => AUTOMATIC1111_0}/Dockerfile (100%) create mode 100644 services/AUTOMATIC1111_0/config.json rename services/{AUTOMATIC1111 => AUTOMATIC1111_0}/entrypoint.sh (69%) mode change 100755 => 100644 rename services/{AUTOMATIC1111 => AUTOMATIC1111_0}/info.py (100%) create mode 100644 services/AUTOMATIC1111_1/Dockerfile create mode 100644 services/AUTOMATIC1111_1/config.json create mode 100644 services/AUTOMATIC1111_1/entrypoint.sh create mode 100644 services/AUTOMATIC1111_1/info.py diff --git a/docker-compose.yml b/docker-compose.yml index d2e8740..18d95de 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,6 +7,8 @@ x-base_service: &base_service volumes: - &v1 ./data:/data - &v2 ./output:/output + - &v3 ./output0:/output0 + - &v4 ./output1:/output1 deploy: resources: reservations: diff --git a/output0/.gitignore b/output0/.gitignore new file mode 100644 index 0000000..11b4bb1 --- /dev/null +++ b/output0/.gitignore @@ -0,0 +1,2 @@ +/* +!/.gitignore \ No newline at end of file diff --git a/output1/.gitignore b/output1/.gitignore new file mode 100644 index 0000000..11b4bb1 --- /dev/null +++ b/output1/.gitignore @@ -0,0 +1,2 @@ +/* +!/.gitignore \ No newline at end of file diff --git a/services/AUTOMATIC1111/config.json b/services/AUTOMATIC1111/config.json deleted file mode 100644 index 7fff2b7..0000000 --- a/services/AUTOMATIC1111/config.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "outdir_samples": "", - "outdir_txt2img_samples": "/output/txt2img", - "outdir_img2img_samples": "/output/img2img", - "outdir_extras_samples": "/output/extras", - "outdir_txt2img_grids": "/output/txt2img-grids", - "outdir_img2img_grids": "/output/img2img-grids", - "outdir_save": "/output/saved", - "font": "DejaVuSans.ttf" -} diff --git a/services/AUTOMATIC1111/Dockerfile b/services/AUTOMATIC1111_0/Dockerfile similarity index 100% rename from services/AUTOMATIC1111/Dockerfile rename to services/AUTOMATIC1111_0/Dockerfile diff --git a/services/AUTOMATIC1111_0/config.json b/services/AUTOMATIC1111_0/config.json new file mode 100644 index 0000000..0168d4e --- /dev/null +++ b/services/AUTOMATIC1111_0/config.json @@ -0,0 +1,10 @@ +{ + "outdir_samples": "", + "outdir_txt2img_samples": "/output0/txt2img", + "outdir_img2img_samples": "/output0/img2img", + "outdir_extras_samples": "/output0/extras", + "outdir_txt2img_grids": "/output0/txt2img-grids", + "outdir_img2img_grids": "/output0/img2img-grids", + "outdir_save": "/output0/saved", + "font": "DejaVuSans.ttf" +} diff --git a/services/AUTOMATIC1111/entrypoint.sh b/services/AUTOMATIC1111_0/entrypoint.sh old mode 100755 new mode 100644 similarity index 69% rename from services/AUTOMATIC1111/entrypoint.sh rename to services/AUTOMATIC1111_0/entrypoint.sh index a5c2e5b..156f3dd --- a/services/AUTOMATIC1111/entrypoint.sh +++ b/services/AUTOMATIC1111_0/entrypoint.sh @@ -3,16 +3,16 @@ set -Eeuo pipefail # TODO: move all mkdir -p ? -mkdir -p /data/config/auto/scripts/ -cp -n /docker/config.json /data/config/auto/config.json -jq '. * input' /data/config/auto/config.json /docker/config.json | sponge /data/config/auto/config.json +mkdir -p /data/config/auto0/scripts/ +cp -n /docker/config.json /data/config/auto0/config.json +jq '. * input' /data/config/auto0/config.json /docker/config.json | sponge /data/config/auto0/config.json -if [ ! -f /data/config/auto/ui-config.json ]; then - echo '{}' >/data/config/auto/ui-config.json +if [ ! -f /data/config/auto0/ui-config.json ]; then + echo '{}' >/data/config/auto0/ui-config.json fi # copy scripts, we cannot just mount the directory because it will override the already provided scripts in the repo -cp -rfT /data/config/auto/scripts/ "${ROOT}/scripts" +cp -rfT /data/config/auto0/scripts/ "${ROOT}/scripts" declare -A MOUNTS @@ -35,9 +35,9 @@ MOUNTS["${ROOT}/models/BLIP"]="/data/BLIP" MOUNTS["${ROOT}/models/midas"]="/data/MiDaS" MOUNTS["${ROOT}/embeddings"]="/data/embeddings" -MOUNTS["${ROOT}/config.json"]="/data/config/auto/config.json" -MOUNTS["${ROOT}/ui-config.json"]="/data/config/auto/ui-config.json" -MOUNTS["${ROOT}/extensions"]="/data/config/auto/extensions" +MOUNTS["${ROOT}/config.json"]="/data/config/auto0/config.json" +MOUNTS["${ROOT}/ui-config.json"]="/data/config/auto0/ui-config.json" +MOUNTS["${ROOT}/extensions"]="/data/config/auto0/extensions" # extra hacks MOUNTS["${ROOT}/repositories/CodeFormer/weights/facelib"]="/data/.cache" @@ -54,9 +54,9 @@ for to_path in "${!MOUNTS[@]}"; do echo Mounted $(basename "${from_path}") done -if [ -f "/data/config/auto/startup.sh" ]; then +if [ -f "/data/config/auto0/startup.sh" ]; then pushd ${ROOT} - . /data/config/auto/startup.sh + . /data/config/auto0/startup.sh popd fi diff --git a/services/AUTOMATIC1111/info.py b/services/AUTOMATIC1111_0/info.py similarity index 100% rename from services/AUTOMATIC1111/info.py rename to services/AUTOMATIC1111_0/info.py diff --git a/services/AUTOMATIC1111_1/Dockerfile b/services/AUTOMATIC1111_1/Dockerfile new file mode 100644 index 0000000..093036a --- /dev/null +++ b/services/AUTOMATIC1111_1/Dockerfile @@ -0,0 +1,93 @@ +# syntax=docker/dockerfile:1 + +FROM alpine/git:2.36.2 as download + +SHELL ["/bin/sh", "-ceuxo", "pipefail"] + +RUN < /clone.sh +mkdir -p repositories/"$1" && cd repositories/"$1" && git init && git remote add origin "$2" && git fetch origin "$3" --depth=1 && git reset --hard "$3" && rm -rf .git +EOE +EOF + +RUN . /clone.sh taming-transformers https://github.com/CompVis/taming-transformers.git 24268930bf1dce879235a7fddd0b2355b84d7ea6 \ + && rm -rf data assets **/*.ipynb + +RUN . /clone.sh stable-diffusion-stability-ai https://github.com/Stability-AI/stablediffusion.git 47b6b607fdd31875c9279cd2f4f16b92e4ea958e \ + && rm -rf assets data/**/*.png data/**/*.jpg data/**/*.gif + +RUN . /clone.sh CodeFormer https://github.com/sczhou/CodeFormer.git c5b4593074ba6214284d6acd5f1719b6c5d739af \ + && rm -rf assets inputs + +RUN . /clone.sh BLIP https://github.com/salesforce/BLIP.git 48211a1594f1321b00f14c9f7a5b4813144b2fb9 +RUN . /clone.sh k-diffusion https://github.com/crowsonkb/k-diffusion.git 5b3af030dd83e0297272d861c19477735d0317ec +RUN . /clone.sh clip-interrogator https://github.com/pharmapsychotic/clip-interrogator 2486589f24165c8e3b303f84e9dbbea318df83e8 + + +FROM alpine:3.17 as xformers +RUN apk add --no-cache aria2 +RUN aria2c -x 5 --dir / --out wheel.whl 'https://github.com/AbdBarho/stable-diffusion-webui-docker/releases/download/4.1.0/xformers-0.0.16.dev421-cp310-cp310-manylinux2014_x86_64.whl' + +FROM python:3.10.9-slim + +SHELL ["/bin/bash", "-ceuxo", "pipefail"] + +ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1 + +RUN PIP_NO_CACHE_DIR=1 pip install torch==1.13.1+cu117 torchvision --extra-index-url https://download.pytorch.org/whl/cu117 + +RUN apt-get update && apt install fonts-dejavu-core rsync git jq moreutils ffmpeg -y && apt-get clean + + +RUN --mount=type=cache,target=/root/.cache/pip <=4.24 + +COPY . /docker + +RUN </data/config/auto1/ui-config.json +fi + +# copy scripts, we cannot just mount the directory because it will override the already provided scripts in the repo +cp -rfT /data/config/auto1/scripts/ "${ROOT}/scripts" + +declare -A MOUNTS + +MOUNTS["/root/.cache"]="/data/.cache" + +# main +MOUNTS["${ROOT}/models/Stable-diffusion"]="/data/StableDiffusion" +MOUNTS["${ROOT}/models/VAE"]="/data/VAE" +MOUNTS["${ROOT}/models/Codeformer"]="/data/Codeformer" +MOUNTS["${ROOT}/models/GFPGAN"]="/data/GFPGAN" +MOUNTS["${ROOT}/models/ESRGAN"]="/data/ESRGAN" +MOUNTS["${ROOT}/models/BSRGAN"]="/data/BSRGAN" +MOUNTS["${ROOT}/models/RealESRGAN"]="/data/RealESRGAN" +MOUNTS["${ROOT}/models/SwinIR"]="/data/SwinIR" +MOUNTS["${ROOT}/models/ScuNET"]="/data/ScuNET" +MOUNTS["${ROOT}/models/LDSR"]="/data/LDSR" +MOUNTS["${ROOT}/models/hypernetworks"]="/data/Hypernetworks" +MOUNTS["${ROOT}/models/torch_deepdanbooru"]="/data/Deepdanbooru" +MOUNTS["${ROOT}/models/BLIP"]="/data/BLIP" +MOUNTS["${ROOT}/models/midas"]="/data/MiDaS" + +MOUNTS["${ROOT}/embeddings"]="/data/embeddings" +MOUNTS["${ROOT}/config.json"]="/data/config/auto1/config.json" +MOUNTS["${ROOT}/ui-config.json"]="/data/config/auto1/ui-config.json" +MOUNTS["${ROOT}/extensions"]="/data/config/auto1/extensions" + +# extra hacks +MOUNTS["${ROOT}/repositories/CodeFormer/weights/facelib"]="/data/.cache" + +for to_path in "${!MOUNTS[@]}"; do + set -Eeuo pipefail + from_path="${MOUNTS[${to_path}]}" + rm -rf "${to_path}" + if [ ! -f "$from_path" ]; then + mkdir -vp "$from_path" + fi + mkdir -vp "$(dirname "${to_path}")" + ln -sT "${from_path}" "${to_path}" + echo Mounted $(basename "${from_path}") +done + +if [ -f "/data/config/auto1/startup.sh" ]; then + pushd ${ROOT} + . /data/config/auto1/startup.sh + popd +fi + +exec "$@" diff --git a/services/AUTOMATIC1111_1/info.py b/services/AUTOMATIC1111_1/info.py new file mode 100644 index 0000000..edfa7b0 --- /dev/null +++ b/services/AUTOMATIC1111_1/info.py @@ -0,0 +1,14 @@ +import sys +from pathlib import Path + +file = Path(sys.argv[1]) +file.write_text( + file.read_text()\ + .replace(' return demo', """ + with demo: + gr.Markdown( + 'Created by [AUTOMATIC1111 / stable-diffusion-webui-docker](https://github.com/AbdBarho/stable-diffusion-webui-docker/)' + ) + return demo +""", 1) +)