|
#@title - Instant (Simple) |
|
import requests |
|
import os |
|
import subprocess |
|
cek = subprocess.getoutput('nvidia-smi') |
|
from google.colab.output import eval_js |
|
os.environ['colab_url'] = eval_js("google.colab.kernel.proxyPort(7860, {'cache': false})") |
|
|
|
if not 'T4' in cek: |
|
print("[1;32m-----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 |
|
|
|
|
|
#thanks to https://github.com/camenduru for the fork |
|
print('[1;32mInstalling dependencies...') |
|
print('[1;32m(This process will only happen once per session)') |
|
print('[0m') |
|
%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('[1;32mInstalling webui...') |
|
print('[0m') |
|
!if ! [ -d stable-diffusion-webui ]; then git clone -b v2.1 https://github.com/camenduru/stable-diffusion-webui; touch forkedwebui; fi |
|
%cd stable-diffusion-webui |
|
|
|
#AnythingV3 Model & Vae |
|
print('[1;32mDownloading AnythingV3 model...') |
|
print('[0m') |
|
%cd /content/stable-diffusion-webui/models/Stable-diffusion/ |
|
!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 |
|
!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 |
|
|
|
#webui setup for nai |
|
print('[1;32mSetting UI configs...') |
|
print('[0m') |
|
%cd /content/stable-diffusion-webui |
|
!if [ -f configinstan ]; then rm configinstan; fi |
|
!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 |
|
!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 |
|
!touch configinstanlite |
|
|
|
#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 |
|
|
|
#extensions |
|
print('[1;32mInstalling extensions...') |
|
print('[0m') |
|
%cd /content/stable-diffusion-webui/extensions |
|
!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 "repo" && true; fi; done' #DominikDoom/a1111-sd-webui-tagcomplete |
|
!bash -c 'for repo in sd-civitai-browser kohya-sd-scripts-webui stable-diffusion-webui-model-toolkit batchlinks-webui; do if [ -d " |
|
repo && true; fi; done' |
|
#%cd /content/stable-diffusion-webui/extensions/UnivAICharGen |
|
#!git checkout c56b5146049b91cfcd645c62bd356bd0631c4131 . |
|
!git clone -b pre-embedding --single-branch https://github.com/etherealxx/Umi-AI |
|
|
|
#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 |
|
|
|
#some fix |
|
!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 |
|
|
|
print('[1;32mInstallation Success!') |
|
print('[1;32mLaunching the webui...') |
|
print('[0m') |
|
%cd /content/stable-diffusion-webui |
|
!python launch.py --ckpt /content/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0.safetensors --vae-path /content/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0.vae.pt --share --xformers --enable-insecure-extension-access --gradio-queue |
|
|
|
|
|
#@title - Instant (Advanced) |
|
import requests |
|
import os |
|
import subprocess |
|
cek = subprocess.getoutput('nvidia-smi') |
|
if not 'T4' in cek: |
|
print("[1;32m-----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})") |
|
|
|
#thanks to https://github.com/camenduru for the fork |
|
print('[1;32mInstalling dependencies...') |
|
print('[1;32m(This process will only happen once per session)') |
|
print('[0m') |
|
%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('[1;32mInstalling webui...') |
|
print('[0m') |
|
!if ! [ -d stable-diffusion-webui ]; then git clone -b v2.1 https://github.com/camenduru/stable-diffusion-webui; touch forkedwebui; fi |
|
%cd stable-diffusion-webui |
|
|
|
#AnythingV3 Model & Vae |
|
print('[1;32mDownloading AnythingV3 model...') |
|
print('[0m') |
|
%cd /content/stable-diffusion-webui/models/Stable-diffusion/ |
|
!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 |
|
!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 |
|
|
|
#webui setup for nai |
|
print('[1;32mSetting UI configs...') |
|
print('[0m') |
|
%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 |
|
|
|
#extensions |
|
print('[1;32mInstalling extensions...') |
|
print('[0m') |
|
%cd /content/stable-diffusion-webui/extensions |
|
!bash -c 'for repo in camenduru/stable-diffusion-webui-images-browser camenduru/sd-civitai-browser Extraltodeus/depthmap2mask ddPn08/kohya-sd-scripts-webui arenatemp/stable-diffusion-webui-model-toolkit etherealxx/batchlinks-webui; do if [ ! -d " |
|
repo" && true; fi; done' #DominikDoom/a1111-sd-webui-tagcomplete |
|
# !git clone -b lora --single-branch https://github.com/etherealxx/sd-civitai-browser |
|
!git clone -b pre-embedding --single-branch https://github.com/etherealxx/Umi-AI |
|
#%cd /content/stable-diffusion-webui/extensions/UnivAICharGen |
|
#!git checkout c56b5146049b91cfcd645c62bd356bd0631c4131 . |
|
|
|
#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 |
|
|
|
#some fix |
|
!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 |
|
|
|
print('[1;32mInstallation Success!') |
|
print('[1;32mLaunching the webui...') |
|
print('[0m') |
|
%cd /content/stable-diffusion-webui |
|
!python launch.py --ckpt /content/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0.safetensors --vae-path /content/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0.vae.pt --share --xformers --enable-insecure-extension-access --gradio-queue |
|
|
|
|
|
#@title (for mobile/android user, run this first before Instant/Manual) |
|
|
|
%%html |
|
Press play on the music player to keep the tab alive (Uses only 13MB of data) |
|
|
|
Untuk pengguna mobile, tekan play di musik di bawah |
|
Fungsinya agar bisa make Colabnya lebih lama (make kuota 13MB) |
|
- Manual (Open Dropdown👇) |
|
|
|
Run the 1. installation cell |
|
Choose your desired model, then run the 2. Download Model cell (you can repeat this step to download several model before you launch the webui) |
|
Open the dropdown of 3. Run (Choose one👇), then choose one of the two available methods (doesn't matter which one) |
|
|
|
|
|
#@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("[1;32m-----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('[1;32mInstalling dependencies...') |
|
print('[1;32m(This process will only happen once per session)') |
|
print('[0m') |
|
%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('[1;32mInstalling webui...') |
|
print('[0m') |
|
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('[1;32mSetting UI configs...') |
|
print('[0m') |
|
%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('[1;32mInstalling extensions...') |
|
print('[0m') |
|
%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" && 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('[1;32mInstallation Success!') |
|
print('[0m') |
|
|
|
|
|
#@title 2. Download Model |
|
Model_to_download="Anythingv3" #@param [ "Anythingv3", "WaifuDiffusion-Vae", "Eimis", "EvtV3", "ACertain", "ElysiumV3", "Wlop-any", "LeafMix", "Abyss7thLayer", "Healys", "LigneClaire", "KriboMix", "InizioSkinjob", "PantyStocking", "WaifuBodyBlenderMix", "StuffyMix", "AbyssOrangeMix2", "AbyssOrangeMix3", "8528", "AmbrosiaFusion", "AniMeth", "AnythingV4.0", "ArchonInstagram", "CounterveitV2.5", "CounterveitV2.2", "CounterveitV2.2", "HD-17", "HDDreamGape", "MomochaMix", "Mozarella", "PadoruDiffusion", "PastelMix", "Protothing", "Shirayuki", "NutMegMix", "KaniAnime", "EverythingMix", "BlossomExtract", "HentaiElysium", "BerryMix", "Systemy-CSR", "ElyOrangeMix", "AnyTwamMix", "DarkberryMix", "Grapefruit", "Mitsudoue"] |
|
#@markdown Confused on what model to choose? Look for examples and comparison [here](https://github.com/etherealxx/etherportal-webui-colab/blob/master/ModelComparison.md). |
|
#@markdown If the download speed is slow (Below 10MiB/s), press the stop button then re-run the cell) |
|
#@markdown If the model you wanted isn't listed, and you have the direct link, paste it to the form below. (Supported link: Huggingface, MEGA) |
|
optional_direct_link='' #@param {type:"string"} |
|
|
|
import os |
|
import urllib.request, subprocess, contextlib #these handle mega.nz |
|
from IPython.display import clear_output #this also handle mega.nz |
|
from IPython.utils import capture |
|
import requests |
|
from tqdm import tqdm |
|
|
|
folder = '/content/stable-diffusion-webui/models/Stable-diffusion/' |
|
|
|
def checkdownloaded(pathx): |
|
if os.path.exists(pathx) or (os.path.exists(os.path.join(folder, 'Anything-V3.0.safetensors')) and Model_to_download=="Anythingv3"): |
|
|
|
if pathx.endswith("tmp"): |
|
os.remove(pathx) |
|
else: |
|
print(f'[1;32mThat model is already downloaded.') |
|
print('[0m') |
|
return 2 |
|
|
|
#civitstuff |
|
checkerpath = os.path.join(folder, 'civitmodel.txt') |
|
alreadythere = False |
|
|
|
def checkearlycivit(): |
|
alreadythere = False |
|
lines = [] |
|
if not os.path.exists(checkerpath): |
|
!touch {checkerpath} |
|
#check for unavailable model first |
|
if os.stat(checkerpath).st_size != 0: |
|
with open(checkerpath, "r") as file: |
|
for line in file: |
|
key, value = line.strip().split(" = ") |
|
modelfile = os.path.join(folder, value) |
|
if os.path.exists(modelfile): |
|
lines.append(line) |
|
if key == Model_to_download: |
|
alreadythere = True |
|
else: |
|
print(f"Seems like {key} model is not found on the model folder.") |
|
print() |
|
|
|
with open(checkerpath, "w") as file: |
|
file.writelines(lines) |
|
|
|
if alreadythere == True: return 2 |
|
|
|
def civitgetpath(modelname): |
|
with open(checkerpath, "r") as file: |
|
for line in file: |
|
key, value = line.strip().split(" = ") |
|
if key == modelname: |
|
return os.path.join(folder, value) |
|
|
|
def civitwrite(modelname): |
|
towrite = f"{Model_to_download} = {modelname}" |
|
with open(checkerpath, "a") as file: |
|
file.write(towrite + "\n") |
|
#civitstuffend |
|
|
|
def download_hf(link): |
|
filename = link.rsplit('/', 1)[-1] |
|
if Model_to_download == 'WaifuDiffusion-Vae': |
|
filename = 'WD-vae.vae.pt' |
|
elif Model_to_download == 'Anythingv3': |
|
filename = 'Anything-V3.0.safetensors' |
|
|
|
hfpath = os.path.join(folder, filename) |
|
check = checkdownloaded(hfpath) |
|
if check == 2: |
|
if Model_to_download=='Anythingv3' and not os.path.exists(os.path.join(folder, 'Anything-V3.0.vae.pt')): |
|
!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 |
|
return |
|
|
|
print(f'\033[1;32mDownloading {Model_to_download} Model...\033[0m') |
|
!gdown {link} -O /content/stable-diffusion-webui/models/Stable-diffusion/{filename} |
|
if Model_to_download=='Anythingv3': |
|
!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 |
|
print(f'\033[1;32mModel Downloaded.\033[0m') |
|
|
|
def download_civit(url): |
|
print(f'\033[1;32mDownloading {Model_to_download} Model...\033[0m') |
|
|
|
head_response = requests.head(url) |
|
total = int(head_response.headers.get('Content-Length', 0)) |
|
civitcheck = checkearlycivit() |
|
if civitcheck == 2: #model exist |
|
civitpath = civitgetpath(Model_to_download) |
|
downloaded_size = os.path.getsize(civitpath) |
|
if total != 0 and downloaded_size != total: |
|
os.remove(civitpath) |
|
checkearlycivit() |
|
print(f'Removed incomplete download: {Model_to_download}') |
|
else: |
|
print(f'[1;32mThat model is already downloaded.') |
|
print('[0m') |
|
return |
|
|
|
downloaded_size = 0 |
|
|
|
if not civitcheck == 2: |
|
pathtemp = os.path.join(folder, Model_to_download + ".bdgh") |
|
print(f'The model "{Model_to_download}" will be renamed correctly after downloading') |
|
with open(pathtemp, 'wb') as file, tqdm( |
|
desc=pathtemp, |
|
total=total, |
|
unit='iB', |
|
unit_scale=True, |
|
unit_divisor=1024, |
|
initial=downloaded_size, |
|
) as bar: |
|
resp = requests.get(url, stream=True) |
|
|
|
for data in resp.iter_content(chunk_size=1024): |
|
size = file.write(data) |
|
bar.update(size) |
|
# Check if the file has been downloaded successfully |
|
downloaded_size = os.path.getsize(pathtemp) |
|
if (total != 0 and downloaded_size != total) or (downloaded_size < 1000): |
|
# Remove the file if it has not been downloaded successfully |
|
os.remove(pathtemp) |
|
print() |
|
if downloaded_size < 1000: |
|
print(f'The model "{Model_to_download}" is probably had the link changed. Contact the owner of this repo.') |
|
else: |
|
print(f'Removed incomplete download: {Model_to_download}') |
|
return |
|
actualfilename = resp.headers['Content-Disposition'].split("filename=")[1].strip('"') |
|
#%cd {folder} |
|
os.rename(pathtemp, os.path.join(folder, actualfilename)) |
|
print (f'Model "{Model_to_download}.bdgh" renamed to "{actualfilename}"') |
|
civitwrite(actualfilename) |
|
print(f'\033[1;32mModel Downloaded.\033[0m') |
|
|
|
|
|
print('[1;32mInstalling webui...') |
|
with capture.capture_output() as cap: |
|
%cd /content |
|
!if ! [ -d stable-diffusion-webui ]; then git clone -b v1.6 https://github.com/camenduru/stable-diffusion-webui; touch forkedwebui; fi |
|
print('[0m') |
|
!if [ -f {folder}'Put Stable Diffusion checkpoints here.txt' ]; then rm {folder}'Put Stable Diffusion checkpoints here.txt'; fi |
|
|
|
%cd {folder} |
|
#sfw |
|
if Model_to_download=='Anythingv3': |
|
download_hf('https://huggingface.co/Linaqruf/anything-v3.0/resolve/main/anything-v3-fp32-pruned.safetensors') |
|
if Model_to_download=='WaifuDiffusion-Vae': |
|
download_hf('https://huggingface.co/hakurei/waifu-diffusion-v1-4/resolve/main/vae/kl-f8-anime2.ckpt') |
|
if Model_to_download=='Eimis': |
|
download_hf('https://huggingface.co/eimiss/EimisAnimeDiffusion_1.0v/resolve/main/EimisAnimeDiffusion_1-0v.ckpt') |
|
if Model_to_download=='EvtV3': |
|
download_hf('https://huggingface.co/haor/Evt_V3/resolve/main/Evt_V3_ema.ckpt') |
|
if Model_to_download=='ACertain': |
|
download_hf('https://huggingface.co/JosephusCheung/ACertainModel/resolve/main/ACertainModel.ckpt') |
|
if Model_to_download=='ElysiumV3': |
|
download_hf('https://huggingface.co/hesw23168/SD-Elysium-Model/resolve/main/Elysium_Anime_V3.safetensors') |
|
if Model_to_download=='Wlop-any': |
|
download_hf('https://huggingface.co/SirVeggie/wlop/resolve/main/wlop-any.ckpt') |
|
if Model_to_download=='LeafMix': |
|
download_hf('https://huggingface.co/etherealxx/anyleaf-temp/resolve/main/Leaf-pruned.safetensors') |
|
if Model_to_download=='Abyss7thLayer': |
|
download_hf('https://huggingface.co/syaimu/7th_Layer/resolve/main/7th_layer/Abyss_7th_layer.ckpt') |
|
if Model_to_download=='Healys': |
|
download_civit('https://civitai.com/api/download/models/1498') |
|
if Model_to_download=='LigneClaire': |
|
download_hf('https://huggingface.co/breakcore2/ligne_claire_anime_diffusion/resolve/main/ligne_claire_anime_diffusion_v1.safetensors') |
|
if Model_to_download=='KriboMix': |
|
download_civit('https://civitai.com/api/download/models/1289') |
|
if Model_to_download=='InizioSkinjob': |
|
download_hf('https://huggingface.co/Cinnamomo/inizio/resolve/main/safetensor/inizio_skinjob.safetensors') |
|
if Model_to_download=='PantyStocking': |
|
download_civit('https://civitai.com/api/download/models/1560') |
|
if Model_to_download=='WaifuBodyBlenderMix': |
|
download_civit('https://civitai.com/api/download/models/1838') |
|
if Model_to_download=='StuffyMix': |
|
download_civit('https://civitai.com/api/download/models/3376') |
|
if Model_to_download=='AbyssOrangeMix2': |
|
download_hf('https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/AbyssOrangeMix2/AbyssOrangeMix2_hard.safetensors') |
|
if Model_to_download=='AbyssOrangeMix3': |
|
download_hf('https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/AbyssOrangeMix3/AOM3 |
|
.safetensors') |
|
if Model_to_download=='8528': |
|
download_hf('https://huggingface.co/ckpt/8528-diffusion/resolve/main/8528d-final.ckpt') |
|
if Model_to_download=='AmbrosiaFusion': |
|
download_hf('https://huggingface.co/NiteStormz/ProtoThing_200/resolve/main/AmbrosiaFusion.ckpt') |
|
if Model_to_download=='AniMeth': |
|
download_hf('https://huggingface.co/Rasgeath/self_made_sauce/resolve/main/AniMeth.safetensors') |
|
if Model_to_download=='AnythingV4.0': |
|
download_hf('https://huggingface.co/andite/anything-v4.0/resolve/main/anything-v4.0-pruned.safetensors') |
|
if Model_to_download=='ArchonInstagram': |
|
download_hf('https://huggingface.co/misobarisic/playground/resolve/main/ArchonInstagram-fp16.ckpt') |
|
if Model_to_download=='CounterveitV2.5': |
|
download_hf('https://huggingface.co/gsdf/Counterfeit-V2.5/resolve/main/Counterfeit-V2.5_pruned.safetensors') |
|
if Model_to_download=='CounterveitV2.2': |
|
download_hf('https://huggingface.co/gsdf/Counterfeit-V2.5/resolve/main/Counterfeit-V2.2.safetensors') |
|
if Model_to_download=='CounterveitV2.2': |
|
download_hf('https://huggingface.co/gsdf/Counterfeit-V2.5/resolve/main/Counterfeit-V2.2.safetensors') |
|
if Model_to_download=='HD-17': |
|
download_hf('https://huggingface.co/Deltaadams/HentaiDiffusion/resolve/main/HD-17.ckpt') |
|
if Model_to_download=='HDDreamGape': |
|
download_hf('https://huggingface.co/Horsebird/HDDream-G/resolve/main/HDDream-Gape.safetensors') |
|
if Model_to_download=='MomochaMix': |
|
download_hf('https://huggingface.co/NoCrypt/momocha-mix/resolve/main/momocha-6E7-0.315-AD-E7-0.15-WS.ckpt') |
|
if Model_to_download=='Mozarella': |
|
download_hf('https://huggingface.co/Rasgeath/self_made_sauce/resolve/main/Mozzarella-pruned.safetensors') |
|
if Model_to_download=='PadoruDiffusion': |
|
download_hf('https://huggingface.co/misobarisic/playground/resolve/main/padoruDiffusion_1.ckpt') |
|
if Model_to_download=='PastelMix': |
|
download_hf('https://huggingface.co/andite/pastel-mix/resolve/main/pastelmix-fp32.safetensors') |
|
if Model_to_download=='Protothing': |
|
download_hf('https://huggingface.co/NiteStormz/ProtoThing_200/resolve/main/ProtoThing_200.ckpt') |
|
if Model_to_download=='Shirayuki': |
|
download_hf('https://huggingface.co/hesw23168/SD_Shirayuki_Model/resolve/main/Shirayuki_Anime_V1-fp16.safetensors') |
|
if Model_to_download=='NutMegMix': |
|
download_hf('https://huggingface.co/acheong08/nutmegmix/resolve/main/nutmegmix.safetensors') |
|
if Model_to_download=='KaniAnime': |
|
download_hf('https://huggingface.co/Rasgeath/self_made_sauce/resolve/main/Kani-anime-pruned.ckpt') |
|
if Model_to_download=='EverythingMix': |
|
download_hf('https://huggingface.co/DrBob2142/Everything/resolve/main/Everything%20V1B.safetensors') |
|
if Model_to_download=='BlossomExtract': |
|
download_hf('https://huggingface.co/NUROISEA/anything-mix/resolve/main/blossom-extract.safetensors') |
|
if Model_to_download=='HentaiElysium': |
|
download_hf('https://huggingface.co/NUROISEA/anything-mix/resolve/main/hentai-elysium-50.safetensors') |
|
|
|
#nsfw |
|
if Model_to_download=='BerryMix': |
|
download_hf('https://huggingface.co/misobarisic/berry-mix/resolve/main/berry_mix.ckpt') |
|
if Model_to_download=='Systemy-CSR': |
|
download_hf('https://huggingface.co/etherealxx/systemy-csrmodel-cutesexyrobutts/resolve/main/CSRmodel_1-CSRmodel_0-Weighted_sum-merged.ckpt') |
|
if Model_to_download=='ElyOrangeMix': |
|
download_hf('https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/ElyOrangeMix/ElyOrangeMix.ckpt') |
|
if Model_to_download=='AnyTwamMix': |
|
download_civit('https://civitai.com/api/download/models/4527') |
|
if Model_to_download=='DarkberryMix': |
|
download_civit('https://civitai.com/api/download/models/1992') |
|
if Model_to_download=='Grapefruit': |
|
download_civit('https://civitai.com/api/download/models/6360') |
|
if Model_to_download=='Mitsudoue': |
|
download_civit('https://civitai.com/api/download/models/1454') |
|
|
|
#these code below handle mega.nz |
|
def unbuffered(proc, stream='stdout'): |
|
stream = getattr(proc, stream) |
|
with contextlib.closing(stream): |
|
while True: |
|
out = [] |
|
last = stream.read(1) |
|
# Don't loop forever |
|
if last == '' and proc.poll() is not None: |
|
break |
|
while last not in newlines: |
|
# Don't loop forever |
|
if last == '' and proc.poll() is not None: |
|
break |
|
out.append(last) |
|
last = stream.read(1) |
|
out = ''.join(out) |
|
yield out |
|
|
|
def transfare(): |
|
import codecs |
|
decoder = codecs.getincrementaldecoder("UTF-8")() |
|
cmd = ["mega-get", optional_direct_link, folder] |
|
proc = subprocess.Popen( |
|
cmd, |
|
stdout=subprocess.PIPE, |
|
stderr=subprocess.STDOUT, |
|
universal_newlines=True, |
|
) |
|
for line in unbuffered(proc): |
|
if not line.startswith("Download"): |
|
print(f"\r{line}", end="") |
|
else: |
|
print(f"\n{line}") |
|
|
|
|
|
def installmega(): |
|
HOME = os.path.expanduser("~") |
|
if not os.path.exists(f"{HOME}/.ipython/ocr.py"): |
|
hCode = "https://raw.githubusercontent.com/biplobsd/" \ |
|
"OneClickRun/master/res/ocr.py" |
|
urllib.request.urlretrieve(hCode, f"{HOME}/.ipython/ocr.py") |
|
|
|
from ocr import ( |
|
runSh, |
|
loadingAn, |
|
) |
|
|
|
if not os.path.exists("/usr/bin/mega-cmd"): |
|
loadingAn() |
|
print("Installing MEGA ...") |
|
runSh('sudo apt-get -y update') |
|
runSh('sudo apt-get -y install libmms0 libc-ares2 libc6 libcrypto++6 libgcc1 libmediainfo0v5 libpcre3 libpcrecpp0v5 libssl1.1 libstdc++6 libzen0v5 zlib1g apt-transport-https') |
|
runSh('sudo curl -sL -o /var/cache/apt/archives/MEGAcmd.deb https://mega.nz/linux/MEGAsync/Debian_9.0/amd64/megacmd-Debian_9.0_amd64.deb', output=True) |
|
runSh('sudo dpkg -i /var/cache/apt/archives/MEGAcmd.deb', output=True) |
|
print("MEGA is installed.") |
|
clear_output() |
|
#these code above handle mega.nz |
|
|
|
if optional_direct_link!='': |
|
if optional_direct_link.startswith("https://huggingface.co/"): |
|
custom_download = os.path.basename(optional_direct_link) |
|
custom_path = os.path.join(folder,custom_download) |
|
if not os.path.isfile(custom_path): |
|
print(f'[1;32mDownloading {custom_download}') |
|
print('[0m') |
|
!gdown {optional_direct_link} -O {custom_path} |
|
else: |
|
print(f'[1;32mThat custom model is already downloaded.') |
|
print('[0m') |
|
elif optional_direct_link.startswith("https://mega.nz/"): |
|
print(f'[1;32mDownloading from a Mega link') |
|
print('[0m') |
|
installmega() |
|
newlines = ['\n', '\r\n', '\r'] |
|
transfare() |
|
|
|
files = os.listdir(folder) |
|
for file in files: |
|
if file.endswith('tmp') or file.endswith('bdgh'): |
|
file_path = os.path.join(folder, file) |
|
print(f"Removed incomplete download: {file_path}") |
|
os.remove(file_path) |
|
|
|
for root, dirs, files in os.walk(folder): |
|
for file in files: |
|
if file.endswith('.ckpt') or file.endswith('.safetensors'): |
|
checksizepath = os.path.join(root, file) |
|
MB = 1000000 # 1 megabyte = 1000000 bytes |
|
lorapath = '/content/stable-diffusion-webui/models/Lora' |
|
if os.path.getsize(checksizepath) < 200 * MB: |
|
if os.path.getsize(checksizepath) < MB: |
|
os.remove(checksizepath) |
|
print() |
|
print(f'The model {checksizepath} is probably had the link changed. Contact the owner of this repo.') |
|
else: |
|
if not os.path.exists(lorapath): |
|
os.makedirs(lorapath) |
|
os.rename(checksizepath, os.path.join(lorapath, file)) |
|
print() |
|
print(f'The model {checksizepath} is probably a Lora, so it is moved to lora folder') |
|
|
|
print() |
|
print('[1;32mList of installed models:') |
|
print('[0m') |
|
!ls *.{ckpt,safetensors,pt} {folder} 2>/dev/null |
|
|
|
3. Run (Choose one👇) |
|
|
|
#@title Run with Gradio |
|
#@markdown ![](https://raw.githubusercontent.com/etherealxx/etherportal-webui-colab/master/images/launchwebui2.jpg) |
|
|
|
import subprocess |
|
cek = subprocess.getoutput('nvidia-smi') |
|
if not 'T4' in cek: |
|
print("[1;32m-----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 |
|
|
|
|
|
%cd /content/stable-diffusion-webui/ |
|
!python launch.py --share --xformers --enable-insecure-extension-access --gradio-queue --no-half-vae |
|
|
|
|
|
#@title Run with Localtunnel |
|
#@markdown ![](https://raw.githubusercontent.com/etherealxx/etherportal-webui-colab/master/images/launchwebui3.jpg) |
|
|
|
import subprocess |
|
import time |
|
!npm install -g localtunnel |
|
|
|
cek = subprocess.getoutput('nvidia-smi') |
|
if not 'T4' in cek: |
|
print("[1;32m-----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 |
|
|
|
|
|
%cd /content/stable-diffusion-webui/ |
|
!nohup lt -p 7860 > lt.log 2>&1 & |
|
time.sleep(2) |
|
with open('/content/stable-diffusion-webui/lt.log', 'r') as testwritefile: |
|
print("\033[92m" + "Wait for the model to load and follow this link") |
|
print(testwritefile.read()) |
|
print("\033[95m") |
|
!python launch.py --xformers --enable-insecure-extension-access |
|
|
|
|