Anthropohpobe commited on
Commit
f759e9b
1 Parent(s): b50e28e

Add application file

Browse files
Files changed (1) hide show
  1. app.py +71 -0
app.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from subprocess import getoutput
3
+
4
+ gpu_info = getoutput('nvidia-smi')
5
+ if("A10G" in gpu_info):
6
+ os.system(f"pip install -q https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.15/xformers-0.0.15.dev0+4c06c79.d20221205-cp38-cp38-linux_x86_64.whl")
7
+ elif("T4" in gpu_info):
8
+
9
+ os.system(f"apt-get install git-lfs")
10
+ os.system(f"pip install -q https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.15/xformers-0.0.15.dev0+1515f77.d20221130-cp38-cp38-linux_x86_64.whl")
11
+
12
+ os.system(f"git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git /home/user/app/stable-diffusion-webui")
13
+ #os.system(f"git clone https://github.com/camenduru/stable-diffusion-webui /home/user/app/stable-diffusion-webui")
14
+ os.chdir("/home/user/app/stable-diffusion-webui")
15
+
16
+ #os.system(f"wget -q https://github.com/camenduru/webui/raw/main/env_patch.py -O /home/user/app/env_patch.py")
17
+ #os.system(f"sed -i -e '/import image_from_url_text/r /home/user/app/env_patch.py' /home/user/app/stable-diffusion-webui/modules/ui.py")
18
+ #os.system(f"sed -i -e '/(modelmerger_interface, \"Checkpoint Merger\", \"modelmerger\"),/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
19
+ #os.system(f"sed -i -e '/(train_interface, \"Train\", \"ti\"),/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
20
+ #os.system(f"sed -i -e '/extensions_interface, \"Extensions\", \"extensions\"/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
21
+ #os.system(f"sed -i -e '/settings_interface, \"Settings\", \"settings\"/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
22
+ #os.system(f'''sed -i -e "s/document.getElementsByTagName('gradio-app')\[0\].shadowRoot/!!document.getElementsByTagName('gradio-app')[0].shadowRoot ? document.getElementsByTagName('gradio-app')[0].shadowRoot : document/g" /home/user/app/stable-diffusion-webui/script.js''')
23
+ #os.system(f"sed -i -e 's/ show_progress=False,/ show_progress=True,/g' /home/user/app/stable-diffusion-webui/modules/ui.py")
24
+ #os.system(f"sed -i -e 's/shared.demo.launch/shared.demo.queue().launch/g' /home/user/app/stable-diffusion-webui/webui.py")
25
+ #os.system(f"sed -i -e 's/ outputs=\[/queue=False, &/g' /home/user/app/stable-diffusion-webui/modules/ui.py")
26
+ #os.system(f"sed -i -e 's/ queue=False, / /g' /home/user/app/stable-diffusion-webui/modules/ui.py")
27
+
28
+ os.system("apt-get install libgoogle-perftools-dev -y")
29
+
30
+ if "IS_SHARED_UI" in os.environ:
31
+ os.system(f"rm -rfv /home/user/app/stable-diffusion-webui/scripts/")
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
+ os.system(f"wget -q {os.getenv('MODEL_LINK')} -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/{os.getenv('MODEL_NAME')}")
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
+ os.system(f"wget https://huggingface.co/Xenos14/Checkpoints/resolve/main/ui-config.json --content-disposition -O /home/user/app/stable-diffusion-webui/ui-config.json")
45
+ os.system(f"wget https://huggingface.co/Xenos14/Checkpoints/resolve/main/config.json --content-disposition -O /home/user/app/stable-diffusion-webui/config.json")
46
+
47
+ # 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")
48
+ os.system(f"git clone https://github.com/Mikubill/sd-webui-controlnet.git /home/user/app/stable-diffusion-webui/extensions/stable-diffusion-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 https://huggingface.co/monster-labs/control_v1p_sd15_qrcode_monster/blob/main/v2/control_v1p_sd15_qrcode_monster_v2.safetensors --content-disposition -O /home/user/app/stable-diffusion-webui/models/ControlNet/control_v1p_sd15_qrcode_monster")
52
+
53
+ #cards
54
+ os.system(f"mkdir /home/user/app/stable-diffusion-webui/extensions/sd-dynamic-prompts/wildcards/")
55
+ os.system(f"git clone https://huggingface.co/Xenos14/wildcards /home/user/app/stable-diffusion-webui/extensions/sd-dynamic-prompts/wildcards/Xenos")
56
+ os.system(f"rm -r -f /home/user/app/stable-diffusion-webui/extensions/sd-dynamic-prompts/wildcards/Xenos/.git")
57
+ os.system(f"git clone https://github.com/vorstcavry/embeddings /home/user/app/stable-diffusion-webui/embeddings/negative")
58
+ os.system(f"rm -r -f /home/user/app/stable-diffusion-webui/embeddings/negative/.git")
59
+ os.system(f"git clone https://huggingface.co/Xenos14/embeddings /home/user/app/stable-diffusion-webui/embeddings/!Xenos")
60
+ os.system(f"rm -r -f /home/user/app/stable-diffusion-webui/embeddings/!Xenos/.git")
61
+
62
+ os.system(f"mkdir /home/user/app/stable-diffusion-webui/models/Lora/")
63
+ os.system(f"git clone https://huggingface.co/Xenos14/Loras /home/user/app/stable-diffusion-webui/models/Lora/Xenos")
64
+ os.system(f"rm -r -f /home/user/app/stable-diffusion-webui/models/Lora/Xenos/.git")
65
+
66
+
67
+ os.system(f"wget -q https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.ckpt -O /home/user/app/stable-diffusion-webui/models/VAE/vae-ft-mse-840000-ema-pruned.ckpt")
68
+ 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")
69
+
70
+ os.system(f"python launch.py --enable-console-prompts --cors-allow-origins huggingface.co,hf.space --no-progressbar-hiding --api --skip-torch-cuda-test --disable-safe-unpickle --skip-torch-cuda-test --no-half --listen --enable-insecure-extension-access")
71
+ #--ui-config-file /home/user/app/ui-config.json --ui-settings-file /home/user/app/config.json