Are Tests

This commit is contained in:
unknown 2023-01-15 13:31:34 -03:00
parent 5ffc7490e1
commit fcf52e301e
12 changed files with 207 additions and 21 deletions

View file

@ -7,6 +7,8 @@ x-base_service: &base_service
volumes: volumes:
- &v1 ./data:/data - &v1 ./data:/data
- &v2 ./output:/output - &v2 ./output:/output
- &v3 ./output0:/output0
- &v4 ./output1:/output1
deploy: deploy:
resources: resources:
reservations: reservations:

2
output0/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/*
!/.gitignore

2
output1/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/*
!/.gitignore

View file

@ -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"
}

View file

@ -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"
}

View file

@ -3,16 +3,16 @@
set -Eeuo pipefail set -Eeuo pipefail
# TODO: move all mkdir -p ? # TODO: move all mkdir -p ?
mkdir -p /data/config/auto/scripts/ mkdir -p /data/config/auto0/scripts/
cp -n /docker/config.json /data/config/auto/config.json cp -n /docker/config.json /data/config/auto0/config.json
jq '. * input' /data/config/auto/config.json /docker/config.json | sponge /data/config/auto/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 if [ ! -f /data/config/auto0/ui-config.json ]; then
echo '{}' >/data/config/auto/ui-config.json echo '{}' >/data/config/auto0/ui-config.json
fi fi
# copy scripts, we cannot just mount the directory because it will override the already provided scripts in the repo # 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 declare -A MOUNTS
@ -35,9 +35,9 @@ MOUNTS["${ROOT}/models/BLIP"]="/data/BLIP"
MOUNTS["${ROOT}/models/midas"]="/data/MiDaS" MOUNTS["${ROOT}/models/midas"]="/data/MiDaS"
MOUNTS["${ROOT}/embeddings"]="/data/embeddings" MOUNTS["${ROOT}/embeddings"]="/data/embeddings"
MOUNTS["${ROOT}/config.json"]="/data/config/auto/config.json" MOUNTS["${ROOT}/config.json"]="/data/config/auto0/config.json"
MOUNTS["${ROOT}/ui-config.json"]="/data/config/auto/ui-config.json" MOUNTS["${ROOT}/ui-config.json"]="/data/config/auto0/ui-config.json"
MOUNTS["${ROOT}/extensions"]="/data/config/auto/extensions" MOUNTS["${ROOT}/extensions"]="/data/config/auto0/extensions"
# extra hacks # extra hacks
MOUNTS["${ROOT}/repositories/CodeFormer/weights/facelib"]="/data/.cache" MOUNTS["${ROOT}/repositories/CodeFormer/weights/facelib"]="/data/.cache"
@ -54,9 +54,9 @@ for to_path in "${!MOUNTS[@]}"; do
echo Mounted $(basename "${from_path}") echo Mounted $(basename "${from_path}")
done done
if [ -f "/data/config/auto/startup.sh" ]; then if [ -f "/data/config/auto0/startup.sh" ]; then
pushd ${ROOT} pushd ${ROOT}
. /data/config/auto/startup.sh . /data/config/auto0/startup.sh
popd popd
fi fi

View file

@ -0,0 +1,93 @@
# syntax=docker/dockerfile:1
FROM alpine/git:2.36.2 as download
SHELL ["/bin/sh", "-ceuxo", "pipefail"]
RUN <<EOF
cat <<'EOE' > /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 <<EOF
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
cd stable-diffusion-webui
git reset --hard d7aec59c4eb02f723b3d55c6f927a42e97acd679
pip install -r requirements_versions.txt
EOF
RUN --mount=type=cache,target=/root/.cache/pip \
--mount=type=bind,from=xformers,source=/wheel.whl,target=/xformers-0.0.15-cp310-cp310-linux_x86_64.whl \
pip install triton /xformers-0.0.15-cp310-cp310-linux_x86_64.whl
ENV ROOT=/stable-diffusion-webui
COPY --from=download /git/ ${ROOT}
RUN mkdir ${ROOT}/interrogate && cp ${ROOT}/repositories/clip-interrogator/data/* ${ROOT}/interrogate
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -r ${ROOT}/repositories/CodeFormer/requirements.txt
RUN --mount=type=cache,target=/root/.cache/pip \
pip install opencv-python-headless \
git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379 \
git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1 \
git+https://github.com/mlfoundations/open_clip.git@bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b \
pyngrok
# Note: don't update the sha of previous versions because the install will take forever
# instead, update the repo state in a later step
ARG SHA=d97f467c0d27695d23edad5e4f8898a57e0ccb00
RUN --mount=type=cache,target=/root/.cache/pip <<EOF
cd stable-diffusion-webui
git fetch
git reset --hard ${SHA}
pip install -r requirements_versions.txt
EOF
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -U opencv-python-headless transformers>=4.24
COPY . /docker
RUN <<EOF
python3 /docker/info.py ${ROOT}/modules/ui.py
mv ${ROOT}/style.css ${ROOT}/user.css
EOF
WORKDIR ${ROOT}
ENV CLI_ARGS=""
EXPOSE 7861
ENTRYPOINT ["/docker/entrypoint.sh"]
CMD python3 -u webui.py --listen --port 7860 ${CLI_ARGS}

View file

@ -0,0 +1,10 @@
{
"outdir_samples": "",
"outdir_txt2img_samples": "/output1/txt2img",
"outdir_img2img_samples": "/output1/img2img",
"outdir_extras_samples": "/output1/extras",
"outdir_txt2img_grids": "/output1/txt2img-grids",
"outdir_img2img_grids": "/output1/img2img-grids",
"outdir_save": "/output1/saved",
"font": "DejaVuSans.ttf"
}

View file

@ -0,0 +1,63 @@
#!/bin/bash
set -Eeuo pipefail
# TODO: move all mkdir -p ?
mkdir -p /data/config/auto1/scripts/
cp -n /docker/config.json /data/config/auto1/config.json
jq '. * input' /data/config/auto1/config.json /docker/config.json | sponge /data/config/auto1/config.json
if [ ! -f /data/config/auto1/ui-config.json ]; then
echo '{}' >/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 "$@"

View file

@ -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)
)