Spaces:
Runtime error
Runtime error
Commit
·
6097267
1
Parent(s):
1df440e
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#@title - Instant (Simple)
|
2 |
+
import requests
|
3 |
+
import os
|
4 |
+
import subprocess
|
5 |
+
cek = subprocess.getoutput('nvidia-smi')
|
6 |
+
from google.colab.output import eval_js
|
7 |
+
os.environ['colab_url'] = eval_js("google.colab.kernel.proxyPort(7860, {'cache': false})")
|
8 |
+
|
9 |
+
if not 'T4' in cek:
|
10 |
+
print("[1;32m-----Your colab session is over. Use other google account or wait 12-24 hours-----")
|
11 |
+
print("-----Sesi colab elu udah habis bro. Saran gw tunggu 12-24 jam atau bikin/pake akun google lain-----")
|
12 |
+
raise KeyboardInterrupt
|
13 |
+
|
14 |
+
|
15 |
+
#thanks to https://github.com/camenduru for the fork
|
16 |
+
print('[1;32mInstalling dependencies...')
|
17 |
+
print('[1;32m(This process will only happen once per session)')
|
18 |
+
print('[0m')
|
19 |
+
%cd /content
|
20 |
+
#!if ! [ -f xformers ]; then pip install -q https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.16/xformers-0.0.16+814314d.d20230118-cp38-cp38-linux_x86_64.whl; pip install -q --pre triton; touch xformers; fi
|
21 |
+
if not os.path.isfile('dependencies'):
|
22 |
+
!gdown http://launchpadlibrarian.net/367274644/libgoogle-perftools-dev_2.5-2.2ubuntu3_amd64.deb
|
23 |
+
!gdown https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/google-perftools_2.5-2.2ubuntu3_all.deb
|
24 |
+
!gdown https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libtcmalloc-minimal4_2.5-2.2ubuntu3_amd64.deb
|
25 |
+
!gdown https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libgoogle-perftools4_2.5-2.2ubuntu3_amd64.deb
|
26 |
+
!apt install -qq libunwind8-dev
|
27 |
+
!dpkg -i *.deb
|
28 |
+
%env LD_PRELOAD=libtcmalloc.so
|
29 |
+
!rm *.deb
|
30 |
+
# print("Grabbing pre-built xformers from camenduru's repo")
|
31 |
+
# url = 'https://api.github.com/repos/camenduru/stable-diffusion-webui-colab/releases/latest'
|
32 |
+
# response = requests.get(url)
|
33 |
+
# print("Status code: " + str(response.status_code))
|
34 |
+
# if response.status_code == 200:
|
35 |
+
# data = response.json()
|
36 |
+
# templink = [link for link in [asset['browser_download_url'] for asset in data['assets'] if 'cp39' in asset['name']]]
|
37 |
+
# xformerlink = templink[0]
|
38 |
+
# else:
|
39 |
+
# print("Request failed, loading last updated xformers instead")
|
40 |
+
# xformerlink = 'https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.17/xformers-0.0.17+b6be33a.d20230315-cp39-cp39-linux_x86_64.whl'
|
41 |
+
# !pip install -q --pre xformers
|
42 |
+
!pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1 torchtext==0.14.1 torchdata==0.5.1 --extra-index-url https://download.pytorch.org/whl/cu116 -U
|
43 |
+
!pip install -q xformers==0.0.16 triton==2.0.0 -U
|
44 |
+
# !pip install -q --pre xformers==0.0.17.dev476 -U
|
45 |
+
# !pip install -q --pre triton
|
46 |
+
!touch dependencies
|
47 |
+
|
48 |
+
print('[1;32mInstalling webui...')
|
49 |
+
print('[0m')
|
50 |
+
!if ! [ -d stable-diffusion-webui ]; then git clone -b v2.1 https://github.com/camenduru/stable-diffusion-webui; touch forkedwebui; fi
|
51 |
+
%cd stable-diffusion-webui
|
52 |
+
|
53 |
+
#AnythingV3 Model & Vae
|
54 |
+
print('[1;32mDownloading AnythingV3 model...')
|
55 |
+
print('[0m')
|
56 |
+
%cd /content/stable-diffusion-webui/models/Stable-diffusion/
|
57 |
+
!if ! [ -f Anything-V3.0.safetensors ]; then gdown https://huggingface.co/Linaqruf/anything-v3.0/resolve/main/anything-v3-fp32-pruned.safetensors -O /content/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0.safetensors; fi
|
58 |
+
!if ! [ -f Anything-V3.0.vae.pt ]; then gdown https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/VAEs/orangemix.vae.pt -O /content/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0.vae.pt; fi
|
59 |
+
|
60 |
+
#webui setup for nai
|
61 |
+
print('[1;32mSetting UI configs...')
|
62 |
+
print('[0m')
|
63 |
+
%cd /content/stable-diffusion-webui
|
64 |
+
!if [ -f configinstan ]; then rm configinstan; fi
|
65 |
+
!if ! [ -f configinstanlite ]; then gdown https://pastebin.com/raw/fmN0i5Sd -O /content/stable-diffusion-webui/ui-config.json && gdown https://pastebin.com/raw/amVtB1NW -O /content/stable-diffusion-webui/config.json; fi
|
66 |
+
!if ! [ -f configinstanlite ]; then mv /content/stable-diffusion-webui/modules/ui.py /content/stable-diffusion-webui/modules/ui_backup.py && gdown https://pastebin.com/raw/pKFWUfLM -O /content/stable-diffusion-webui/modules/ui.py; fi
|
67 |
+
!touch configinstanlite
|
68 |
+
|
69 |
+
#notification bell
|
70 |
+
!gdown https://github.com/etherealxx/etherportal-webui-colab/raw/master/notification.mp3 -O /content/stable-diffusion-webui/notification.mp3
|
71 |
+
|
72 |
+
#foolhardy remacri
|
73 |
+
! [ ! -d models/ESRGAN ] && mkdir -p models/ESRGAN; [ ! -f models/ESRGAN/4x_foolhardy_Remacri.pth ] && gdown https://huggingface.co/etherealxx/whoseisthis/resolve/main/4x_foolhardy_Remacri.pth -O /content/stable-diffusion-webui/models/ESRGAN/4x_foolhardy_Remacri.pth
|
74 |
+
|
75 |
+
#extensions
|
76 |
+
print('[1;32mInstalling extensions...')
|
77 |
+
print('[0m')
|
78 |
+
%cd /content/stable-diffusion-webui/extensions
|
79 |
+
!bash -c 'for repo in camenduru/stable-diffusion-webui-images-browser Extraltodeus/depthmap2mask ddPn08/kohya-sd-scripts-webui arenatemp/stable-diffusion-webui-model-toolkit; do if [ ! -d "
|
80 |
+
repo" && true; fi; done' #DominikDoom/a1111-sd-webui-tagcomplete
|
81 |
+
!bash -c 'for repo in sd-civitai-browser kohya-sd-scripts-webui stable-diffusion-webui-model-toolkit batchlinks-webui; do if [ -d "
|
82 |
+
repo && true; fi; done'
|
83 |
+
#%cd /content/stable-diffusion-webui/extensions/UnivAICharGen
|
84 |
+
#!git checkout c56b5146049b91cfcd645c62bd356bd0631c4131 .
|
85 |
+
!git clone -b pre-embedding --single-branch https://github.com/etherealxx/Umi-AI
|
86 |
+
|
87 |
+
#badprompt & badartist
|
88 |
+
%cd /content/stable-diffusion-webui/embeddings/
|
89 |
+
!if ! [ -f bad_prompt.pt ]; then gdown https://huggingface.co/datasets/Nerfgun3/bad_prompt/resolve/main/bad_prompt_version2.pt -O /content/stable-diffusion-webui/embeddings/bad_prompt.pt; fi
|
90 |
+
!if ! [ -f bad_artist.pt ]; then gdown https://huggingface.co/etherealxx/whoseisthis/resolve/main/bad_artist.pt -O /content/stable-diffusion-webui/embeddings/bad_artist.pt; fi
|
91 |
+
!if ! [ -f bad_hands.pt ]; then gdown https://huggingface.co/etherealxx/whoseisthis/resolve/main/bad-hands-5.pt -O /content/stable-diffusion-webui/embeddings/bad_hands.pt; fi
|
92 |
+
|
93 |
+
#some fix
|
94 |
+
!sed -i -e '''/ prepare_environment()/a\ os.system\(f\"""sed -i -e ''\"s/dict()))/dict())).cuda()/g\"'' /content/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/util.py""")''' /content/stable-diffusion-webui/launch.py
|
95 |
+
!sed -i -e 's/fastapi==0.90.1/fastapi==0.89.1/g' /content/stable-diffusion-webui/requirements_versions.txt
|
96 |
+
|
97 |
+
print('[1;32mInstallation Success!')
|
98 |
+
print('[1;32mLaunching the webui...')
|
99 |
+
print('[0m')
|
100 |
+
%cd /content/stable-diffusion-webui
|
101 |
+
!python launch.py --ckpt /content/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0.safetensors --vae-path /content/stable-diffusion-webui
|