Spaces:
Runtime error
Runtime error
Update app.py
#9
by
nroggendorff
- opened
app.py
CHANGED
@@ -1,72 +1,49 @@
|
|
1 |
import os
|
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 |
-
os.system(f"sed -i -e '/demo:/r /home/user/app/header_patch.py' /home/user/app/stable-diffusion-webui/modules/ui.py")
|
28 |
-
# ---------------------------------------------------------------------------------------------------------------------------------------------------
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
os.system(f"wget -q https://github.com/camenduru/webui/raw/main/shared-config.json -O /home/user/app/shared-config.json")
|
34 |
-
os.system(f"wget -q https://github.com/camenduru/webui/raw/main/shared-ui-config.json -O /home/user/app/shared-ui-config.json")
|
35 |
|
36 |
-
|
37 |
-
os.system(f"wget -q {os.getenv('VAE_LINK')} -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/{os.getenv('VAE_NAME')}")
|
38 |
-
os.system(f"wget -q {os.getenv('YAML_LINK')} -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/{os.getenv('YAML_NAME')}")
|
39 |
-
|
40 |
-
os.system(f"python launch.py --force-enable-xformers --disable-console-progressbars --enable-console-prompts --ui-config-file /home/user/app/shared-ui-config.json --ui-settings-file /home/user/app/shared-config.json --cors-allow-origins huggingface.co,hf.space --no-progressbar-hiding")
|
41 |
-
else:
|
42 |
-
# Please duplicate this space and delete # character in front of the custom script you want to use or add here more custom scripts with same structure os.system(f"wget -q https://CUSTOM_SCRIPT_URL -O /home/user/app/stable-diffusion-webui/scripts/CUSTOM_SCRIPT_NAME.py")
|
43 |
-
os.system(f"wget -q https://gist.github.com/camenduru/9ec5f8141db9902e375967e93250860f/raw/d0bcf01786f20107c329c03f8968584ee67be12a/run_n_times.py -O /home/user/app/stable-diffusion-webui/scripts/run_n_times.py")
|
44 |
-
|
45 |
-
# Please duplicate this space and delete # character in front of the extension you want to use or add here more extensions with same structure os.system(f"git clone https://EXTENSION_GIT_URL /home/user/app/stable-diffusion-webui/extensions/EXTENSION_NAME")
|
46 |
-
#os.system(f"git clone https://github.com/camenduru/stable-diffusion-webui-artists-to-study /home/user/app/stable-diffusion-webui/extensions/stable-diffusion-webui-artists-to-study")
|
47 |
-
os.system(f"git clone https://github.com/yfszzx/stable-diffusion-webui-images-browser /home/user/app/stable-diffusion-webui/extensions/stable-diffusion-webui-images-browser")
|
48 |
-
os.system(f"git clone https://github.com/deforum-art/deforum-for-automatic1111-webui /home/user/app/stable-diffusion-webui/extensions/deforum-for-automatic1111-webui")
|
49 |
-
|
50 |
-
# Please duplicate this space and delete # character in front of the model you want to use or add here more ckpts with same structure os.system(f"wget -q https://CKPT_URL -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/CKPT_NAME.ckpt")
|
51 |
-
#os.system(f"wget -q https://huggingface.co/nitrosocke/Arcane-Diffusion/resolve/main/arcane-diffusion-v3.ckpt -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/arcane-diffusion-v3.ckpt")
|
52 |
-
#os.system(f"wget -q https://huggingface.co/DGSpitzer/Cyberpunk-Anime-Diffusion/resolve/main/Cyberpunk-Anime-Diffusion.ckpt -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/Cyberpunk-Anime-Diffusion.ckpt")
|
53 |
-
#os.system(f"wget -q https://huggingface.co/prompthero/midjourney-v4-diffusion/resolve/main/mdjrny-v4.ckpt -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/mdjrny-v4.ckpt")
|
54 |
-
#os.system(f"wget -q https://huggingface.co/nitrosocke/mo-di-diffusion/resolve/main/moDi-v1-pruned.ckpt -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/moDi-v1-pruned.ckpt")
|
55 |
-
#os.system(f"wget -q https://huggingface.co/Fictiverse/Stable_Diffusion_PaperCut_Model/resolve/main/PaperCut_v1.ckpt -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/PaperCut_v1.ckpt")
|
56 |
-
#os.system(f"wget -q https://huggingface.co/lilpotat/sa/resolve/main/samdoesarts_style.ckpt -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/samdoesarts_style.ckpt")
|
57 |
-
#os.system(f"wget -q https://huggingface.co/hakurei/waifu-diffusion-v1-3/resolve/main/wd-v1-3-float32.ckpt -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/wd-v1-3-float32.ckpt")
|
58 |
-
#os.system(f"wget -q https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/sd-v1-4.ckpt")
|
59 |
-
#os.system(f"wget -q https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned-emaonly.ckpt")
|
60 |
-
#os.system(f"wget -q https://huggingface.co/runwayml/stable-diffusion-inpainting/resolve/main/sd-v1-5-inpainting.ckpt -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/sd-v1-5-inpainting.ckpt")
|
61 |
-
|
62 |
-
#os.system(f"wget -q https://huggingface.co/Linaqruf/anything-v3.0/resolve/main/Anything-V3.0-pruned.ckpt -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0-pruned.ckpt")
|
63 |
-
#os.system(f"wget -q https://huggingface.co/Linaqruf/anything-v3.0/resolve/main/Anything-V3.0.vae.pt -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0-pruned.vae.pt")
|
64 |
-
|
65 |
-
#os.system(f"wget -q https://huggingface.co/stabilityai/stable-diffusion-2/resolve/main/768-v-ema.ckpt -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/768-v-ema.ckpt")
|
66 |
-
#os.system(f"wget -q https://raw.githubusercontent.com/Stability-AI/stablediffusion/main/configs/stable-diffusion/v2-inference-v.yaml -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/768-v-ema.yaml")
|
67 |
-
os.system(f"wget -q https://r2.kamiya-b.me/dreambooth_lib/akakura-sn.ckpt -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/akakura-sn.ckpt")
|
68 |
-
#os.system(f"wget -q https://huggingface.co/stabilityai/stable-diffusion-2-1/resolve/main/v2-1_768-ema-pruned.ckpt -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/v2-1_768-ema-pruned.ckpt")
|
69 |
-
os.system(f"wget -q https://raw.githubusercontent.com/Stability-AI/stablediffusion/main/configs/stable-diffusion/v2-inference-v.yaml -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/v2-1_768-ema-pruned.yaml")
|
70 |
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
+
import requests as rq
|
3 |
+
from git import Repo as rp
|
4 |
+
import concurrent.futures as cf
|
5 |
+
from tqdm import tqdm
|
6 |
|
7 |
+
def download_file(url, save_directory, filename):
|
8 |
+
filepath = os.path.join(save_directory, filename)
|
9 |
+
response = rq.get(url, stream=True)
|
10 |
+
total_size = int(response.headers.get('content-length', 0))
|
11 |
+
block_size = 1024
|
12 |
+
progress_bar = tqdm(total=total_size, unit='B', unit_scale=True)
|
13 |
+
with open(filepath, "wb") as f:
|
14 |
+
for data in response.iter_content(block_size):
|
15 |
+
progress_bar.update(len(data))
|
16 |
+
f.write(data)
|
17 |
+
progress_bar.close()
|
18 |
|
19 |
+
def main():
|
20 |
+
urls = [
|
21 |
+
("https://civitai.com/api/download/models/118945?type=Model&format=SafeTensor&token=286ce3775c01e40a98315a0a7eb1142d", "/home/user/app/stable-diffusion-webui/models/Lora/", "epicrealismhelper.safetensors"),
|
22 |
+
("https://civitai.com/api/download/models/131991?type=Model&format=SafeTensor&token=286ce3775c01e40a98315a0a7eb1142d", "/home/user/app/stable-diffusion-webui/models/Lora/", "juggernauthelper.safetensors"),
|
23 |
+
]
|
24 |
+
|
25 |
+
small_files = [
|
26 |
+
("https://civitai.com/api/download/models/118945?type=Model&format=SafeTensor&token=286ce3775c01e40a98315a0a7eb1142d", "/home/user/app/stable-diffusion-webui/models/Lora/", "epicrealismhelper.safetensors"),
|
27 |
+
("https://civitai.com/api/download/models/131991?type=Model&format=SafeTensor&token=286ce3775c01e40a98315a0a7eb1142d", "/home/user/app/stable-diffusion-webui/models/Lora/", "juggernauthelper.safetensors"),
|
28 |
+
]
|
29 |
+
big_files = [
|
30 |
+
("https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0_0.9vae.safetensors?download=true", "/home/user/app/stable-diffusion-webui/models/Stable-diffusion/", "sdxl.safetensors"),
|
31 |
+
("https://civitai.com/api/download/models/348913?type=Model&format=SafeTensor&size=full&fp=fp16&token=286ce3775c01e40a98315a0a7eb1142d", "/home/user/app/stable-diffusion-webui/models/Stable-diffusion/", "juggernautxl.safetensors"),
|
32 |
+
("https://civitai.com/api/download/models/128592?type=Model&format=SafeTensor&size=full&fp=fp16&token=286ce3775c01e40a98315a0a7eb1142d", "/home/user/app/stable-diffusion-webui/models/Stable-diffusion/", "animeart.safetensors"),
|
33 |
+
("https://civitai.com/api/download/models/367058?token=286ce3775c01e40a98315a0a7eb1142d", "/home/user/app/stable-diffusion-webui/models/Stable-diffusion/", "epicrealismxl.safetensors"),
|
34 |
+
("https://huggingface.co/stabilityai/stable-video-diffusion-img2vid-xt-1-1/resolve/main/svd_xt_1_1.safetensors?download=true", "/home/user/app/stable-diffusion-webui/models/svd/", "svd.safetensors")
|
35 |
+
]
|
36 |
|
37 |
+
with cf.ThreadPoolExecutor(max_workers=2) as small_executor:
|
38 |
+
small_futures = [small_executor.submit(download_file, *url_info) for url_info in small_files]
|
|
|
|
|
39 |
|
40 |
+
with cf.ThreadPoolExecutor(max_workers=16) as big_executor:
|
41 |
+
big_futures = [big_executor.submit(download_file, *url_info) for url_info in big_files]
|
|
|
|
|
|
|
42 |
|
43 |
+
cf.wait(small_futures + big_futures)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
+
if __name__ == "__main__":
|
46 |
+
rp.clone_from("https://github.com/lllyasviel/stable-diffusion-webui-forge.git", "/home/user/app/stable-diffusion-webui")
|
47 |
+
os.makedirs("/home/user/app/stable-diffusion-webui/models/Lora", exist_ok=True)
|
48 |
+
main()
|
49 |
+
os.system(f"python /home/user/app/stable-diffusion-webui/launch.py --ui-config-file /home/user/app/ui-config.json --cors-allow-origins huggingface.co,hf.space --api --xformers --precision full --no-half --skip-torch-cuda-test")
|