File size: 4,538 Bytes
4bb4722
c1fa9ff
edff4dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
070e744
edff4dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/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}