File size: 6,379 Bytes
ee02a02
 
 
6097267
ee02a02
6097267
 
 
ee02a02
6097267
 
ee02a02
 
6097267
 
ee02a02
 
 
6097267
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ee02a02
 
 
 
 
 
 
6097267
 
 
ee02a02
 
6097267
ee02a02
 
 
6097267
 
 
 
 
 
 
ee02a02
 
6097267
ee02a02
 
6097267
ee02a02
6097267
ee02a02
 
 
6097267
 
 
 
 
 
 
ee02a02
 
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
#@title 1. Installation
webui_version = "camenduru's fork (stable)" #@param ["camenduru's fork (stable)", "original automatic1111 repo (latest feature, might be buggy)"]
import shutil
import os
import requests
import subprocess
cek = subprocess.getoutput('nvidia-smi')
if not 'T4' in cek:
  print("-----Your colab session is over. Use other google account or wait 12-24 hours-----")
  print("-----Sesi colab elu udah habis bro. Saran gw tunggu 12-24 jam atau bikin/pake akun google lain-----")
  raise KeyboardInterrupt
from google.colab.output import eval_js
os.environ['colab_url'] = eval_js("google.colab.kernel.proxyPort(7860, {'cache': false})")


print('Installing dependencies...')
print('(This process will only happen once per session)')
print('')
%cd /content
#!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
if not os.path.isfile('dependencies'):
    !gdown http://launchpadlibrarian.net/367274644/libgoogle-perftools-dev_2.5-2.2ubuntu3_amd64.deb
    !gdown https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/google-perftools_2.5-2.2ubuntu3_all.deb
    !gdown https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libtcmalloc-minimal4_2.5-2.2ubuntu3_amd64.deb
    !gdown https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libgoogle-perftools4_2.5-2.2ubuntu3_amd64.deb
    !apt install -qq libunwind8-dev
    !dpkg -i *.deb
    %env LD_PRELOAD=libtcmalloc.so
    !rm *.deb
    # print("Grabbing pre-built xformers from camenduru's repo")
    # url = 'https://api.github.com/repos/camenduru/stable-diffusion-webui-colab/releases/latest'
    # response = requests.get(url)
    # print("Status code: " + str(response.status_code))
    # if response.status_code == 200:
    #     data = response.json()
    #     templink = [link for link in [asset['browser_download_url'] for asset in data['assets'] if 'cp39' in asset['name']]]
    #     xformerlink = templink[0]
    # else:
    #     print("Request failed, loading last updated xformers instead")
    #     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'
    # !pip install -q --pre xformers
    !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
    !pip install -q xformers==0.0.16 triton==2.0.0 -U
    # !pip install -q --pre xformers==0.0.17.dev476 -U
    # !pip install -q --pre triton
    !touch dependencies

print('Installing webui...')
print('')
if webui_version=="camenduru's fork (stable)":
  !if ! [ -f forkedwebui ]; then echo "cloning from camenduru's fork"; rm -rf stable-diffusion-webui; git clone -b v2.1 https://github.com/camenduru/stable-diffusion-webui; 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; sed -i -e 's/fastapi==0.90.1/fastapi==0.89.1/g' /content/stable-diffusion-webui/requirements_versions.txt; touch forkedwebui; fi
else:
  !if [ -f forkedwebui ]; then rm forkedwebui; mv '/content/stable-diffusion-webui/models/Stable-diffusion' '/content/temp'; rm -rf stable-diffusion-webui; fi
  !if ! [ -d stable-diffusion-webui ]; then echo "cloning from official repo"; git clone https://github.com/automatic1111/stable-diffusion-webui; cp -rf '/content/temp'/* '/content/stable-diffusion-webui/models/Stable-diffusion'; rm -rf '/content/temp'; fi
%cd stable-diffusion-webui

#webui setup for nai
print('Setting UI configs...')
print('')
%cd /content/stable-diffusion-webui
!if [ -f configinstanlite ]; then rm configinstanlite && rm /content/stable-diffusion-webui/modules/ui.py && mv /content/stable-diffusion-webui/modules/ui_backup.py /content/stable-diffusion-webui/modules/ui.py; fi
!if ! [ -f configinstan ]; then gdown https://pastebin.com/raw/gMTvTUUZ -O /content/stable-diffusion-webui/ui-config.json && gdown https://pastebin.com/raw/VviKmfiQ -O /content/stable-diffusion-webui/config.json; fi
!touch configinstan

#notification bell
!gdown https://github.com/etherealxx/etherportal-webui-colab/raw/master/notification.mp3 -O /content/stable-diffusion-webui/notification.mp3

#foolhardy remacri
! [ ! -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

#temporaryfix

#extensions
print('Installing extensions...')
print('')
%cd /content/stable-diffusion-webui/extensions
!bash -c 'for repo in camenduru/stable-diffusion-webui-images-browser camenduru/sd-civitai-browser Extraltodeus/depthmap2mask kohya-ss/sd-webui-additional-networks etherealxx/batchlinks-webui; do if [ ! -d "$repo" ]; then git clone "https://github.com/$repo" && true; fi; done' #DominikDoom/a1111-sd-webui-tagcomplete
!git clone -b pre-embedding --single-branch https://github.com/etherealxx/Umi-AI
#%cd /content/stable-diffusion-webui/extensions/UnivAICharGen
#!if [ -f forkedwebui ]; then git checkout c56b5146049b91cfcd645c62bd356bd0631c4131 .; fi
# !git clone -b lora --single-branch https://github.com/etherealxx/sd-civitai-browser

#badprompt & badartist
%cd /content/stable-diffusion-webui/embeddings/
!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
!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
!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

print('Installation Success!')
print('')