atikur-rabbi commited on
Commit
0a21a41
1 Parent(s): 51f5a72
Dockerfile CHANGED
@@ -22,20 +22,18 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
22
 
23
  RUN useradd -m huggingface
24
 
25
- USER huggingface
26
-
27
- WORKDIR /home/huggingface
28
-
29
 
30
- RUN wget https://github.com/cmdr2/stable-diffusion-ui/releases/download/v2.5.24/Easy-Diffusion-Linux.zip && \
31
- unzip Easy-Diffusion-Linux.zip && \
32
- rm Easy-Diffusion-Linux.zip
33
 
34
- # ENTRYPOINT [ "docker-entrypoint.py" ]
35
- RUN cd easy-diffusion && \
36
- ls -l
 
37
 
38
- EXPOSE 9000
39
 
40
- CMD [ "./start,sh" ]
41
 
 
22
 
23
  RUN useradd -m huggingface
24
 
25
+ # RUN wget https://github.com/cmdr2/stable-diffusion-ui/releases/download/v2.5.24/Easy-Diffusion-Linux.zip && \
26
+ # unzip Easy-Diffusion-Linux.zip && \
27
+ # rm Easy-Diffusion-Linux.zip
 
28
 
29
+ EXPOSE 9000
 
 
30
 
31
+ RUN chown -R huggingface /home/huggingface/easy-diffusion
32
+ RUN chmod -R u+x /home/huggingface/easy-diffusion
33
+
34
+ USER huggingface
35
 
36
+ WORKDIR /home/huggingface
37
 
38
+ CMD [ "easy-diffusion/start.sh" ]
39
 
build.sh DELETED
@@ -1,95 +0,0 @@
1
- #!/bin/sh
2
-
3
- set -eu
4
-
5
- CWD=$(basename "$PWD")
6
-
7
- set_gpu_arg() {
8
- while [ "$#" -gt 0 ]; do
9
- if [ "$1" = "--device" ] && [ "$2" = "cpu" ]; then
10
- GPU_ARG=""
11
- return
12
- fi
13
- shift
14
- done
15
- GPU_ARG="--gpus=all"
16
- }
17
-
18
- build() {
19
- docker build . --tag "$CWD"
20
- }
21
-
22
- clean() {
23
- docker system prune -f
24
- }
25
-
26
- dev() {
27
- docker run --rm --gpus=all --entrypoint=sh \
28
- -v huggingface:/home/huggingface/.cache/huggingface \
29
- -v "$PWD"/input:/home/huggingface/input \
30
- -v "$PWD"/output:/home/huggingface/output \
31
- -it "$CWD"
32
- }
33
-
34
- pull() {
35
- GHCR="ghcr.io/fboulnois/stable-diffusion-docker"
36
- docker pull "$GHCR"
37
- docker tag "$GHCR" "$CWD"
38
- }
39
-
40
- run() {
41
- set_gpu_arg "$@"
42
- docker run --rm ${GPU_ARG} \
43
- -v huggingface:/home/huggingface/.cache/huggingface \
44
- -v "$PWD"/input:/home/huggingface/input \
45
- -v "$PWD"/output:/home/huggingface/output \
46
- "$CWD" "$@"
47
- }
48
-
49
- tests() {
50
- BASE_URL="https://raw.githubusercontent.com/fboulnois/repository-assets/main/assets/stable-diffusion-docker"
51
- TEST_IMAGE="An_impressionist_painting_of_a_parakeet_eating_spaghetti_in_the_desert_full.png"
52
- curl -sL "${BASE_URL}/${TEST_IMAGE}" > "$PWD/input/${TEST_IMAGE}"
53
- run --skip --height 512 --width 640 "abstract art"
54
- run --device cpu --onnx --image "${TEST_IMAGE}" --strength 0.6 "abstract art"
55
- run --model "stabilityai/stable-diffusion-2" \
56
- --skip --height 768 --width 768 "abstract art"
57
- run --model "stabilityai/stable-diffusion-2-1" \
58
- --skip --height 768 --width 768 "abstract art"
59
- run --model "stabilityai/stable-diffusion-x4-upscaler" \
60
- --image "${TEST_IMAGE}" --half --attention-slicing \
61
- --xformers-memory-efficient-attention \
62
- --prompt "An impressionist painting of a parakeet eating spaghetti in the desert"
63
- run --model "stabilityai/stable-diffusion-2-depth" \
64
- --height 768 --width 768 \
65
- --image "${TEST_IMAGE}" --attention-slicing \
66
- --xformers-memory-efficient-attention \
67
- --negative-prompt "bad, ugly, deformed, malformed, mutated, bad anatomy" \
68
- --prompt "a toucan"
69
- run --model "timbrooks/instruct-pix2pix" \
70
- --scale 7.0 --image-scale 2.0 \
71
- --image "${TEST_IMAGE}" --attention-slicing \
72
- --xformers-memory-efficient-attention \
73
- --negative-prompt "bad, ugly, deformed, malformed, mutated, bad anatomy" \
74
- --prompt "replace the sky with bricks"
75
- run --model "dreamlike-art/dreamlike-diffusion-1.0" \
76
- --skip --vae-tiling --xformers-memory-efficient-attention \
77
- --height 1024 --width 1024 "abstract art"
78
- run --model "runwayml/stable-diffusion-v1-5" \
79
- --samples 2 --iters 2 --seed 42 \
80
- --scheduler HeunDiscreteScheduler \
81
- --scale 7.5 --steps 80 --attention-slicing \
82
- --half --skip --negative-prompt "red roses" \
83
- --prompt "bouquet of roses"
84
- }
85
-
86
- mkdir -p input output
87
- case ${1:-build} in
88
- build) build ;;
89
- clean) clean ;;
90
- dev) dev "$@" ;;
91
- pull) pull ;;
92
- run) shift; run "$@" ;;
93
- test) tests ;;
94
- *) echo "$0: No command named '$1'" ;;
95
- esac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docker-entrypoint.py DELETED
@@ -1,286 +0,0 @@
1
- #!/usr/bin/env python
2
- import argparse, datetime, inspect, os, warnings
3
- import numpy as np
4
- import torch
5
- from PIL import Image
6
- from diffusers import (
7
- OnnxStableDiffusionPipeline,
8
- OnnxStableDiffusionInpaintPipeline,
9
- OnnxStableDiffusionImg2ImgPipeline,
10
- StableDiffusionDepth2ImgPipeline,
11
- StableDiffusionPipeline,
12
- StableDiffusionImg2ImgPipeline,
13
- StableDiffusionInpaintPipeline,
14
- StableDiffusionInstructPix2PixPipeline,
15
- StableDiffusionUpscalePipeline,
16
- schedulers,
17
- )
18
-
19
-
20
- def iso_date_time():
21
- return datetime.datetime.now().isoformat()
22
-
23
-
24
- def load_image(path):
25
- image = Image.open(os.path.join("input", path)).convert("RGB")
26
- print(f"loaded image from {path}:", iso_date_time(), flush=True)
27
- return image
28
-
29
-
30
- def remove_unused_args(p):
31
- params = inspect.signature(p.pipeline).parameters.keys()
32
- args = {
33
- "prompt": p.prompt,
34
- "negative_prompt": p.negative_prompt,
35
- "image": p.image,
36
- "mask_image": p.mask,
37
- "height": p.height,
38
- "width": p.width,
39
- "num_images_per_prompt": p.samples,
40
- "num_inference_steps": p.steps,
41
- "guidance_scale": p.scale,
42
- "image_guidance_scale": p.image_scale,
43
- "strength": p.strength,
44
- "generator": p.generator,
45
- }
46
- return {p: args[p] for p in params if p in args}
47
-
48
-
49
- def stable_diffusion_pipeline(p):
50
- p.dtype = torch.float16 if p.half else torch.float32
51
-
52
- if p.onnx:
53
- p.diffuser = OnnxStableDiffusionPipeline
54
- p.revision = "onnx"
55
- else:
56
- p.diffuser = StableDiffusionPipeline
57
- p.revision = "fp16" if p.half else "main"
58
-
59
- models = argparse.Namespace(
60
- **{
61
- "depth2img": ["stabilityai/stable-diffusion-2-depth"],
62
- "pix2pix": ["timbrooks/instruct-pix2pix"],
63
- "upscalers": ["stabilityai/stable-diffusion-x4-upscaler"],
64
- }
65
- )
66
-
67
- if p.image is not None:
68
- if p.revision == "onnx":
69
- p.diffuser = OnnxStableDiffusionImg2ImgPipeline
70
- elif p.model in models.depth2img:
71
- p.diffuser = StableDiffusionDepth2ImgPipeline
72
- elif p.model in models.pix2pix:
73
- p.diffuser = StableDiffusionInstructPix2PixPipeline
74
- elif p.model in models.upscalers:
75
- p.diffuser = StableDiffusionUpscalePipeline
76
- else:
77
- p.diffuser = StableDiffusionImg2ImgPipeline
78
- p.image = load_image(p.image)
79
-
80
- if p.mask is not None:
81
- if p.revision == "onnx":
82
- p.diffuser = OnnxStableDiffusionInpaintPipeline
83
- else:
84
- p.diffuser = StableDiffusionInpaintPipeline
85
- p.mask = load_image(p.mask)
86
-
87
- if p.token is None:
88
- with open("token.txt") as f:
89
- p.token = f.read().replace("\n", "")
90
-
91
- if p.seed == 0:
92
- p.seed = torch.random.seed()
93
-
94
- if p.revision == "onnx":
95
- p.seed = p.seed >> 32 if p.seed > 2**32 - 1 else p.seed
96
- p.generator = np.random.RandomState(p.seed)
97
- else:
98
- p.generator = torch.Generator(device=p.device).manual_seed(p.seed)
99
-
100
- print("load pipeline start:", iso_date_time(), flush=True)
101
-
102
- with warnings.catch_warnings():
103
- warnings.filterwarnings("ignore", category=FutureWarning)
104
- pipeline = p.diffuser.from_pretrained(
105
- p.model,
106
- torch_dtype=p.dtype,
107
- revision=p.revision,
108
- use_auth_token=p.token,
109
- ).to(p.device)
110
-
111
- if p.scheduler is not None:
112
- scheduler = getattr(schedulers, p.scheduler)
113
- pipeline.scheduler = scheduler.from_config(pipeline.scheduler.config)
114
-
115
- if p.skip:
116
- pipeline.safety_checker = None
117
-
118
- if p.attention_slicing:
119
- pipeline.enable_attention_slicing()
120
-
121
- if p.xformers_memory_efficient_attention:
122
- pipeline.enable_xformers_memory_efficient_attention()
123
-
124
- if p.vae_tiling:
125
- pipeline.vae.enable_tiling()
126
-
127
- p.pipeline = pipeline
128
-
129
- print("loaded models after:", iso_date_time(), flush=True)
130
-
131
- return p
132
-
133
-
134
- def stable_diffusion_inference(p):
135
- prefix = p.prompt.replace(" ", "_")[:170]
136
- for j in range(p.iters):
137
- result = p.pipeline(**remove_unused_args(p))
138
-
139
- for i, img in enumerate(result.images):
140
- idx = j * p.samples + i + 1
141
- out = f"{prefix}__steps_{p.steps}__scale_{p.scale:.2f}__seed_{p.seed}__n_{idx}.png"
142
- img.save(os.path.join("output", out))
143
-
144
- print("completed pipeline:", iso_date_time(), flush=True)
145
-
146
-
147
- def main():
148
- parser = argparse.ArgumentParser(description="Create images from a text prompt.")
149
- parser.add_argument(
150
- "--attention-slicing",
151
- action="store_true",
152
- help="Use less memory at the expense of inference speed",
153
- )
154
- parser.add_argument(
155
- "--device",
156
- type=str,
157
- nargs="?",
158
- default="cuda",
159
- help="The cpu or cuda device to use to render images",
160
- )
161
- parser.add_argument(
162
- "--half",
163
- action="store_true",
164
- help="Use float16 (half-sized) tensors instead of float32",
165
- )
166
- parser.add_argument(
167
- "--height", type=int, nargs="?", default=512, help="Image height in pixels"
168
- )
169
- parser.add_argument(
170
- "--image",
171
- type=str,
172
- nargs="?",
173
- help="The input image to use for image-to-image diffusion",
174
- )
175
- parser.add_argument(
176
- "--image-scale",
177
- type=float,
178
- nargs="?",
179
- help="How closely the image should follow the original image",
180
- )
181
- parser.add_argument(
182
- "--iters",
183
- type=int,
184
- nargs="?",
185
- default=1,
186
- help="Number of times to run pipeline",
187
- )
188
- parser.add_argument(
189
- "--mask",
190
- type=str,
191
- nargs="?",
192
- help="The input mask to use for diffusion inpainting",
193
- )
194
- parser.add_argument(
195
- "--model",
196
- type=str,
197
- nargs="?",
198
- default="CompVis/stable-diffusion-v1-4",
199
- help="The model used to render images",
200
- )
201
- parser.add_argument(
202
- "--negative-prompt",
203
- type=str,
204
- nargs="?",
205
- help="The prompt to not render into an image",
206
- )
207
- parser.add_argument(
208
- "--onnx",
209
- action="store_true",
210
- help="Use the onnx runtime for inference",
211
- )
212
- parser.add_argument(
213
- "--prompt", type=str, nargs="?", help="The prompt to render into an image"
214
- )
215
- parser.add_argument(
216
- "--samples",
217
- type=int,
218
- nargs="?",
219
- default=1,
220
- help="Number of images to create per run",
221
- )
222
- parser.add_argument(
223
- "--scale",
224
- type=float,
225
- nargs="?",
226
- default=7.5,
227
- help="How closely the image should follow the prompt",
228
- )
229
- parser.add_argument(
230
- "--scheduler",
231
- type=str,
232
- nargs="?",
233
- help="Override the scheduler used to denoise the image",
234
- )
235
- parser.add_argument(
236
- "--seed", type=int, nargs="?", default=0, help="RNG seed for repeatability"
237
- )
238
- parser.add_argument(
239
- "--skip",
240
- action="store_true",
241
- help="Skip the safety checker",
242
- )
243
- parser.add_argument(
244
- "--steps", type=int, nargs="?", default=50, help="Number of sampling steps"
245
- )
246
- parser.add_argument(
247
- "--strength",
248
- type=float,
249
- default=0.75,
250
- help="Diffusion strength to apply to the input image",
251
- )
252
- parser.add_argument(
253
- "--token", type=str, nargs="?", help="Huggingface user access token"
254
- )
255
- parser.add_argument(
256
- "--vae-tiling",
257
- action="store_true",
258
- help="Use less memory when generating ultra-high resolution images",
259
- )
260
- parser.add_argument(
261
- "--width", type=int, nargs="?", default=512, help="Image width in pixels"
262
- )
263
- parser.add_argument(
264
- "--xformers-memory-efficient-attention",
265
- action="store_true",
266
- help="Use less memory but require the xformers library",
267
- )
268
- parser.add_argument(
269
- "prompt0",
270
- metavar="PROMPT",
271
- type=str,
272
- nargs="?",
273
- help="The prompt to render into an image",
274
- )
275
-
276
- args = parser.parse_args()
277
-
278
- if args.prompt0 is not None:
279
- args.prompt = args.prompt0
280
-
281
- pipeline = stable_diffusion_pipeline(args)
282
- stable_diffusion_inference(pipeline)
283
-
284
-
285
- if __name__ == "__main__":
286
- main()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
scripts/bootstrap.sh ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # This script will install git and conda (if not found on the PATH variable)
4
+ # using micromamba (an 8mb static-linked single-file binary, conda replacement).
5
+ # For users who already have git and conda, this step will be skipped.
6
+
7
+ # This enables a user to install this project without manually installing conda and git.
8
+
9
+ source ./scripts/functions.sh
10
+
11
+ set -o pipefail
12
+
13
+ OS_NAME=$(uname -s)
14
+ case "${OS_NAME}" in
15
+ Linux*) OS_NAME="linux";;
16
+ Darwin*) OS_NAME="osx";;
17
+ *) echo "Unknown OS: $OS_NAME! This script runs only on Linux or Mac" && exit
18
+ esac
19
+
20
+ OS_ARCH=$(uname -m)
21
+ case "${OS_ARCH}" in
22
+ x86_64*) OS_ARCH="64";;
23
+ arm64*) OS_ARCH="arm64";;
24
+ aarch64*) OS_ARCH="arm64";;
25
+ *) echo "Unknown system architecture: $OS_ARCH! This script runs only on x86_64 or arm64" && exit
26
+ esac
27
+
28
+ if ! which curl; then fail "'curl' not found. Please install curl."; fi
29
+ if ! which tar; then fail "'tar' not found. Please install tar."; fi
30
+ if ! which bzip2; then fail "'bzip2' not found. Please install bzip2."; fi
31
+
32
+ if pwd | grep ' '; then fail "The installation directory's path contains a space character. Conda will fail to install. Please change the directory."; fi
33
+
34
+ # https://mamba.readthedocs.io/en/latest/installation.html
35
+ if [ "$OS_NAME" == "linux" ] && [ "$OS_ARCH" == "arm64" ]; then OS_ARCH="aarch64"; fi
36
+
37
+ # config
38
+ export MAMBA_ROOT_PREFIX="$(pwd)/installer_files/mamba"
39
+ INSTALL_ENV_DIR="$(pwd)/installer_files/env"
40
+ LEGACY_INSTALL_ENV_DIR="$(pwd)/installer"
41
+ MICROMAMBA_DOWNLOAD_URL="https://micro.mamba.pm/api/micromamba/${OS_NAME}-${OS_ARCH}/latest"
42
+ umamba_exists="F"
43
+
44
+ # figure out whether git and conda needs to be installed
45
+ if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi
46
+
47
+ PACKAGES_TO_INSTALL=""
48
+
49
+ if [ ! -e "$LEGACY_INSTALL_ENV_DIR/etc/profile.d/conda.sh" ] && [ ! -e "$INSTALL_ENV_DIR/etc/profile.d/conda.sh" ]; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL conda python=3.8.5"; fi
50
+ if ! hash "git" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL git"; fi
51
+
52
+ if "$MAMBA_ROOT_PREFIX/micromamba" --version &>/dev/null; then umamba_exists="T"; fi
53
+
54
+ # (if necessary) install git and conda into a contained environment
55
+ if [ "$PACKAGES_TO_INSTALL" != "" ]; then
56
+ # download micromamba
57
+ if [ "$umamba_exists" == "F" ]; then
58
+ echo "Downloading micromamba from $MICROMAMBA_DOWNLOAD_URL to $MAMBA_ROOT_PREFIX/micromamba"
59
+
60
+ mkdir -p "$MAMBA_ROOT_PREFIX"
61
+ curl -L "$MICROMAMBA_DOWNLOAD_URL" | tar -xvj -O bin/micromamba > "$MAMBA_ROOT_PREFIX/micromamba"
62
+
63
+ if [ "$?" != "0" ]; then
64
+ echo
65
+ echo "EE micromamba download failed"
66
+ echo "EE If the lines above contain 'bzip2: Cannot exec', your system doesn't have bzip2 installed"
67
+ echo "EE If there are network errors, please check your internet setup"
68
+ fail "micromamba download failed"
69
+ fi
70
+
71
+ chmod u+x "$MAMBA_ROOT_PREFIX/micromamba"
72
+
73
+ # test the mamba binary
74
+ echo "Micromamba version:"
75
+ "$MAMBA_ROOT_PREFIX/micromamba" --version
76
+ fi
77
+
78
+ # create the installer env
79
+ if [ ! -e "$INSTALL_ENV_DIR" ]; then
80
+ "$MAMBA_ROOT_PREFIX/micromamba" create -y --prefix "$INSTALL_ENV_DIR" || fail "unable to create the install environment"
81
+ fi
82
+
83
+ if [ ! -e "$INSTALL_ENV_DIR" ]; then
84
+ fail "There was a problem while installing$PACKAGES_TO_INSTALL using micromamba. Cannot continue."
85
+ fi
86
+
87
+ echo "Packages to install:$PACKAGES_TO_INSTALL"
88
+
89
+ "$MAMBA_ROOT_PREFIX/micromamba" install -y --prefix "$INSTALL_ENV_DIR" -c conda-forge $PACKAGES_TO_INSTALL
90
+ if [ "$?" != "0" ]; then
91
+ fail "Installation of the packages '$PACKAGES_TO_INSTALL' failed."
92
+ fi
93
+ fi
scripts/functions.sh ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # utility functions for all scripts
3
+ #
4
+
5
+ fail() {
6
+ echo
7
+ echo "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
8
+ echo
9
+ if [ "$1" != "" ]; then
10
+ echo ERROR: $1
11
+ else
12
+ echo An error occurred.
13
+ fi
14
+ cat <<EOF
15
+
16
+ Error downloading Stable Diffusion UI. Sorry about that, please try to:
17
+ 1. Run this installer again.
18
+ 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting
19
+ 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB
20
+ 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues
21
+
22
+ Thanks!
23
+
24
+
25
+ EOF
26
+ read -p "Press any key to continue"
27
+ exit 1
28
+
29
+ }
30
+
31
+ filesize() {
32
+ case "$(uname -s)" in
33
+ Linux*) stat -c "%s" $1;;
34
+ Darwin*) stat -f "%z" $1;;
35
+ *) echo "Unknown OS: $OS_NAME! This script runs only on Linux or Mac" && exit
36
+ esac
37
+ }
38
+
39
+
scripts/install_status.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
scripts/on_env_start.sh ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ source ./scripts/functions.sh
4
+
5
+ printf "\n\nEasy Diffusion\n\n"
6
+
7
+ if [ -f "scripts/config.sh" ]; then
8
+ source scripts/config.sh
9
+ fi
10
+
11
+ if [ "$update_branch" == "" ]; then
12
+ export update_branch="main"
13
+ fi
14
+
15
+ if [ -f "scripts/install_status.txt" ] && [ `grep -c sd_ui_git_cloned scripts/install_status.txt` -gt "0" ]; then
16
+ echo "Easy Diffusion's git repository was already installed. Updating from $update_branch.."
17
+
18
+ cd sd-ui-files
19
+
20
+ git reset --hard
21
+ git -c advice.detachedHead=false checkout "$update_branch"
22
+ git pull
23
+
24
+ cd ..
25
+ else
26
+ printf "\n\nDownloading Easy Diffusion..\n\n"
27
+ printf "Using the $update_branch channel\n\n"
28
+
29
+ if git clone -b "$update_branch" https://github.com/cmdr2/stable-diffusion-ui.git sd-ui-files ; then
30
+ echo sd_ui_git_cloned >> scripts/install_status.txt
31
+ else
32
+ fail "git clone failed"
33
+ fi
34
+ fi
35
+
36
+ rm -rf ui
37
+ cp -Rf sd-ui-files/ui .
38
+ cp sd-ui-files/scripts/on_sd_start.sh scripts/
39
+ cp sd-ui-files/scripts/bootstrap.sh scripts/
40
+ cp sd-ui-files/scripts/check_modules.py scripts/
41
+ cp sd-ui-files/scripts/start.sh .
42
+ cp sd-ui-files/scripts/developer_console.sh .
43
+ cp sd-ui-files/scripts/functions.sh scripts/
44
+
45
+ exec ./scripts/on_sd_start.sh
start.sh ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ cd "$(dirname "${BASH_SOURCE[0]}")"
4
+
5
+ if [ -f "on_sd_start.bat" ]; then
6
+ echo ================================================================================
7
+ echo
8
+ echo !!!! WARNING !!!!
9
+ echo
10
+ echo It looks like you\'re trying to run the installation script from a source code
11
+ echo download. This will not work.
12
+ echo
13
+ echo Recommended: Please close this window and download the installer from
14
+ echo https://stable-diffusion-ui.github.io/docs/installation/
15
+ echo
16
+ echo ================================================================================
17
+ echo
18
+ read
19
+ exit 1
20
+ fi
21
+
22
+
23
+ # set legacy installer's PATH, if it exists
24
+ if [ -e "installer" ]; then export PATH="$(pwd)/installer/bin:$PATH"; fi
25
+
26
+ # Setup the packages required for the installer
27
+ scripts/bootstrap.sh || exit 1
28
+
29
+ # set new installer's PATH, if it downloaded any packages
30
+ if [ -e "installer_files/env" ]; then export PATH="$(pwd)/installer_files/env/bin:$PATH"; fi
31
+
32
+ # Test the bootstrap
33
+ which git
34
+ git --version || exit 1
35
+
36
+ which conda
37
+ conda --version || exit 1
38
+
39
+ # Download the rest of the installer and UI
40
+ chmod +x scripts/*.sh
41
+ scripts/on_env_start.sh