src->models

This commit is contained in:
hlky 2022-10-05 01:03:06 +01:00
parent 8cef7c8762
commit b650c162e6
No known key found for this signature in database
GPG Key ID: 55A99F1E80D907D5
14 changed files with 187 additions and 123 deletions

View File

@ -1,4 +1,2 @@
models/custom/
outputs/
src/
gfpgan/
src/

View File

@ -9,15 +9,15 @@ SHELL ["/bin/bash", "-c"]
ENV PYTHONPATH=/sd
EXPOSE 8501
COPY ./stable-diffusion-webui/data/DejaVuSans.ttf /usr/share/fonts/truetype/
COPY ./stable-diffusion-webui/data/ /sd/data/
copy ./stable-diffusion-webui/images/ /sd/images/
copy ./stable-diffusion-webui/scripts/ /sd/scripts/
copy ./stable-diffusion-webui/ldm/ /sd/ldm/
copy ./stable-diffusion-webui/frontend/ /sd/frontend/
copy ./stable-diffusion-webui/configs/ /sd/configs/
copy ./stable-diffusion-webui/.streamlit/ /sd/.streamlit/
COPY ./stable-diffusion-webui/entrypoint.sh /sd/
COPY ./data/DejaVuSans.ttf /usr/share/fonts/truetype/
COPY ./data/ /sd/data/
copy ./images/ /sd/images/
copy ./scripts/ /sd/scripts/
copy ./ldm/ /sd/ldm/
copy ./frontend/ /sd/frontend/
copy ./configs/ /sd/configs/
copy ./.streamlit/ /sd/.streamlit/
COPY ./entrypoint.sh /sd/
ENTRYPOINT /sd/entrypoint.sh
RUN mkdir -p ~/.streamlit/

27
Dockerfile_runpod Normal file
View File

@ -0,0 +1,27 @@
ARG IMAGE=hlky/sd-webui:base
FROM ${IMAGE}
WORKDIR /workdir
SHELL ["/bin/bash", "-c"]
ENV PYTHONPATH=/sd
EXPOSE 8501
COPY ./data/DejaVuSans.ttf /usr/share/fonts/truetype/
COPY ./configs/ /sd/configs/
COPY ./data/ /sd/data/
COPY ./frontend/ /sd/frontend/
COPY ./gfpgan/ /sd/gfpgan/
COPY ./images/ /sd/images/
COPY ./ldm/ /sd/ldm/
COPY ./models/ /sd/models/
COPY ./scripts/ /sd/scripts/
COPY ./.streamlit/ /sd/.streamlit/
COPY ./runpod_entrypoint.sh /sd/entrypoint.sh
ENTRYPOINT /sd/entrypoint.sh
RUN mkdir -p ~/.streamlit/
RUN echo "[general]" > ~/.streamlit/credentials.toml
RUN echo "email = \"\"" >> ~/.streamlit/credentials.toml

View File

@ -107,7 +107,7 @@ Lets you improve faces in pictures using the GFPGAN model. There is a checkbox i
If you want to use GFPGAN to improve generated faces, you need to install it separately.
Download [GFPGANv1.3.pth](https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth) and put it
into the `/stable-diffusion-webui/src/gfpgan/experiments/pretrained_models` directory.
into the `/stable-diffusion-webui/models/gfpgan` directory.
### RealESRGAN
@ -117,13 +117,13 @@ Lets you double the resolution of generated images. There is a checkbox in every
There is also a separate tab for using RealESRGAN on any picture.
Download [RealESRGAN_x4plus.pth](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth) and [RealESRGAN_x4plus_anime_6B.pth](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth).
Put them into the `stable-diffusion-webui/src/realesrgan/experiments/pretrained_models` directory.
Put them into the `stable-diffusion-webui/models/realesrgan` directory.
### GoBig, LSDR, and GoLatent *(Currently Gradio Only)*
More powerful upscalers that uses a seperate Latent Diffusion model to more cleanly upscale images.
Download **LDSR** [project.yaml](https://heibox.uni-heidelberg.de/f/31a76b13ea27482981b4/?dl=1) and [ model last.cpkt](https://heibox.uni-heidelberg.de/f/578df07c8fc04ffbadf3/?dl=1). Rename last.ckpt to model.ckpt and place both under stable-diffusion-webui/src/latent-diffusion/experiments/pretrained_models/
Download **LDSR** [project.yaml](https://heibox.uni-heidelberg.de/f/31a76b13ea27482981b4/?dl=1) and [ model last.cpkt](https://heibox.uni-heidelberg.de/f/578df07c8fc04ffbadf3/?dl=1). Rename last.ckpt to model.ckpt and place both under stable-diffusion-webui/models/ldsr/
Please see the [Image Enhancers Documentation](docs/5.image_enhancers.md) to learn more.

View File

@ -108,19 +108,19 @@ There are three more models that we need to download in order to get the most ou
### GFPGAN
1. If you want to use GFPGAN to improve generated faces, you need to install it separately.
1. Download [GFPGANv1.3.pth](https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth) and [GFPGANv1.4.pth](https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/GFPGANv1.4.pth) and put it
into the `/stable-diffusion-webui/src/gfpgan/experiments/pretrained_models` directory.
into the `/stable-diffusion-webui/models/gfpgan` directory.
### RealESRGAN
1. Download [RealESRGAN_x4plus.pth](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth) and [RealESRGAN_x4plus_anime_6B.pth](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth).
1. Put them into the `stable-diffusion-webui/src/realesrgan/experiments/pretrained_models` directory.
1. Put them into the `stable-diffusion-webui/models/realesrgan` directory.
### LDSR
1. Detailed instructions [here](https://github.com/Hafiidz/latent-diffusion). Brief instruction as follows.
1. Git clone [Hafiidz/latent-diffusion](https://github.com/Hafiidz/latent-diffusion) into your `/stable-diffusion-webui/src/` folder.
1. Run `/stable-diffusion-webui/src/latent-diffusion/download_model.bat` to automatically download and rename the models.
1. Wait until it is done and you can confirm by confirming two new files in `stable-diffusion-webui/src/latent-diffusion/experiments/pretrained_models/`
1. Run `/stable-diffusion-webui/models/ldsr/download_model.bat` to automatically download and rename the models.
1. Wait until it is done and you can confirm by confirming two new files in `stable-diffusion-webui/models/ldsr/`
1. _(Optional)_ If there are no files there, you can manually download **LDSR** [project.yaml](https://heibox.uni-heidelberg.de/f/31a76b13ea27482981b4/?dl=1) and [model last.cpkt](https://heibox.uni-heidelberg.de/f/578df07c8fc04ffbadf3/?dl=1).
1. Rename last.ckpt to model.ckpt and place both under `stable-diffusion-webui/src/latent-diffusion/experiments/pretrained_models/`.
1. Rename last.ckpt to model.ckpt and place both under `stable-diffusion-webui/models/ldsr/`.
1. Refer to [here](https://github.com/sd-webui/stable-diffusion-webui/issues/488) for any issue.

View File

@ -32,7 +32,7 @@ GFPGAN is designed to help restore faces in Stable Diffusion outputs. If you hav
If you want to use GFPGAN to improve generated faces, you need to download the models for it seperately if you are on Windows or doing so manually on Linux.
Download [GFPGANv1.3.pth](https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth) and put it
into the `/stable-diffusion-webui/src/gfpgan/experiments/pretrained_models` directory after you have setup the conda environment for the first time.
into the `/stable-diffusion-webui/models/gfpgan` directory after you have setup the conda environment for the first time.
## RealESRGAN
---
@ -42,7 +42,7 @@ RealESRGAN is a 4x upscaler built into both versions of the Web UI interface. It
If you want to use RealESRGAN to upscale your images, you need to download the models for it seperately if you are on Windows or doing so manually on Linux.
Download [RealESRGAN_x4plus.pth](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth) and [RealESRGAN_x4plus_anime_6B.pth](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth).
Put them into the `stable-diffusion-webui/src/realesrgan/experiments/pretrained_models` directory after you have setup the conda environment for the first time.
Put them into the `stable-diffusion-webui/models/realesrgan` directory after you have setup the conda environment for the first time.
## GoBig (Gradio only currently)
---
@ -57,7 +57,7 @@ To use GoBig, you will need to download the RealESRGAN models as directed above.
LSDR is a 4X upscaler with high VRAM usage that uses a Latent Diffusion model to upscale the image. This will accentuate the details of an image, but won't change the composition. This might introduce sharpening, but it is great for textures or compositions with plenty of details. However, it is slower and will use more VRAM.
If you want to use LSDR to upscale your images, you need to download the models for it seperately if you are on Windows or doing so manually on Linux.
Download the LDSR [project.yaml](https://heibox.uni-heidelberg.de/f/31a76b13ea27482981b4/?dl=1) and [ model last.cpkt](https://heibox.uni-heidelberg.de/f/578df07c8fc04ffbadf3/?dl=1). Rename `last.ckpt` to `model.ckpt` and place both in the `stable-diffusion-webui/src/latent-diffusion/experiments/pretrained_models` directory after you have setup the conda environment for the first time.
Download the LDSR [project.yaml](https://heibox.uni-heidelberg.de/f/31a76b13ea27482981b4/?dl=1) and [ model last.cpkt](https://heibox.uni-heidelberg.de/f/578df07c8fc04ffbadf3/?dl=1). Rename `last.ckpt` to `model.ckpt` and place both in the `stable-diffusion-webui/models/ldsr` directory after you have setup the conda environment for the first time.
## GoLatent (Gradio only currently)
---

View File

@ -45,85 +45,80 @@ mkdir -p $MODEL_DIR
# download URL
# sha256sum
MODEL_FILES=(
'model.ckpt models/ldm/stable-diffusion-v1 https://www.googleapis.com/storage/v1/b/aai-blog-files/o/sd-v1-4.ckpt?alt=media fe4efff1e174c627256e44ec2991ba279b3816e364b49f9be2abc0b3ff3f8556'
'GFPGANv1.3.pth src/gfpgan/experiments/pretrained_models https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth c953a88f2727c85c3d9ae72e2bd4846bbaf59fe6972ad94130e23e7017524a70'
'RealESRGAN_x4plus.pth src/realesrgan/experiments/pretrained_models https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth 4fa0d38905f75ac06eb49a7951b426670021be3018265fd191d2125df9d682f1'
'RealESRGAN_x4plus_anime_6B.pth src/realesrgan/experiments/pretrained_models https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth f872d837d3c90ed2e05227bed711af5671a6fd1c9f7d7e91c911a61f155e99da'
'project.yaml src/latent-diffusion/experiments/pretrained_models https://heibox.uni-heidelberg.de/f/31a76b13ea27482981b4/?dl=1 9d6ad53c5dafeb07200fb712db14b813b527edd262bc80ea136777bdb41be2ba'
'model.ckpt src/latent-diffusion/experiments/pretrained_models https://heibox.uni-heidelberg.de/f/578df07c8fc04ffbadf3/?dl=1 c209caecac2f97b4bb8f4d726b70ac2ac9b35904b7fc99801e1f5e61f9210c13'
'waifu-diffusion.ckpt models/custom https://huggingface.co/crumb/pruned-waifu-diffusion/resolve/main/model-pruned.ckpt 9b31355f90fea9933847175d4731a033f49f861395addc7e153f480551a24c25'
'trinart.ckpt models/custom https://huggingface.co/naclbit/trinart_stable_diffusion_v2/resolve/main/trinart2_step95000.ckpt c1799d22a355ba25c9ceeb6e3c91fc61788c8e274b73508ae8a15877c5dbcf63'
'model__base_caption.pth models/blip https://storage.googleapis.com/sfr-vision-language-research/BLIP/models/model*_base_caption.pth 96ac8749bd0a568c274ebe302b3a3748ab9be614c737f3d8c529697139174086'
'pytorch_model.bin models/clip-vit-large-patch14 https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/pytorch_model.bin f1a17cdbe0f36fec524f5cafb1c261ea3bbbc13e346e0f74fc9eb0460dedd0d3'
'config.json models/clip-vit-large-patch14 https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/config.json 8a09b467700c58138c29d53c605b34ebc69beaadd13274a8a2af8ad2c2f4032a'
'merges.txt models/clip-vit-large-patch14 https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/merges.txt 9fd691f7c8039210e0fced15865466c65820d09b63988b0174bfe25de299051a'
'preprocessor_config.json models/clip-vit-large-patch14 https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/preprocessor_config.json 910e70b3956ac9879ebc90b22fb3bc8a75b6a0677814500101a4c072bd7857bd'
'special_tokens_map.json models/clip-vit-large-patch14 https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/special_tokens_map.json f8c0d6c39aee3f8431078ef6646567b0aba7f2246e9c54b8b99d55c22b707cbf'
'tokenizer.json models/clip-vit-large-patch14 https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/tokenizer.json a83e0809aa4c3af7208b2df632a7a69668c6d48775b3c3fe4e1b1199d1f8b8f4'
'tokenizer_config.json models/clip-vit-large-patch14 https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/tokenizer_config.json deef455e52fa5e8151e339add0582e4235f066009601360999d3a9cda83b1129'
'vocab.json models/clip-vit-large-patch14 https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/vocab.json 3f0c4f7d2086b61b38487075278ea9ed04edb53a03cbb045b86c27190fa8fb69'
'model.ckpt models/ldm/stable-diffusion-v1 https://www.googleapis.com/storage/v1/b/aai-blog-files/o/sd-v1-4.ckpt?alt=media'
'GFPGANv1.4.pth models/gfpgan https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/GFPGANv1.4.pth'
'detection_Resnet50_Final.pth gfpgan/weights https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_Resnet50_Final.pth'
'parsing_parsenet.pth gfpgan/weights https://github.com/xinntao/facexlib/releases/download/v0.2.2/parsing_parsenet.pth'
'RealESRGAN_x4plus.pth models/realesrgan https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth'
'RealESRGAN_x4plus_anime_6B.pth models/realesrgan https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth'
'project.yaml models/ldsr https://heibox.uni-heidelberg.de/f/31a76b13ea27482981b4/?dl=1'
'model.ckpt models/ldsr https://heibox.uni-heidelberg.de/f/578df07c8fc04ffbadf3/?dl=1'
'waifu-diffusion.ckpt models/custom https://huggingface.co/crumb/pruned-waifu-diffusion/resolve/main/model-pruned.ckpt'
'trinart.ckpt models/custom https://huggingface.co/naclbit/trinart_stable_diffusion_v2/resolve/main/trinart2_step95000.ckpt'
'model__base_caption.pth models/blip https://storage.googleapis.com/sfr-vision-language-research/BLIP/models/model*_base_caption.pth'
'pytorch_model.bin models/clip-vit-large-patch14 https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/pytorch_model.bin'
'config.json models/clip-vit-large-patch14 https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/config.json'
'merges.txt models/clip-vit-large-patch14 https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/merges.txt'
'preprocessor_config.json models/clip-vit-large-patch14 https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/preprocessor_config.json'
'special_tokens_map.json models/clip-vit-large-patch14 https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/special_tokens_map.json'
'tokenizer.json models/clip-vit-large-patch14 https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/tokenizer.json'
'tokenizer_config.json models/clip-vit-large-patch14 https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/tokenizer_config.json'
'vocab.json models/clip-vit-large-patch14 https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/vocab.json'
)
# Function to checks for valid hash for model files and download/replaces if invalid or does not exist
validateDownloadModel() {
downloadModel() {
local file=$1
local path="${SCRIPT_DIR}/${2}"
local path_dir="${MODEL_DIR}/$2"
local url=$3
local hash=$4
echo "checking ${file}..."
sha256sum --check --status <<< "${hash} ${MODEL_DIR}/${file}.${hash}"
if [[ $? == "1" ]]; then
if [[ ! -e "${MODEL_DIR}/$2/${file}" ]]; then
echo "Downloading: ${url} please wait..."
mkdir -p ${MODEL_DIR}/$2
mkdir -p ${path}
wget --output-document=${MODEL_DIR}/${file}.${hash} --no-verbose --show-progress --progress=dot:giga ${url}
ln -sf ${MODEL_DIR}/${file}.${hash} ${path}/${file}
wget --output-document=${MODEL_DIR}/$2/${file} --no-verbose --show-progress --progress=dot:giga ${url}
ln -sf ${MODEL_DIR}/$2/${file} ${path}/${file}
if [[ -e "${path}/${file}" ]]; then
echo "saved ${file}"
else
echo "error saving ${path}/${file}!"
echo "error saving ${MODEL_DIR}/$2/${file}!"
exit 1
fi
else
if [[ ! -e ${path}/${file} || ! -L ${path}/${file} ]]; then
mkdir -p ${path}
ln -sf ${MODEL_DIR}/${file}.${hash} ${path}/${file}
echo -e "linked valid ${file}\n"
else
echo -e "${file} is valid!\n"
fi
fi
}
echo "Downloading model files..."
for models in "${MODEL_FILES[@]}"; do
model=($models)
if [[ ! -e ${model[1]}/${model[0]} || ! -L ${model[1]}/${model[0]} ]]; then
downloadModel ${model[0]} ${model[1]} ${model[2]}
fi
done
# Validate model files
if [ $VALIDATE_MODELS == "false" ]; then
echo "Skipping model file validation..."
else
echo "Validating model files..."
for models in "${MODEL_FILES[@]}"; do
model=($models)
if [[ ! -e ${model[1]}/${model[0]} || ! -L ${model[1]}/${model[0]} || -z $VALIDATE_MODELS || $VALIDATE_MODELS == "true" ]]; then
validateDownloadModel ${model[0]} ${model[1]} ${model[2]} ${model[3]}
fi
done
mkdir -p ${MODEL_DIR}/stable-diffusion-v1-4
mkdir -p ${MODEL_DIR}/waifu-diffusion
ln -fs ${SCRIPT_DIR}/models/clip-vit-large-patch14/ ${MODEL_DIR}/stable-diffusion-v1-4/tokenizer
ln -fs ${SCRIPT_DIR}/models/clip-vit-large-patch14/ ${MODEL_DIR}/waifu-diffusion/tokenizer
fi
# Create directory for diffusers models
mkdir -p ${MODEL_DIR}/diffusers/stable-diffusion-v1-4
mkdir -p ${MODEL_DIR}/diffusers/waifu-diffusion
mkdir -p ${SCRIPT_DIR}/diffusers/stable-diffusion-v1-4
mkdir -p ${SCRIPT_DIR}/diffusers/waifu-diffusion
# Link tokenizer to diffusers models
ln -fs ${SCRIPT_DIR}/models/clip-vit-large-patch14/ ${SCRIPT_DIR}/diffusers/stable-diffusion-v1-4/tokenizer
ln -fs ${SCRIPT_DIR}/models/clip-vit-large-patch14/ ${SCRIPT_DIR}/diffusers/waifu-diffusion/tokenizer
if [[ -e "${MODEL_DIR}/sd-concepts-library" ]]; then
# concept library exists, update
cd ${MODEL_DIR}/sd-concepts-library
git pull
else
# concept library does not exist, clone
cd ${MODEL_DIR}
git clone https://github.com/sd-webui/sd-concepts-library
git clone https://github.com/sd-webui/sd-concepts-library.git
fi
# create directory and link concepts library
mkdir -p ${SCRIPT_DIR}/models/custom
ln -fs ${MODEL_DIR}/sd-concepts-library/sd-concepts-library ${SCRIPT_DIR}/models/custom
ln -fs ${MODEL_DIR}/sd-concepts-library/sd-concepts-library/ ${SCRIPT_DIR}/models/custom/sd-concepts-library
mkdir -p ${SCRIPT_DIR}/user_data/outputs
ln -fs ${SCRIPT_DIR}/user_data/outputs/ ${SCRIPT_DIR}/outputs
echo "export HF_HOME=${MODEL_DIR}" >> ~/.bashrc
echo "export XDG_CACHE_HOME=${MODEL_DIR}" >> ~/.bashrc

View File

@ -104,35 +104,35 @@ sd_model_loading () {
# Checks to see if the upscaling models exist in their correct locations. If they do not they will be downloaded as required
post_processor_model_loading () {
# Check to see if GFPGAN has been added yet, if not it will download it and place it in the proper directory
if [ -f "$DIRECTORY/src/gfpgan/experiments/pretrained_models/GFPGANv1.3.pth" ]; then
if [ -f "$DIRECTORY/models/gfpgan/GFPGANv1.3.pth" ]; then
printf "GFPGAN already exists. Continuing...\n\n"
else
printf "Downloading GFPGAN model. Please wait...\n"
wget $GFPGAN_MODEL -P $DIRECTORY/src/gfpgan/experiments/pretrained_models
wget $GFPGAN_MODEL -P $DIRECTORY/models/gfpgan
fi
# Check to see if realESRGAN has been added yet, if not it will download it and place it in the proper directory
if [ -f "$DIRECTORY/src/realesrgan/experiments/pretrained_models/RealESRGAN_x4plus.pth" ]; then
if [ -f "$DIRECTORY/models/realesrgan/RealESRGAN_x4plus.pth" ]; then
printf "realESRGAN already exists. Continuing...\n\n"
else
printf "Downloading realESRGAN model. Please wait...\n"
wget $REALESRGAN_MODEL -P $DIRECTORY/src/realesrgan/experiments/pretrained_models
wget $REALESRGAN_ANIME_MODEL -P $DIRECTORY/src/realesrgan/experiments/pretrained_models
wget $REALESRGAN_MODEL -P $DIRECTORY/models/realesrgan
wget $REALESRGAN_ANIME_MODEL -P $DIRECTORY/models/realesrgan
fi
# Check to see if LDSR has been added yet, if not it will be cloned and its models downloaded to the correct directory
if [ -f "$DIRECTORY/src/latent-diffusion/experiments/pretrained_models/model.ckpt" ]; then
if [ -f "$DIRECTORY/models/ldsr/model.ckpt" ]; then
printf "LDSR already exists. Continuing...\n\n"
else
printf "Cloning LDSR and downloading model. Please wait...\n"
git clone $LATENT_DIFFUSION_REPO
mv latent-diffusion $DIRECTORY/src/latent-diffusion
mkdir $DIRECTORY/src/latent-diffusion/experiments
mkdir $DIRECTORY/src/latent-diffusion/experiments/pretrained_models
wget $LSDR_CONFIG -P $DIRECTORY/src/latent-diffusion/experiments/pretrained_models
mv $DIRECTORY/src/latent-diffusion/experiments/pretrained_models/index.html?dl=1 $DIRECTORY/src/latent-diffusion/experiments/pretrained_models/project.yaml
wget $LSDR_MODEL -P $DIRECTORY/src/latent-diffusion/experiments/pretrained_models
mv $DIRECTORY/src/latent-diffusion/experiments/pretrained_models/index.html?dl=1 $DIRECTORY/src/latent-diffusion/experiments/pretrained_models/model.ckpt
mv latent-diffusion $DIRECTORY/models/ldsr
mkdir $DIRECTORY/models/ldsr/experiments
mkdir $DIRECTORY/models/ldsr
wget $LSDR_CONFIG -P $DIRECTORY/models/ldsr
mv $DIRECTORY/models/ldsr/index.html?dl=1 $DIRECTORY/models/ldsr/project.yaml
wget $LSDR_MODEL -P $DIRECTORY/models/ldsr
mv $DIRECTORY/models/ldsr/index.html?dl=1 $DIRECTORY/models/ldsr/model.ckpt
fi
# Check to see if SD Concepts has been added yet, if not it will download it and place it in the proper directory

44
runpod_entrypoint.sh Normal file
View File

@ -0,0 +1,44 @@
#!/bin/bash
# This file is part of stable-diffusion-webui (https://github.com/sd-webui/stable-diffusion-webui/).
# Copyright 2022 sd-webui team.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Starts the webserver inside the docker container
#
# set -x
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd $SCRIPT_DIR
export PYTHONPATH=$SCRIPT_DIR
if [[ $PUBLIC_KEY ]]
then
mkdir -p ~/.ssh
chmod 700 ~/.ssh
cd ~/.ssh
echo $PUBLIC_KEY >> authorized_keys
chmod 700 -R ~/.ssh
cd /
service ssh start
echo "SSH Service Started"
fi
cd $SCRIPT_DIR
launch_command="streamlit run ${SCRIPT_DIR}/scripts/webui_streamlit.py"
$launch_command
sleep infinity

View File

@ -173,7 +173,7 @@ def layout():
Default: 'models/custom/sd-concepts-library'")
st.session_state['defaults'].general.LDSR_dir = st.text_input("LDSR Folder", value=st.session_state['defaults'].general.LDSR_dir,
help="Folder where LDSR is located. Default: './src/latent-diffusion'")
help="Folder where LDSR is located. Default: './models/ldsr'")
st.session_state["defaults"].general.save_metadata = st.checkbox("Save Metadata", value=st.session_state['defaults'].general.save_metadata,
help="Save metadata on the output image. Default: True")

View File

@ -25,30 +25,30 @@ def updateModels():
# os.system('wget https://cdn-lfs.huggingface.co/repos/ab/41/ab41ccb635cd5bd124c8eac1b5796b4f64049c9453c4e50d51819468ca69ceb8/14749efc0ae8ef0329391ad4436feb781b402f4fece4883c7ad8d10556d8a36a?response-content-disposition=attachment%3B%20filename%3D%22modelfull.ckpt%22 -o models/ldm/stable-diffusion-v1/model.ckpt')
# os.rename('models/ldm/stable-diffusion-v1/modelfull.ckpt','models/ldm/stable-diffusion-v1/model.ckpt')
if op.exists('src/realesrgan/experiments/pretrained_models/RealESRGAN_x4plus.pth') and op.exists('src/realesrgan/experiments/pretrained_models/RealESRGAN_x4plus_anime_6B.pth'):
if op.exists('models/realesrgan/RealESRGAN_x4plus.pth') and op.exists('models/realesrgan/RealESRGAN_x4plus_anime_6B.pth'):
pass
else:
os.system('wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -P src/realesrgan/experiments/pretrained_models')
os.system('wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth -P src/realesrgan/experiments/pretrained_models')
os.system('wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -P models/realesrgan')
os.system('wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth -P models/realesrgan')
if op.exists('src/gfpgan/experiments/pretrained_models/GFPGANv1.3.pth'):
if op.exists('models/gfpgan/GFPGANv1.3.pth'):
pass
else:
os.system('wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth -P src/gfpgan/experiments/pretrained_models')
os.system('wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth -P models/gfpgan')
if op.exists('src/latent-diffusion'):
if op.exists('models/ldsr'):
pass
else:
os.system('git clone https://github.com/devilismyfriend/latent-diffusion.git')
os.system('mv latent-diffusion src/latent-diffusion')
os.system('mv latent-diffusion models/ldsr')
if op.exists('src/latent-diffusion/experiments/pretrained_models/model.ckpt'):
if op.exists('models/ldsr/model.ckpt'):
pass
else:
os.mkdir('src/latent-diffusion/experiments')
os.mkdir('src/latent-diffusion/experiments/pretrained_models')
os.system('wget https://heibox.uni-heidelberg.de/f/31a76b13ea27482981b4/?dl=1 -o src/latent-diffusion/experiments/pretrained_models/project.yaml')
# os.rename('src/latent-diffusion/experiments/pretrained_models/index.html?dl=1', 'src/latent-diffusion/experiments/pretrained_models/project.yaml')
os.system('wget https://heibox.uni-heidelberg.de/f/578df07c8fc04ffbadf3/?dl=1 -o src/latent-diffusion/experiments/pretrained_models/model.ckpt')
# os.rename('src/latent-diffusion/experiments/pretrained_models/index.html?dl=1', 'src/latent-diffusion/experiments/pretrained_models/model.ckpt')
os.mkdir('models/ldsr/experiments')
os.mkdir('models/ldsr')
os.system('wget https://heibox.uni-heidelberg.de/f/31a76b13ea27482981b4/?dl=1 -o models/ldsr/project.yaml')
# os.rename('models/ldsr/index.html?dl=1', 'models/ldsr/project.yaml')
os.system('wget https://heibox.uni-heidelberg.de/f/578df07c8fc04ffbadf3/?dl=1 -o models/ldsr/model.ckpt')
# os.rename('models/ldsr/index.html?dl=1', 'models/ldsr/model.ckpt')

View File

@ -1295,7 +1295,7 @@ def load_LDSR(model_name="model", config="project", checking=False):
#print("Error loading LDSR:", file=sys.stderr)
#print(traceback.format_exc(), file=sys.stderr)
#else:
#print("LDSR not found at path, please make sure you have cloned the LDSR repo to ./src/latent-diffusion/")
#print("LDSR not found at path, please make sure you have cloned the LDSR repo to ./models/ldsr/")
#try_loading_LDSR('model',checking=True)

View File

@ -33,12 +33,12 @@ parser.add_argument("--esrgan-gpu", type=int, help="run ESRGAN on specific gpu (
parser.add_argument("--extra-models-cpu", action='store_true', help="run extra models (GFGPAN/ESRGAN) on cpu", default=False)
parser.add_argument("--extra-models-gpu", action='store_true', help="run extra models (GFGPAN/ESRGAN) on gpu", default=False)
parser.add_argument("--gfpgan-cpu", action='store_true', help="run GFPGAN on cpu", default=False)
parser.add_argument("--gfpgan-dir", type=str, help="GFPGAN directory", default=('./src/gfpgan' if os.path.exists('./src/gfpgan') else './GFPGAN')) # i disagree with where you're putting it but since all guidefags are doing it this way, there you go
parser.add_argument("--gfpgan-dir", type=str, help="GFPGAN directory", default=('./models/gfpgan' if os.path.exists('./models/gfpgan') else './GFPGAN')) # i disagree with where you're putting it but since all guidefags are doing it this way, there you go
parser.add_argument("--gfpgan-gpu", type=int, help="run GFPGAN on specific gpu (overrides --gpu) ", default=0)
parser.add_argument("--gpu", type=int, help="choose which GPU to use if you have multiple", default=0)
parser.add_argument("--grid-format", type=str, help="png for lossless png files; jpg:quality for lossy jpeg; webp:quality for lossy webp, or webp:-compression for lossless webp", default="jpg:95")
parser.add_argument("--inbrowser", action='store_true', help="automatically launch the interface in a new tab on the default browser", default=False)
parser.add_argument("--ldsr-dir", type=str, help="LDSR directory", default=('./src/latent-diffusion' if os.path.exists('./src/latent-diffusion') else './LDSR'))
parser.add_argument("--ldsr-dir", type=str, help="LDSR directory", default=('./models/ldsr' if os.path.exists('./models/ldsr') else './LDSR'))
parser.add_argument("--n_rows", type=int, default=-1, help="rows in the grid; use -1 for autodetect and 0 for n_rows to be same as batch_size (default: -1)",)
parser.add_argument("--no-half", action='store_true', help="do not switch the model to 16-bit floats", default=False)
parser.add_argument("--no-progressbar-hiding", action='store_true', help="do not hide progressbar in gradio UI (we hide it because it slows down ML if you have hardware accleration in browser)", default=False)
@ -53,7 +53,7 @@ parser.add_argument("--outdir", type=str, nargs="?", help="dir to write results
parser.add_argument("--filename_format", type=str, nargs="?", help="filenames format", default=None)
parser.add_argument("--port", type=int, help="choose the port for the gradio webserver to use", default=7860)
parser.add_argument("--precision", type=str, help="evaluate at this precision", choices=["full", "autocast"], default="autocast")
parser.add_argument("--realesrgan-dir", type=str, help="RealESRGAN directory", default=('./src/realesrgan' if os.path.exists('./src/realesrgan') else './RealESRGAN'))
parser.add_argument("--realesrgan-dir", type=str, help="RealESRGAN directory", default=('./models/realesrgan' if os.path.exists('./models/realesrgan') else './RealESRGAN'))
parser.add_argument("--realesrgan-model", type=str, help="Upscaling model for RealESRGAN", default=('RealESRGAN_x4plus'))
parser.add_argument("--save-metadata", action='store_true', help="Store generation parameters in the output png. Drop saved png into Image Lab to read parameters", default=False)
parser.add_argument("--share-password", type=str, help="Sharing is open by default, use this to set a password. Username: webui", default=None)
@ -467,7 +467,7 @@ def try_loading_LDSR(model_name: str,checking=False):
print("Error loading LDSR:", file=sys.stderr)
print(traceback.format_exc(), file=sys.stderr)
else:
print("LDSR not found at path, please make sure you have cloned the LDSR repo to ./src/latent-diffusion/")
print("LDSR not found at path, please make sure you have cloned the LDSR repo to ./models/ldsr/")
try_loading_LDSR('model',checking=True)
def load_SD_model():

View File

@ -104,35 +104,35 @@ sd_model_loading () {
# Checks to see if the upscaling models exist in their correct locations. If they do not they will be downloaded as required
post_processor_model_loading () {
# Check to see if GFPGAN has been added yet, if not it will download it and place it in the proper directory
if [ -f "$DIRECTORY/src/gfpgan/experiments/pretrained_models/GFPGANv1.3.pth" ]; then
if [ -f "$DIRECTORY/models/gfpgan/GFPGANv1.3.pth" ]; then
printf "GFPGAN already exists. Continuing...\n\n"
else
printf "Downloading GFPGAN model. Please wait...\n"
wget $GFPGAN_MODEL -P $DIRECTORY/src/gfpgan/experiments/pretrained_models
wget $GFPGAN_MODEL -P $DIRECTORY/models/gfpgan
fi
# Check to see if realESRGAN has been added yet, if not it will download it and place it in the proper directory
if [ -f "$DIRECTORY/src/realesrgan/experiments/pretrained_models/RealESRGAN_x4plus.pth" ]; then
if [ -f "$DIRECTORY/models/realesrgan/RealESRGAN_x4plus.pth" ]; then
printf "realESRGAN already exists. Continuing...\n\n"
else
printf "Downloading realESRGAN model. Please wait...\n"
wget $REALESRGAN_MODEL -P $DIRECTORY/src/realesrgan/experiments/pretrained_models
wget $REALESRGAN_ANIME_MODEL -P $DIRECTORY/src/realesrgan/experiments/pretrained_models
wget $REALESRGAN_MODEL -P $DIRECTORY/models/realesrgan
wget $REALESRGAN_ANIME_MODEL -P $DIRECTORY/models/realesrgan
fi
# Check to see if LDSR has been added yet, if not it will be cloned and its models downloaded to the correct directory
if [ -f "$DIRECTORY/src/latent-diffusion/experiments/pretrained_models/model.ckpt" ]; then
if [ -f "$DIRECTORY/models/ldsr/model.ckpt" ]; then
printf "LDSR already exists. Continuing...\n\n"
else
printf "Cloning LDSR and downloading model. Please wait...\n"
git clone $LATENT_DIFFUSION_REPO
mv latent-diffusion $DIRECTORY/src/latent-diffusion
mkdir $DIRECTORY/src/latent-diffusion/experiments
mkdir $DIRECTORY/src/latent-diffusion/experiments/pretrained_models
wget $LSDR_CONFIG -P $DIRECTORY/src/latent-diffusion/experiments/pretrained_models
mv $DIRECTORY/src/latent-diffusion/experiments/pretrained_models/index.html?dl=1 $DIRECTORY/src/latent-diffusion/experiments/pretrained_models/project.yaml
wget $LSDR_MODEL -P $DIRECTORY/src/latent-diffusion/experiments/pretrained_models
mv $DIRECTORY/src/latent-diffusion/experiments/pretrained_models/index.html?dl=1 $DIRECTORY/src/latent-diffusion/experiments/pretrained_models/model.ckpt
mv latent-diffusion $DIRECTORY/models/ldsr
mkdir $DIRECTORY/models/ldsr/experiments
mkdir $DIRECTORY/models/ldsr
wget $LSDR_CONFIG -P $DIRECTORY/models/ldsr
mv $DIRECTORY/models/ldsr/index.html?dl=1 $DIRECTORY/models/ldsr/project.yaml
wget $LSDR_MODEL -P $DIRECTORY/models/ldsr
mv $DIRECTORY/models/ldsr/index.html?dl=1 $DIRECTORY/models/ldsr/model.ckpt
fi
# Check to see if SD Concepts has been added yet, if not it will download it and place it in the proper directory