Upload forgeprov-vastai.sh
Browse files- forgeprov-vastai.sh +188 -0
forgeprov-vastai.sh
ADDED
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
source /venv/main/bin/activate
|
4 |
+
FORGE_DIR=${WORKSPACE}/stable-diffusion-webui-forge
|
5 |
+
|
6 |
+
# Packages are installed after nodes so we can fix them...
|
7 |
+
|
8 |
+
APT_PACKAGES=(
|
9 |
+
#"package-1"
|
10 |
+
#"package-2"
|
11 |
+
)
|
12 |
+
|
13 |
+
PIP_PACKAGES=(
|
14 |
+
|
15 |
+
)
|
16 |
+
|
17 |
+
CHECKPOINT_MODELS=(
|
18 |
+
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/aniversePonyXL_v60.safetensors"
|
19 |
+
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/autismmixSDXL_autismmixConfetti_256991.safetensors"
|
20 |
+
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/babes_12p5.safetensors"
|
21 |
+
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/beautifulGirls_v10.safetensors"
|
22 |
+
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/bemypony_Semirealanime.safetensors"
|
23 |
+
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/celestiquerealmixAtomix_v10.safetensors"
|
24 |
+
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/cyberrealisticPony_semiRealV36.safetensors"
|
25 |
+
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/incursiosMemeDiffusion_v27PDXL.safetensors"
|
26 |
+
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/magicalpony_3_628661.safetensors"
|
27 |
+
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/pimpmypony-v1-fp16-clip-fix.safetensors"
|
28 |
+
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/ponyDiffusionV6XL_v6StartWithThisOne_228616.safetensors"
|
29 |
+
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/ponyRealism_V23ULTRA.safetensors"
|
30 |
+
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/prefectPonyXL_v50.safetensors"
|
31 |
+
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/snowpony_v10.safetensors"
|
32 |
+
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/waiANINSFWPONYXL_v140.safetensors"
|
33 |
+
)
|
34 |
+
|
35 |
+
UNET_MODELS=(
|
36 |
+
|
37 |
+
)
|
38 |
+
|
39 |
+
LORA_MODELS=(
|
40 |
+
"https://huggingface.co/huchukato/favs/resolve/main/loras/nsfw/Expressive_H-000001.safetensors"
|
41 |
+
"https://huggingface.co/huchukato/favs/resolve/main/loras/nsfw/incase_style_v3-1_ponyxl_ilff_356767.safetensors"
|
42 |
+
"https://huggingface.co/huchukato/favs/resolve/main/loras/pony/S1_Dramatic_Lighting_v3_1184559.safetensors"
|
43 |
+
"https://huggingface.co/huchukato/favs/resolve/main/loras/pony/d3t41l3dXLP_404816.safetensors"
|
44 |
+
"https://huggingface.co/huchukato/favs/resolve/main/loras/pony/43stl1ght1ngXLP2_348038.safetensors"
|
45 |
+
"https://huggingface.co/huchukato/favs/resolve/main/loras/pony/V3n3t14nXLP2_404377.safetensors"
|
46 |
+
)
|
47 |
+
|
48 |
+
VAE_MODELS=(
|
49 |
+
#"https://huggingface.co/stabilityai/sd-vae-ft-ema-original/resolve/main/vae-ft-ema-560000-ema-pruned.safetensors"
|
50 |
+
"https://huggingface.co/huchukato/favs/resolve/main/VAE/ponyStandardVAE_v10.safetensors"
|
51 |
+
"https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors"
|
52 |
+
)
|
53 |
+
|
54 |
+
ESRGAN_MODELS=(
|
55 |
+
"https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x4.pth"
|
56 |
+
"https://huggingface.co/FacehugmanIII/4x_foolhardy_Remacri/resolve/main/4x_foolhardy_Remacri.pth"
|
57 |
+
"https://huggingface.co/Akumetsu971/SD_Anime_Futuristic_Armor/resolve/main/4x_NMKD-Siax_200k.pth"
|
58 |
+
)
|
59 |
+
|
60 |
+
CONTROLNET_MODELS=(
|
61 |
+
)
|
62 |
+
|
63 |
+
### DO NOT EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING ###
|
64 |
+
|
65 |
+
function provisioning_start() {
|
66 |
+
provisioning_print_header
|
67 |
+
provisioning_get_apt_packages
|
68 |
+
provisioning_get_extensions
|
69 |
+
provisioning_get_pip_packages
|
70 |
+
provisioning_get_files \
|
71 |
+
"${FORGE_DIR}/models/Stable-diffusion" \
|
72 |
+
"${CHECKPOINT_MODELS[@]}"
|
73 |
+
|
74 |
+
# Avoid git errors because we run as root but files are owned by 'user'
|
75 |
+
export GIT_CONFIG_GLOBAL=/tmp/temporary-git-config
|
76 |
+
git config --file $GIT_CONFIG_GLOBAL --add safe.directory '*'
|
77 |
+
|
78 |
+
# Start and exit because webui will probably require a restart
|
79 |
+
cd "${FORGE_DIR}"
|
80 |
+
LD_PRELOAD=libtcmalloc_minimal.so.4 \
|
81 |
+
python launch.py \
|
82 |
+
--skip-python-version-check \
|
83 |
+
--no-download-sd-model \
|
84 |
+
--do-not-download-clip \
|
85 |
+
--no-half \
|
86 |
+
--port 11404 \
|
87 |
+
--exit
|
88 |
+
|
89 |
+
provisioning_print_end
|
90 |
+
}
|
91 |
+
|
92 |
+
function provisioning_get_apt_packages() {
|
93 |
+
if [[ -n $APT_PACKAGES ]]; then
|
94 |
+
sudo $APT_INSTALL ${APT_PACKAGES[@]}
|
95 |
+
fi
|
96 |
+
}
|
97 |
+
|
98 |
+
function provisioning_get_pip_packages() {
|
99 |
+
if [[ -n $PIP_PACKAGES ]]; then
|
100 |
+
pip install --no-cache-dir ${PIP_PACKAGES[@]}
|
101 |
+
fi
|
102 |
+
}
|
103 |
+
|
104 |
+
function provisioning_get_extensions() {
|
105 |
+
for repo in "${EXTENSIONS[@]}"; do
|
106 |
+
dir="${repo##*/}"
|
107 |
+
path="${FORGE_DIR}/extensions/${dir}"
|
108 |
+
if [[ ! -d $path ]]; then
|
109 |
+
printf "Downloading extension: %s...\n" "${repo}"
|
110 |
+
git clone "${repo}" "${path}" --recursive
|
111 |
+
fi
|
112 |
+
done
|
113 |
+
}
|
114 |
+
|
115 |
+
function provisioning_get_files() {
|
116 |
+
if [[ -z $2 ]]; then return 1; fi
|
117 |
+
|
118 |
+
dir="$1"
|
119 |
+
mkdir -p "$dir"
|
120 |
+
shift
|
121 |
+
arr=("$@")
|
122 |
+
printf "Downloading %s model(s) to %s...\n" "${#arr[@]}" "$dir"
|
123 |
+
for url in "${arr[@]}"; do
|
124 |
+
printf "Downloading: %s\n" "${url}"
|
125 |
+
provisioning_download "${url}" "${dir}"
|
126 |
+
printf "\n"
|
127 |
+
done
|
128 |
+
}
|
129 |
+
|
130 |
+
function provisioning_print_header() {
|
131 |
+
printf "\n##############################################\n# #\n# Provisioning container #\n# #\n# This will take some time #\n# #\n# Your container will be ready on completion #\n# #\n##############################################\n\n"
|
132 |
+
}
|
133 |
+
|
134 |
+
function provisioning_print_end() {
|
135 |
+
printf "\nProvisioning complete: Application will start now\n\n"
|
136 |
+
}
|
137 |
+
|
138 |
+
function provisioning_has_valid_hf_token() {
|
139 |
+
[[ -n "$HF_TOKEN" ]] || return 1
|
140 |
+
url="https://huggingface.co/api/whoami-v2"
|
141 |
+
|
142 |
+
response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \
|
143 |
+
-H "Authorization: Bearer $HF_TOKEN" \
|
144 |
+
-H "Content-Type: application/json")
|
145 |
+
|
146 |
+
# Check if the token is valid
|
147 |
+
if [ "$response" -eq 200 ]; then
|
148 |
+
return 0
|
149 |
+
else
|
150 |
+
return 1
|
151 |
+
fi
|
152 |
+
}
|
153 |
+
|
154 |
+
function provisioning_has_valid_civitai_token() {
|
155 |
+
[[ -n "$CIVITAI_TOKEN" ]] || return 1
|
156 |
+
url="https://civitai.com/api/v1/models?hidden=1&limit=1"
|
157 |
+
|
158 |
+
response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \
|
159 |
+
-H "Authorization: Bearer $CIVITAI_TOKEN" \
|
160 |
+
-H "Content-Type: application/json")
|
161 |
+
|
162 |
+
# Check if the token is valid
|
163 |
+
if [ "$response" -eq 200 ]; then
|
164 |
+
return 0
|
165 |
+
else
|
166 |
+
return 1
|
167 |
+
fi
|
168 |
+
}
|
169 |
+
|
170 |
+
# Download from $1 URL to $2 file path
|
171 |
+
function provisioning_download() {
|
172 |
+
if [[ -n $HF_TOKEN && $1 =~ ^https://([a-zA-Z0-9_-]+\.)?huggingface\.co(/|$|\?) ]]; then
|
173 |
+
auth_token="$HF_TOKEN"
|
174 |
+
elif
|
175 |
+
[[ -n $CIVITAI_TOKEN && $1 =~ ^https://([a-zA-Z0-9_-]+\.)?civitai\.com(/|$|\?) ]]; then
|
176 |
+
auth_token="$CIVITAI_TOKEN"
|
177 |
+
fi
|
178 |
+
if [[ -n $auth_token ]];then
|
179 |
+
wget --header="Authorization: Bearer $auth_token" -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
|
180 |
+
else
|
181 |
+
wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
|
182 |
+
fi
|
183 |
+
}
|
184 |
+
|
185 |
+
# Allow user to disable provisioning if they started with a script they didn't want
|
186 |
+
if [[ ! -f /.noprovisioning ]]; then
|
187 |
+
provisioning_start
|
188 |
+
fi
|