-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.sh
executable file
·302 lines (244 loc) · 9.03 KB
/
install.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
#!/bin/bash
# AGPL-3.0 License
# Author of this script:
# github.com/D4n13lk300
# t.me/D4n13lk300
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
WHITE='\033[1;37m'
BG_RED='\033[41m'
NC='\033[0m'
if [ ! -t 0 ]
then echo -e "${WHITE}${BG_RED}Please run this script directly${NC}"
exit
fi
if [ "$EUID" -ne 0 ]
then echo -e "${WHITE}${BG_RED}Please run as root${NC}"
exit
fi
if [ "$(lsb_release -rs)" != "22.04" ]
then echo -e "${WHITE}${BG_RED}This script only works on Ubuntu 22.04${NC}"
exit
fi
echo -e "${YELLOW}Updating system${NC}"
apt update -y
if [ "$1" == "-u" ]
then
echo -e "${YELLOW}Upgrading system${NC}"
DEBIAN_FRONTEND=noninteractive apt upgrade -y
else
echo -e "${YELLOW}Skipping system upgrade${NC}"
fi
echo -e "${CYAN}Installing main dependencies${NC}"
DEBIAN_FRONTEND=noninteractive apt install -y git curl wget aria2 p7zip-full \
neovim zsh tree \
p7zip-rar python3 \
python3-pip \
python3-setuptools \
python3-venv \
python3-numpy \
dialog \
linux-headers-$(uname -r)
echo -e "${YELLOW}Changing shell to zsh${NC}"
chsh -s $(which zsh)
if [ ! -f /usr/bin/nvidia-smi ]
then
echo -e "${GREEN}Downloading CUDA 12 keyring${NC}"
aria2c https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb -o cuda.deb
echo -e "${GREEN}Installing CUDA 12 keyring${NC}"
dpkg -i cuda.deb
echo -e "${GREEN}Adding CUDA 12 repository${NC}"
apt update
echo -e "${GREEN}Installing CUDA 12${NC}"
apt -y install cuda
rm cuda.deb
else
echo -e "${GREEN}Nvidia drivers detected, skipping CUDA installation${NC}"
fi
echo -e "${CYAN}Cloning repository${NC}"
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui sd
cd sd
echo -e "${CYAN}Downloading models${NC}"
CHOICES=(
"1" "Deliberate v5" on
"2" "Deliberate v5 Inpainting" on
"3" "Deliberate v5 (SFW)" off
"4" "Deliberate v5 (SFW) Inpainting" off
"5" "Reliberate v3" on
"6" "Reliberate v3 Inpainting" on
"7" "Reliberate v2" off
"8" "Reliberate v2 Inpainting" off
"9" "Anime v2" on
"10" "Anime v2 Inpainting" on
"11" "Anything V5" off
)
makechoice() {
CHOICE=$(dialog --clear --title "Choose models to download" --checklist " " 0 0 0 "${CHOICES[@]}" 2>&1 >/dev/tty)
ERRORCODE=$?
if [ $ERRORCODE -ne 0 ]; then
echo "Error: Dialog failed with exit code $ERRORCODE"
exit $ERRORCODE
fi
}
makechoice
cd models/Stable-diffusion
download_model() {
FILENAME="$1"
TITLE="Downloading $FILENAME"
URL="$2"
aria2c -o "$FILENAME" --enable-color=false -x4 "$URL" 2>&1 | \
dialog --title "$TITLE" --progressbox 40 100
}
if [[ $CHOICE == *"1"* ]]
then
download_model "Deliberate v5.safetensors" "https://huggingface.co/XpucT/Deliberate/resolve/main/Deliberate_v5.safetensors"
fi
if [[ $CHOICE == *"2"* ]]
then
download_model "Deliberate v5 Inpainting.safetensors" "https://huggingface.co/XpucT/Deliberate/resolve/main/Deliberate_v5-inpainting.safetensors"
fi
if [[ $CHOICE == *"3"* ]]
then
download_model "Deliberate v5 (SFW).safetensors" "https://huggingface.co/XpucT/Deliberate/resolve/main/Deliberate_v5 (SFW).safetensors"
fi
if [[ $CHOICE == *"4"* ]]
then
download_model "Deliberate v5 (SFW) Inpainting.safetensors" "https://huggingface.co/XpucT/Deliberate/resolve/main/Deliberate_v5 (SFW)-inpainting.safetensors"
fi
if [[ $CHOICE == *"5"* ]]
then
download_model "Reliberate v3.safetensors" "https://huggingface.co/XpucT/Reliberate/resolve/main/Reliberate_v3.safetensors"
fi
if [[ $CHOICE == *"6"* ]]
then
download_model "Reliberate v3 Inpainting.safetensors" "https://huggingface.co/XpucT/Reliberate/resolve/main/Reliberate_v3-inpainting.safetensors"
fi
if [[ $CHOICE == *"7"* ]]
then
download_model "Reliberate v2.safetensors" "https://huggingface.co/XpucT/Reliberate/resolve/main/Reliberate_v2.safetensors"
fi
if [[ $CHOICE == *"8"* ]]
then
download_model "Reliberate v2 Inpainting.safetensors" "https://huggingface.co/XpucT/Reliberate/resolve/main/Reliberate_v3-inpainting.safetensors"
fi
if [[ $CHOICE == *"9"* ]]
then
download_model "Anime v2.safetensors" "https://huggingface.co/XpucT/Anime/resolve/main/Anime_v2.safetensors"
fi
if [[ $CHOICE == *"10"* ]]
then
download_model "Anime v2 Inpainting.safetensors" "https://huggingface.co/XpucT/Anime/resolve/main/Anime_v2-inpainting.safetensors"
fi
if [[ $CHOICE == *"11"* ]]
then
download_model "Anything V5.safetensors" "https://civitai.com/api/download/models/90854"
fi
cd ../..
clear
LORAS_LIST=(
"1" "LowRA by XpucT" off
"2" "Lit by XpucT" off
)
CHOICE=$(dialog --clear --title "Choose LoRAs to install" --checklist " " 0 0 0 "${LORAS_LIST[@]}" 2>&1 >/dev/tty)
for option in $CHOICE; do
case $option in
1)
lora_name="LowRA"
lora_url="https://civitai.com/api/download/models/63006"
;;
2)
lora_name="Lit"
lora_url="https://civitai.com/api/download/models/55665"
;;
*)
continue
;;
esac
mkdir -p models/Lora
cd models/Lora
FILENAME="$lora_name.safetensors"
TITLE="Downloading $FILENAME"
aria2c -o "$FILENAME" --enable-color=false -x4 "$lora_url" 2>&1 | dialog --title "$TITLE" --progressbox 40 100
cd ../..
done
clear
EXTENSIONS_LIST=(
"1" "Aspect ratio selector" true
"2" "Canvas Zoom" true
"3" "ControlNet (Depth, Inpaint, LineArt, Canny)" false
)
CHOICE=$(dialog --clear --title "Choose extensions to install" --checklist " " 0 0 0 "${EXTENSIONS_LIST[@]}" 2>&1 >/dev/tty)
ERRORCODE=$?
if [ $ERRORCODE -ne 0 ]; then
echo "Error: Dialog failed with exit code $ERRORCODE"
exit $ERRORCODE
fi
if [[ $CHOICE == *"1"* ]]
then
echo -e "${YELLOW} Installing Aspect Ratio selector"
cd /root/sd/extensions
git clone https://github.com/alemelis/sd-webui-ar
cd /root/sd/
fi
if [[ $CHOICE == *"2"* ]]
then
echo -e "${YELLOW} Installing Canvas Zoom"
cd /root/sd/extensions
git clone https://github.com/richrobber2/canvas-zoom
cd /root/sd/
fi
if [[ $CHOICE == *"3"* ]]
then
echo -e "${YELLOW}Installing ControlNet"
mkdir -p /root/sd/models/ControlNet
cd /root/sd/models/ControlNet
download_model() {
model_name=$1
model_url=$2
config_name=$3
config_url=$4
aria2c -o "$model_name" --enable-color=false -x4 "$model_url" 2>&1 | \
dialog --title "Downloading $model_name" --progressbox 40 100
aria2c -o "$config_name" --enable-color=false -x4 "$config_url" 2>&1 | \
dialog --title "Downloading $config_name" --progressbox 40 100
}
download_model "control_v11f1p_sd15_depth.pth" "https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11f1p_sd15_depth.pth" \
"control_v11f1p_sd15_depth.yaml" "https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11f1p_sd15_depth.yaml"
download_model "control_v11p_sd15_inpaint.pth" "https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_inpaint.pth" \
"control_v11p_sd15_inpaint.yaml" "https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_inpaint.yaml"
download_model "control_v11p_sd15_lineart.pth" "https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_lineart.pth" \
"control_v11p_sd15_lineart.yaml" "https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_lineart.yaml"
download_model "control_v11p_sd15_canny.pth" "https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny.pth" \
"control_v11p_sd15_canny.yaml" "https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny.yaml"
cd /root/sd/
clear
cd extensions
git clone https://github.com/Mikubill/sd-webui-controlnet
cd /root/sd/
fi
clear
mkdir -p /root/sd/models/ESRGAN
cd /root/sd/models/ESRGAN
files=(
"4x_NMKD-Siax_200k.pth|https://huggingface.co/uwg/upscaler/resolve/main/ESRGAN/4x_NMKD-Siax_200k.pth"
"4x-UltraSharp.pth|https://huggingface.co/uwg/upscaler/resolve/main/ESRGAN/4x-UltraSharp.pth"
"WaifuGAN_v3_30000.pth|https://huggingface.co/uwg/upscaler/resolve/main/ESRGAN/WaifuGAN_v3_30000.pth"
"4x_RealisticRescaler_100000_G.pth|https://huggingface.co/uwg/upscaler/resolve/main/ESRGAN/4x_RealisticRescaler_100000_G.pth"
)
for file in "${files[@]}"; do
IFS='|' read -r -a parts <<< "$file"
filename="${parts[0]}"
url="${parts[1]}"
aria2c -x4 -o "$filename" "$url" 2>&1 | dialog --title "Downloading $filename" --progressbox 40 100
done
cd /root/sd
echo -e "${CYAN}Allowing running from root${NC}"
sed -i 's/can_run_as_root=0/can_run_as_root=1/' /root/sd/webui.sh
echo -e "${GREEN}All done!${NC}"
echo -e "${GREEN}Use \`cd sd\` to enter into Stable-Diffusion folder"
echo -e "${GREEN}Run ${CYAN}./webui.sh --listen --xformers${GREEN} to start the webui${NC}"
IP=$(curl -sL ident.me)
echo -e "${CYAN}On first run it will be download some requirements. This may take a while"
echo -e "${GREEN}The address will be http://${IP}:7860/${NC}"