sd / run.sh
dax-wrld's picture
Rename run.py to run.sh
4bb4722 verified
#!/usr/bin/env bash
# # # # 2. Установка Automatic1111 # # # #
from subprocess import getoutput
from IPython.display import clear_output
from IPython.utils import capture
from datetime import timedelta
import time
import os
import threading
import shutil
import filecmp
from itertools import chain
try:
start_colab
except:
start_colab = int(time.time())-5
clear_output()
if not os.path.exists("/kaggle/working/SDDW"):
start_install = int(time.time())
print("\n\033[34m ⌛ Загрузка сборки Automatic1111... Это займёт около 1 минуты...")
with capture.capture_output() as cap:
!apt-get update -y
!apt install liblz4-tool aria2 -y
!pip install flask
!pip install pyngrok
!npm install -g localtunnel
from flask import Flask
from pyngrok import ngrok, conf
!echo -e "https://huggingface.co/datasets/dax-wrld/sd/resolve/main/sddw1709.tar.lz4\n\tout=sddw1709.tar.lz4\n" | aria2c -i- -j16 -x16 -s16 -k 200M -c
!tar -xI lz4 -f sddw1709.tar.lz4 --directory=/kaggle/working/
!rm -rf /kaggle/working/sddw1709.tar.lz4
os.environ["SAFETENSORS_FAST_GPU"]='1'
%cd /kaggle/working/SDDW
!chmod +x webui.sh
if Путь_до_LoRA_моделей:
!cp -r {Путь_до_LoRA_моделей}/. /kaggle/working/SDDW/models/Lora
del cap
install_time = timedelta(seconds=time.time()-start_install)
print("\033[32m ✅ Загрузка Automatic1111 выполнена за","%02d:%02d ⚡" % ((install_time.seconds / 60) % 60, install_time.seconds % 60), flush=True)
!echo -n {start_colab} > /kaggle/working/SDDW/colabTimer.txt
else:
print("\n\033[32m ✅ Сборка Automatic1111 загружена.")
import subprocess
cmd = subprocess.Popen("lt --port 8000&", stdout=subprocess.PIPE, shell=True)
print(cmd.stdout.readline().decode("utf-8"))
!curl https://loca.lt/mytunnelpassword
# # # # 5. Запуск и перезапуск Automatic1111 # # # #
print('\033[34m ⌛ Поиск моделей и расширений...')
print("\r", end='')
print("\033[32m ✅ Найдено:")
file_exists = False
for exts in os.listdir(extensions_dir):
if not 'here.txt' in exts:
if file_exists == False:
print("\033[32m 📍 Расширения:")
file_exists = True
print("\t\033[0m- " + exts)
file_exists = False
for exts in os.listdir(models_dir):
if not 'here.txt' in exts:
if file_exists == False:
print("\033[32m 📍 Модели:")
file_exists = True
print("\t\033[0m- " + exts)
if Путь_до_моделей:
for exts in os.listdir(Путь_до_моделей):
if not 'here.txt' in exts:
print("\t\033[0m- " + exts)
file_exists = False
for exts in os.listdir(lora_dir):
if not 'here.txt' in exts:
if file_exists == False:
print("\033[32m 📍 LoRA:")
file_exists = True
print("\t\033[0m- " + exts)
file_exists = False
for exts in os.listdir(vae_dir):
if not 'here.txt' in exts:
if file_exists == False:
print("\033[32m 📍 VAE:")
file_exists = True
print("\t\033[0m- " + exts)
file_exists = False
for exts in os.listdir(hypern_dir):
if not 'here.txt' in exts:
if file_exists == False:
print("\033[32m 📍 HyperNetworks:")
file_exists = True
print("\t\033[0m- " + exts)
file_exists = False
for exts in os.listdir(control_dir):
if not 'here.txt' in exts:
if file_exists == False:
print("\033[32m 📍 ControlNet модели:")
file_exists = True
print("\t\033[0m- " + exts)
commandline_arguments = "--xformers --disable-safe-unpickle --no-hashing --enable-insecure-extension-access --listen --port 8000"
if Тема_интерфейса=="Светлая":
commandline_arguments += " --theme light"
elif Тема_интерфейса=="Тёмная":
commandline_arguments += " --theme dark"
if Путь_до_моделей:
commandline_arguments += f" --no-download-sd-model --ckpt-dir {Путь_до_моделей} --mo-show-dir-settings"
print("\n\n\n")
!pip install insightface==0.7.3
!pip install onnxruntime
!chmod +x webui.sh
!./webui.sh -f {commandline_arguments}