carloscar commited on
Commit
bb5b380
1 Parent(s): d9cb740

hugging face space fixes

Browse files
Files changed (5) hide show
  1. Dockerfile +5 -12
  2. README.md +6 -9
  3. on_start.sh +15 -0
  4. run.py +2 -1
  5. ui-config.json +2 -2
Dockerfile CHANGED
@@ -1,6 +1,3 @@
1
- # GPU should be set to either "A10G" or "T4"
2
- ARG GPU=A10G
3
-
4
  FROM nvidia/cuda:11.7.1-cudnn8-devel-ubuntu22.04
5
 
6
  ENV DEBIAN_FRONTEND noninteractive
@@ -74,14 +71,6 @@ WORKDIR /app
74
  COPY pyproject.toml poetry.lock /app/
75
  RUN poetry install
76
 
77
- # Install xformers for the specified GPU
78
- ARG GPU
79
- RUN case "$GPU" in \
80
- [aA]10[gG]) /opt/venv/bin/pip install https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.16/xformers-0.0.16+814314d.d20230119.A10G-cp310-cp310-linux_x86_64.whl;; \
81
- [tT]4) /opt/venv/bin/pip install https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.16/xformers-0.0.16+814314d.d20230118-cp310-cp310-linux_x86_64.whl;; \
82
- *) echo "invalid GPU setting"; exit 1;; \
83
- esac
84
-
85
  # WebUI + extensions
86
  RUN git clone -b v2.0 https://github.com/camenduru/stable-diffusion-webui
87
  RUN wget https://raw.githubusercontent.com/camenduru/stable-diffusion-webui-scripts/main/run_n_times.py -O /app/stable-diffusion-webui/scripts/run_n_times.py
@@ -98,6 +87,10 @@ WORKDIR /app/stable-diffusion-webui
98
  COPY config.json ui-config.json /app/stable-diffusion-webui/
99
  RUN python launch.py --exit --skip-torch-cuda-test
100
 
 
 
 
 
101
  # Copy startup scripts
102
  COPY run.py on_start.sh /app/stable-diffusion-webui/
103
  RUN chmod +x on_start.sh
@@ -109,4 +102,4 @@ USER user
109
 
110
  EXPOSE 7860
111
 
112
- CMD ["python", "run.py", "--force-enable-xformers", "--ui-config-file", "ui-config.json", "--ui-settings-file", "config.json", "--disable-console-progressbars", "--cors-allow-origins", "huggingface.co,hf.space", "--no-progressbar-hiding", "--no-download-sd-model", "--api", "--skip-version-check"]
 
 
 
 
1
  FROM nvidia/cuda:11.7.1-cudnn8-devel-ubuntu22.04
2
 
3
  ENV DEBIAN_FRONTEND noninteractive
 
71
  COPY pyproject.toml poetry.lock /app/
72
  RUN poetry install
73
 
 
 
 
 
 
 
 
 
74
  # WebUI + extensions
75
  RUN git clone -b v2.0 https://github.com/camenduru/stable-diffusion-webui
76
  RUN wget https://raw.githubusercontent.com/camenduru/stable-diffusion-webui-scripts/main/run_n_times.py -O /app/stable-diffusion-webui/scripts/run_n_times.py
 
87
  COPY config.json ui-config.json /app/stable-diffusion-webui/
88
  RUN python launch.py --exit --skip-torch-cuda-test
89
 
90
+ RUN sed -i -e 's/ show_progress=False,/ show_progress=True,/g' modules/ui.py
91
+ RUN sed -i -e 's/shared.demo.launch/shared.demo.queue().launch/g' webui.py
92
+ RUN sed -i -e 's/ outputs=\[/queue=False, &/g' modules/ui.py
93
+
94
  # Copy startup scripts
95
  COPY run.py on_start.sh /app/stable-diffusion-webui/
96
  RUN chmod +x on_start.sh
 
102
 
103
  EXPOSE 7860
104
 
105
+ CMD ["/opt/venv/bin/python", "run.py", "--force-enable-xformers", "--xformers", "--listen", "--enable-insecure-extension-access", "--ui-config-file", "ui-config.json", "--ui-settings-file", "config.json", "--disable-console-progressbars", "--cors-allow-origins", "huggingface.co,hf.space", "--no-progressbar-hiding", "--enable-console-prompts", "--no-download-sd-model", "--api", "--skip-version-check"]
README.md CHANGED
@@ -6,6 +6,10 @@ colorTo: yellow
6
  sdk: docker
7
  app_port: 7860
8
  pinned: true
 
 
 
 
9
  models:
10
  - stabilityai/stable-diffusion-2-1
11
  - runwayml/stable-diffusion-v1-5
@@ -23,15 +27,8 @@ Uses Stable Diffusion 2.1 models. Comes with several popular extensions to [AUTO
23
  ### Setup on Hugging Face
24
 
25
  1. Duplicate this space to your Hugging Face account or clone this repo to your account.
26
-
27
- 2. Within your duplicated space under *"Files and versions"*, specify the GPU model in the first lines of the [`Dockerfile`](./Dockerfile#L2) to match the hardware you're going to be using for your space.
28
-
29
- ```Dockerfile
30
- # GPU should be set to either "A10G" or "T4"
31
- ARG GPU=A10G
32
- ```
33
-
34
- 3. Under the *"Settings"* tab of your space you can choose which hardware for your space, that you will also be billed for.
35
 
36
  ---
37
 
 
6
  sdk: docker
7
  app_port: 7860
8
  pinned: true
9
+ tags:
10
+ - stable-diffusion
11
+ - stable-diffusion-diffusers
12
+ - text-to-image
13
  models:
14
  - stabilityai/stable-diffusion-2-1
15
  - runwayml/stable-diffusion-v1-5
 
27
  ### Setup on Hugging Face
28
 
29
  1. Duplicate this space to your Hugging Face account or clone this repo to your account.
30
+ 2. Under the *"Settings"* tab of your space you can choose which hardware for your space, that you will also be billed for.
31
+ 3. The [`on_start.sh`](./on_start.sh) file will be run when the container is started, right before the webui is initiated. This is where you can install any additional extensions or models you may need.
 
 
 
 
 
 
 
32
 
33
  ---
34
 
on_start.sh CHANGED
@@ -1,6 +1,18 @@
1
  #!/bin/bash
2
  set -euo pipefail
3
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  # SD 2.1 768 base model
5
  aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/stabilityai/stable-diffusion-2-1/resolve/36a01dc742066de2e8c91e7cf0b8f6b53ef53da1/v2-1_768-ema-pruned.safetensors -d /app/stable-diffusion-webui/models/Stable-diffusion -o v2-1_768-ema-pruned.safetensors
6
  aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://raw.githubusercontent.com/Stability-AI/stablediffusion/fc1488421a2761937b9d54784194157882cbc3b1/configs/stable-diffusion/v2-inference-v.yaml -d /app/stable-diffusion-webui/models/Stable-diffusion -o v2-1_768-ema-pruned.yaml
@@ -9,6 +21,9 @@ aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://raw.githubusercont
9
  aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors -d /app/stable-diffusion-webui/models/Stable-diffusion -o v1-5-pruned-emaonly.safetensors
10
  aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-inference.yaml -d /app/stable-diffusion-webui/models/Stable-diffusion -o v1-5-pruned-emaonly.yaml
11
 
 
 
 
12
  # Dreamlike Diffusion 1.0 model
13
  aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/dreamlike-art/dreamlike-diffusion-1.0/resolve/00cbe4d56fd56f45e952a5be4d847f21b9782546/dreamlike-diffusion-1.0.safetensors -d /app/stable-diffusion-webui/models/Stable-diffusion -o dreamlike-diffusion-1.0.safetensors
14
 
 
1
  #!/bin/bash
2
  set -euo pipefail
3
 
4
+ echo "\$ nvidia smi"
5
+ nvidia-smi
6
+
7
+ # Install xformers matching the GPU (only for Nvidia A10G and T4 GPUs)
8
+ if nvidia-smi --query-gpu=gpu_name --format=csv,noheader | grep -q A10G; then
9
+ /opt/venv/bin/pip install https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.16/xformers-0.0.16+814314d.d20230119.A10G-cp310-cp310-linux_x86_64.whl
10
+ elif nvidia-smi --query-gpu=gpu_name --format=csv,noheader | grep -q T4; then
11
+ /opt/venv/bin/pip install https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.16/xformers-0.0.16+814314d.d20230118-cp310-cp310-linux_x86_64.whl
12
+ else
13
+ /opt/venv/bin/pip install --pre xformers
14
+ fi
15
+
16
  # SD 2.1 768 base model
17
  aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/stabilityai/stable-diffusion-2-1/resolve/36a01dc742066de2e8c91e7cf0b8f6b53ef53da1/v2-1_768-ema-pruned.safetensors -d /app/stable-diffusion-webui/models/Stable-diffusion -o v2-1_768-ema-pruned.safetensors
18
  aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://raw.githubusercontent.com/Stability-AI/stablediffusion/fc1488421a2761937b9d54784194157882cbc3b1/configs/stable-diffusion/v2-inference-v.yaml -d /app/stable-diffusion-webui/models/Stable-diffusion -o v2-1_768-ema-pruned.yaml
 
21
  aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors -d /app/stable-diffusion-webui/models/Stable-diffusion -o v1-5-pruned-emaonly.safetensors
22
  aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-inference.yaml -d /app/stable-diffusion-webui/models/Stable-diffusion -o v1-5-pruned-emaonly.yaml
23
 
24
+ # VAE
25
+ aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors -d /app/stable-diffusion-webui/models/VAE -o vae-ft-mse-840000-ema-pruned.safetensors
26
+
27
  # Dreamlike Diffusion 1.0 model
28
  aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/dreamlike-art/dreamlike-diffusion-1.0/resolve/00cbe4d56fd56f45e952a5be4d847f21b9782546/dreamlike-diffusion-1.0.safetensors -d /app/stable-diffusion-webui/models/Stable-diffusion -o dreamlike-diffusion-1.0.safetensors
29
 
run.py CHANGED
@@ -13,6 +13,7 @@ def on_start():
13
  def start():
14
  on_start()
15
 
 
16
  print(f"Launching {'API server' if '--nowebui' in sys.argv else 'Web UI'} with arguments: {' '.join(sys.argv[1:])}")
17
  import webui # type: ignore # noqa
18
  if '--nowebui' in sys.argv:
@@ -22,4 +23,4 @@ def start():
22
 
23
 
24
  if __name__ == "__main__":
25
- start()
 
13
  def start():
14
  on_start()
15
 
16
+ print("---------------")
17
  print(f"Launching {'API server' if '--nowebui' in sys.argv else 'Web UI'} with arguments: {' '.join(sys.argv[1:])}")
18
  import webui # type: ignore # noqa
19
  if '--nowebui' in sys.argv:
 
23
 
24
 
25
  if __name__ == "__main__":
26
+ start()
ui-config.json CHANGED
@@ -2,7 +2,7 @@
2
  "txt2img/Prompt/visible": true,
3
  "txt2img/Prompt/value": "",
4
  "txt2img/Negative prompt/visible": true,
5
- "txt2img/Negative prompt/value": "",
6
  "txt2img/Style 1/value": "None",
7
  "txt2img/Style 1/visible": true,
8
  "txt2img/Style 2/value": "None",
@@ -106,7 +106,7 @@
106
  "img2img/Prompt/visible": true,
107
  "img2img/Prompt/value": "",
108
  "img2img/Negative prompt/visible": true,
109
- "img2img/Negative prompt/value": "",
110
  "img2img/Style 1/value": "None",
111
  "img2img/Style 1/visible": true,
112
  "img2img/Style 2/value": "None",
 
2
  "txt2img/Prompt/visible": true,
3
  "txt2img/Prompt/value": "",
4
  "txt2img/Negative prompt/visible": true,
5
+ "txt2img/Negative prompt/value": "(worst quality:1.4), (low quality:1.4), (monochrome:1.1), (bad_prompt_version2:0.8), bad art, text, jpeg, watermark, artist sign, blurry, out of frame, ((disfigured)), deformations, extra limb, missing limbs, floating limbs, poorly drawn face, poorly drawn hands, missing fingers, split screen, bad hands, missing fingers, (malformed limbs), ((missing arms)), ((missing legs)), (((extra arms))), (((extra legs))), mutation, mutated hands, (fused fingers), (too many fingers), (((long neck))), roothand, crabhand, vinehand, pincers, [low_resolution], normal quality, cross eyed, bad anatomy, very thin legs, very thin arms, deformed, surreal, ",
6
  "txt2img/Style 1/value": "None",
7
  "txt2img/Style 1/visible": true,
8
  "txt2img/Style 2/value": "None",
 
106
  "img2img/Prompt/visible": true,
107
  "img2img/Prompt/value": "",
108
  "img2img/Negative prompt/visible": true,
109
+ "img2img/Negative prompt/value": "(worst quality:1.4), (low quality:1.4), (monochrome:1.1), (bad_prompt_version2:0.8), bad art, text, jpeg, watermark, artist sign, blurry, out of frame, ((disfigured)), deformations, extra limb, missing limbs, floating limbs, poorly drawn face, poorly drawn hands, missing fingers, split screen, bad hands, missing fingers, (malformed limbs), ((missing arms)), ((missing legs)), (((extra arms))), (((extra legs))), mutation, mutated hands, (fused fingers), (too many fingers), (((long neck))), roothand, crabhand, vinehand, pincers, [low_resolution], normal quality, cross eyed, bad anatomy, very thin legs, very thin arms, deformed, surreal, ",
110
  "img2img/Style 1/value": "None",
111
  "img2img/Style 1/visible": true,
112
  "img2img/Style 2/value": "None",