forked from fboulnois/stable-diffusion-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·72 lines (63 loc) · 2 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh
set -eu
CWD=$(basename "$PWD")
set_gpu_arg() {
while [ "$#" -gt 0 ]; do
if [ "$1" = "--device" ] && [ "$2" = "cpu" ]; then
GPU_ARG=""
return
fi
shift
done
GPU_ARG="--gpus=all"
}
build() {
docker build . --tag "$CWD"
}
clean() {
docker system prune -f
}
dev() {
docker run --rm --gpus=all --entrypoint=sh \
-v huggingface:/home/huggingface/.cache/huggingface \
-v "$PWD"/input:/home/huggingface/input \
-v "$PWD"/output:/home/huggingface/output \
-it "$CWD"
}
run() {
set_gpu_arg "$@"
docker run --rm ${GPU_ARG} \
-v huggingface:/home/huggingface/.cache/huggingface \
-v "$PWD"/input:/home/huggingface/input \
-v "$PWD"/output:/home/huggingface/output \
"$CWD" "$@"
}
tests() {
TEST_IMAGE="An_impressionist_painting_of_a_parakeet_eating_spaghetti_in_the_desert_s1.png"
cp "img/${TEST_IMAGE}" "input/${TEST_IMAGE}"
run --skip --H 512 --W 640 "abstract art"
run --device cpu --image "${TEST_IMAGE}" --strength 0.6 "abstract art"
run --model "stabilityai/stable-diffusion-2" \
--skip --H 768 --W 768 "abstract art"
run --model "stabilityai/stable-diffusion-2-1" \
--skip --H 768 --W 768 "abstract art"
run --model "stabilityai/stable-diffusion-x4-upscaler" \
--image "${TEST_IMAGE}" --half --attention-slicing \
--xformers-memory-efficient-attention \
--prompt "An impressionist painting of a parakeet eating spaghetti in the desert"
run --model "runwayml/stable-diffusion-v1-5" \
--n_samples 2 --n_iter 2 --seed 42 \
--scheduler HeunDiscreteScheduler \
--scale 7.5 --ddim_steps 80 --attention-slicing \
--half --skip --negative-prompt "red roses" \
--prompt "bouquet of roses"
}
mkdir -p input output
case ${1:-build} in
build) build ;;
clean) clean ;;
dev) dev "$@" ;;
run) shift; run "$@" ;;
test) tests ;;
*) echo "$0: No command named '$1'" ;;
esac