Upload 2 files
Browse files
ceo.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#@title 启用云盘部署的sd_webui
|
2 |
+
import sys
|
3 |
+
import os
|
4 |
+
import importlib.util
|
5 |
+
from IPython import get_ipython
|
6 |
+
from IPython.display import clear_output
|
7 |
+
from google.colab import drive
|
8 |
+
drive.mount('/content/drive')
|
9 |
+
import binascii
|
10 |
+
sdw = binascii.unhexlify("737461626c652d646966667573696f6e2d7765627569").decode('ascii')
|
11 |
+
w = binascii.unhexlify("7765627569").decode('ascii')
|
12 |
+
gwb = f'/content/drive/MyDrive/{sdw}'
|
13 |
+
|
14 |
+
get_ipython().run_line_magic('cd', '/content')
|
15 |
+
get_ipython().run_line_magic('env', 'TF_CPP_MIN_LOG_LEVEL=1')
|
16 |
+
|
17 |
+
#部署 env 环境变量
|
18 |
+
get_ipython().system(f'apt -y update -qq')
|
19 |
+
get_ipython().system(f'wget https://github.com/camenduru/gperftools/releases/download/v1.0/libtcmalloc_minimal.so.4 -O /content/libtcmalloc_minimal.so.4')
|
20 |
+
get_ipython().run_line_magic('env', 'LD_PRELOAD=/content/libtcmalloc_minimal.so.4')
|
21 |
+
|
22 |
+
#设置 python 环境
|
23 |
+
get_ipython().system(f'apt -y install -qq aria2 libcairo2-dev pkg-config python3-dev')
|
24 |
+
get_ipython().system(f'pip install -q torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2+cu118 torchtext==0.15.2 torchdata==0.6.1 --extra-index-url https://download.pytorch.org/whl/cu118 -U')
|
25 |
+
get_ipython().system(f'pip install -q xformers==0.0.20 triton==2.0.0 gradio_client==0.2.7 -U')
|
26 |
+
|
27 |
+
clear_output()
|
28 |
+
|
29 |
+
get_ipython().run_line_magic('cd', f'/content/drive/MyDrive/Gm')
|
30 |
+
get_ipython().system(f'python launch.py --share --listen --enable-insecure-extension-access --theme dark --gradio-queue --multiple --opt-sdp-attention --api')
|
main.py
ADDED
@@ -0,0 +1,312 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import binascii
|
3 |
+
|
4 |
+
# 自定义类型转换函数
|
5 |
+
def str_to_bool(value):
|
6 |
+
if value.lower() in ('yes', 'true', 't', 'y', '1'):
|
7 |
+
return True
|
8 |
+
elif value.lower() in ('no', 'false', 'f', 'n', '0'):
|
9 |
+
return False
|
10 |
+
else:
|
11 |
+
raise argparse.ArgumentTypeError('Invalid boolean value: {}'.format(value))
|
12 |
+
|
13 |
+
# 创建参数解析器
|
14 |
+
parser = argparse.ArgumentParser()
|
15 |
+
|
16 |
+
parser.add_argument('--UI', type=str)
|
17 |
+
parser.add_argument('--Version', type=str)
|
18 |
+
parser.add_argument('--ControlNet', type=str)
|
19 |
+
|
20 |
+
parser.add_argument('--Roop', type=str_to_bool)
|
21 |
+
parser.add_argument('--Drive_Map', type=str_to_bool)
|
22 |
+
parser.add_argument('--Key_words', type=str_to_bool)
|
23 |
+
parser.add_argument('--SadTalker', type=str_to_bool)
|
24 |
+
|
25 |
+
# 解析命令行参数
|
26 |
+
args = parser.parse_args()
|
27 |
+
|
28 |
+
UI = args.UI
|
29 |
+
Roop = args.Roop
|
30 |
+
Version = args.Version
|
31 |
+
ControlNet = args.ControlNet
|
32 |
+
Drive_Map = args.Drive_Map
|
33 |
+
Key_words = args.Key_words
|
34 |
+
SadTalker = args.SadTalker
|
35 |
+
|
36 |
+
################################################################################################################################################
|
37 |
+
|
38 |
+
import sys
|
39 |
+
import os
|
40 |
+
import base64
|
41 |
+
import importlib.util
|
42 |
+
from IPython import get_ipython
|
43 |
+
from IPython.display import clear_output
|
44 |
+
from google.colab import drive
|
45 |
+
import tensorflow as tf
|
46 |
+
|
47 |
+
# 检测是否为GPU运行
|
48 |
+
print("TensorFlow version:", tf.__version__)
|
49 |
+
if tf.test.gpu_device_name():
|
50 |
+
drive.mount('/content/drive')
|
51 |
+
else:
|
52 |
+
raise Exception("\n请在《代码执行程序》-《更改运行时类型》-设置为GPU~")
|
53 |
+
|
54 |
+
# w = base64.b64decode(("d2VidWk=").encode('ascii')).decode('ascii')
|
55 |
+
# sdw = base64.b64decode(("c3RhYmxlLWRpZmZ1c2lvbi13ZWJ1aQ==").encode('ascii')).decode('ascii')
|
56 |
+
sdw = binascii.unhexlify("737461626c652d646966667573696f6e2d7765627569").decode('ascii')
|
57 |
+
w = binascii.unhexlify("7765627569").decode('ascii')
|
58 |
+
wb = f'/content/{sdw}'
|
59 |
+
gwb = f'/content/drive/MyDrive/{sdw}'
|
60 |
+
|
61 |
+
get_ipython().run_line_magic('cd', '/content')
|
62 |
+
get_ipython().run_line_magic('env', 'TF_CPP_MIN_LOG_LEVEL=1')
|
63 |
+
|
64 |
+
# 云盘同步
|
65 |
+
def cloudDriveSync(cloudPath, localPath='', sync=False):
|
66 |
+
# 云盘没有目录
|
67 |
+
if not os.path.exists(cloudPath):
|
68 |
+
# 创建云盘目录
|
69 |
+
get_ipython().system(f'mkdir {cloudPath}')
|
70 |
+
|
71 |
+
# 是否要同步
|
72 |
+
if not sync:
|
73 |
+
return
|
74 |
+
|
75 |
+
# 删除本地目录
|
76 |
+
get_ipython().system(f'rm -rf {localPath}')
|
77 |
+
# 链接云盘目录
|
78 |
+
get_ipython().system(f'ln -s {cloudPath} {localPath}')
|
79 |
+
|
80 |
+
# 初始化云盘
|
81 |
+
def initCloudDrive():
|
82 |
+
cloudDriveSync(f'{gwb}')
|
83 |
+
cloudDriveSync(f'{gwb}/Config')
|
84 |
+
cloudDriveSync(f'{gwb}/models', f'{wb}/models/Stable-diffusion', Drive_Map)
|
85 |
+
cloudDriveSync(f'{gwb}/Lora', f'{wb}/models/Lora', Drive_Map)
|
86 |
+
# cloudDriveSync(f'{gwb}/LyCORIS', f'{wb}/models/LyCORIS', Drive_Map)
|
87 |
+
cloudDriveSync(f'{gwb}/VAE', f'{wb}/models/VAE', Drive_Map)
|
88 |
+
cloudDriveSync(f'{gwb}/outputs', f'{wb}/outputs', Drive_Map)
|
89 |
+
cloudDriveSync(f'{gwb}/embeddings', f'{wb}/embeddings/negative', Drive_Map)
|
90 |
+
|
91 |
+
# 云盘没有配置文件
|
92 |
+
if not os.path.exists(f'{gwb}/Config/config.json'):
|
93 |
+
get_ipython().system(f'wget -O {gwb}/Config/config.json "https://huggingface.co/gmk123/sd_config/raw/main/config.json"')
|
94 |
+
# clong git
|
95 |
+
def gitDownload(url, localPath):
|
96 |
+
if os.path.exists(localPath):
|
97 |
+
return
|
98 |
+
|
99 |
+
get_ipython().system(f'git clone {url} {localPath}')
|
100 |
+
|
101 |
+
|
102 |
+
# 安装附加功能
|
103 |
+
def installAdditional():
|
104 |
+
# 安装扩展
|
105 |
+
urls = [
|
106 |
+
f'https://github.com/camenduru/{sdw}-images-browser',
|
107 |
+
f'https://github.com/camenduru/{sdw}-huggingface',
|
108 |
+
f'https://github.com/camenduru/sd-civitai-browser',
|
109 |
+
f'https://github.com/kohya-ss/sd-{w}-additional-networks',
|
110 |
+
f'https://github.com/fkunn1326/openpose-editor',
|
111 |
+
f'https://github.com/jexom/sd-{w}-depth-lib',
|
112 |
+
f'https://github.com/hnmr293/posex',
|
113 |
+
f'https://github.com/nonnonstop/sd-{w}-3d-open-pose-editor',
|
114 |
+
f'https://github.com/camenduru/sd-{w}-tunnels',
|
115 |
+
f'https://github.com/etherealxx/batchlinks-{w}',
|
116 |
+
f'https://github.com/camenduru/{sdw}-catppuccin',
|
117 |
+
f'https://github.com/AUTOMATIC1111/{sdw}-rembg',
|
118 |
+
f'https://github.com/ashen-sensored/{sdw}-two-shot',
|
119 |
+
f'https://github.com/thomasasfk/sd-{w}-aspect-ratio-helper',
|
120 |
+
# f'https://github.com/tjm35/asymmetric-tiling-sd-{w}',
|
121 |
+
f'https://github.com/s9roll7/ebsynth_utility',
|
122 |
+
# f'https://github.com/hako-mikan/sd-{w}-lora-block-weight',
|
123 |
+
# f'https://github.com/hako-mikan/sd-{w}-supermerger',
|
124 |
+
f'https://github.com/a2569875/{sdw}-composable-lora',
|
125 |
+
# f'https://github.com/camenduru/a1111-sd-{w}-locon',
|
126 |
+
f'https://github.com/KohakuBlueleaf/a1111-sd-{w}-lycoris',
|
127 |
+
# f'https://github.com/deforum-art/deforum-for-automatic1111-{w}',
|
128 |
+
# f'https://github.com/camenduru/sd_{w}_stealth_pnginfo',
|
129 |
+
# f'https://github.com/Scholar01/sd-{w}-mov2mov',
|
130 |
+
]
|
131 |
+
for url in urls:
|
132 |
+
|
133 |
+
filename = url.split('/')[-1]
|
134 |
+
|
135 |
+
if 'github' in url:
|
136 |
+
get_ipython().system(f'git clone {url} {wb}/extensions/{filename}')
|
137 |
+
|
138 |
+
get_ipython().system(f'wget https://raw.githubusercontent.com/camenduru/{sdw}-scripts/main/run_n_times.py -O {wb}/scripts/run_n_times.py')
|
139 |
+
get_ipython().system(f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/embed/upscale/resolve/main/4x-UltraSharp.pth -d {wb}/models/ESRGAN -o 4x-UltraSharp.pth')
|
140 |
+
|
141 |
+
# 优化embeddings
|
142 |
+
gitDownload(f'https://huggingface.co/embed/negative',f'{wb}/embeddings/negative')
|
143 |
+
get_ipython().system(f'rm -rf {wb}/embeddings/negative/.git')
|
144 |
+
get_ipython().system(f'rm {wb}/embeddings/negative/.gitattributes')
|
145 |
+
|
146 |
+
gitDownload(f'https://huggingface.co/embed/lora',f'{wb}/models/Lora/positive')
|
147 |
+
get_ipython().system(f'rm -rf {wb}/models/Lora/positive/.git')
|
148 |
+
get_ipython().system(f'rm {wb}/models/Lora/positive/.gitattributes')
|
149 |
+
|
150 |
+
#中文插件
|
151 |
+
gitDownload(f'https://github.com/DominikDoom/a1111-sd-{w}-tagcomplete',f'{wb}/extensions/a1111-sd-{w}-tagcomplete')
|
152 |
+
get_ipython().system(f'rm -f {wb}/extensions/a1111-sd-{w}-tagcomplete/tags/danbooru.csv')
|
153 |
+
get_ipython().system(f'wget https://beehomefile.oss-cn-beijing.aliyuncs.com/20210114/danbooru.csv -O {wb}/extensions/a1111-sd-{w}-tagcomplete/tags/danbooru.csv')
|
154 |
+
gitDownload(f'https://github.com/toriato/{sdw}-wd14-tagger',f'{wb}/extensions/{sdw}-wd14-tagge')
|
155 |
+
get_ipython().system(f'rm -f {wb}/localizations')
|
156 |
+
gitDownload(f'https://github.com/dtlnor/{sdw}-localization-zh_CN',f'{wb}/extensions/{sdw}-localization-zh_CN')
|
157 |
+
#附加插件=脸部修复/颜色细化/ps扩展/漫画助手/分块vae
|
158 |
+
gitDownload(f'https://github.com/Bing-su/adetailer',f'{wb}/extensions/adetailer')
|
159 |
+
gitDownload(f'https://github.com/hnmr293/sd-{w}-cutoff',f'{wb}/extensions/sd-{w}-cutoff')
|
160 |
+
# gitDownload(f'https://github.com/a2569875/lora-prompt-tool',f'{wb}/extensions/lora-prompt-tool')
|
161 |
+
gitDownload(f'https://github.com/yankooliveira/sd-{w}-photopea-embed',f'{wb}/extensions/sd-{w}-photopea-embed')
|
162 |
+
get_ipython().system(f'wget https://huggingface.co/gmk123/mhzs/raw/main/jubenchajian4_51.py -O {wb}/scripts/jubenchajian4_51.py')
|
163 |
+
gitDownload(f'https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111',f'{wb}/extensions/multidiffusion-upscaler-for-automatic1111')
|
164 |
+
#Roop换脸插件
|
165 |
+
if Roop:
|
166 |
+
gitDownload(f'https://github.com/Gourieff/sd-{w}-reactor',f'{wb}/extensions/sd-{w}-reactor')
|
167 |
+
print('Roop换脸启用')
|
168 |
+
else:
|
169 |
+
print('Roop换脸不启用')
|
170 |
+
|
171 |
+
# ControlNet模型
|
172 |
+
Cnt_models = [
|
173 |
+
'control_v11e_sd15_ip2p_fp16.safetensors',
|
174 |
+
'control_v11e_sd15_shuffle_fp16.safetensors',
|
175 |
+
'control_v11p_sd15_canny_fp16.safetensors',
|
176 |
+
'control_v11f1p_sd15_depth_fp16.safetensors',
|
177 |
+
'control_v11p_sd15_inpaint_fp16.safetensors',
|
178 |
+
'control_v11p_sd15_lineart_fp16.safetensors',
|
179 |
+
'control_v11p_sd15_mlsd_fp16.safetensors',
|
180 |
+
'control_v11p_sd15_normalbae_fp16.safetensors',
|
181 |
+
'control_v11p_sd15_openpose_fp16.safetensors',
|
182 |
+
'control_v11p_sd15_scribble_fp16.safetensors',
|
183 |
+
'control_v11p_sd15_seg_fp16.safetensors',
|
184 |
+
'control_v11p_sd15_softedge_fp16.safetensors',
|
185 |
+
'control_v11p_sd15s2_lineart_anime_fp16.safetensors',
|
186 |
+
'control_v11f1e_sd15_tile_fp16.safetensors',
|
187 |
+
]
|
188 |
+
get_ipython().system(f'rm -rf {wb}/extensions/sd-{w}-controlnet')
|
189 |
+
# 模型下载到Colab
|
190 |
+
if ControlNet == "Colab":
|
191 |
+
gitDownload(f'https://github.com/Mikubill/sd-{w}-controlnet',f'{wb}/extensions/sd-{w}-controlnet')
|
192 |
+
for v in Cnt_models:
|
193 |
+
get_ipython().system(f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/{v} -d {wb}/extensions/sd-{w}-controlnet/models -o {v}')
|
194 |
+
|
195 |
+
# 模型下载到Google_Drive
|
196 |
+
elif ControlNet == "Google_Drive":
|
197 |
+
cloudDriveSync(f'{gwb}/cnt_models')
|
198 |
+
gitDownload(f'https://github.com/Mikubill/sd-{w}-controlnet',f'{wb}/extensions/sd-{w}-controlnet')
|
199 |
+
for v in Cnt_models:
|
200 |
+
if not os.path.exists(f'{gwb}/cnt_models/{v}'):
|
201 |
+
get_ipython().system(f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/{v} -d {gwb}/cnt_models -o {v}')
|
202 |
+
print("创建扩展",f'{v}')
|
203 |
+
else:
|
204 |
+
print("扩展存在",f'{v}')
|
205 |
+
# 遍历cnt_models目录下的文件,将文件银接到Colab目录下的extensions目录下
|
206 |
+
for v in os.listdir(f'{gwb}/cnt_models'):
|
207 |
+
# 链接云盘目录
|
208 |
+
get_ipython().system(f'ln -s {gwb}/cnt_models/{v} {wb}/extensions/sd-{w}-controlnet/models')
|
209 |
+
|
210 |
+
elif ControlNet == "No":
|
211 |
+
print("不使用 ControlNet")
|
212 |
+
|
213 |
+
# 各种UI界面
|
214 |
+
if UI == "Kitchen_Ui":
|
215 |
+
gitDownload(f'https://github.com/canisminor1990/sd-{w}-kitchen-theme-legacy', f'{wb}/extensions/sd-{w}-kitchen-theme-legacy')
|
216 |
+
print("Kitchen界面插件启用")
|
217 |
+
elif UI == "Lobe_Ui":
|
218 |
+
gitDownload(f'https://github.com/canisminor1990/sd-web-ui-kitchen-theme', f'{wb}/extensions/sd-web-ui-kitchen-theme')
|
219 |
+
print("Lobe界面插件启用")
|
220 |
+
elif UI == "Ux_Ui":
|
221 |
+
gitDownload(f'https://github.com/anapnoe/{sdw}-ux', f'{wb}/extensions/{sdw}-ux')
|
222 |
+
print("UX界面插件启用")
|
223 |
+
elif UI == "No":
|
224 |
+
print("UI插件不启用")
|
225 |
+
|
226 |
+
# 关键词
|
227 |
+
if Key_words:
|
228 |
+
gitDownload(f'https://github.com/Physton/sd-{w}-prompt-all-in-one', f'{wb}/extensions/sd-{w}-prompt-all-in-one')
|
229 |
+
cloudDriveSync(f'{gwb}/storage', f'{wb}/extensions/sd-{w}-prompt-all-in-one/storage', Key_words)
|
230 |
+
print("关键词插件启用")
|
231 |
+
else:
|
232 |
+
get_ipython().system(f'rm -rf {wb}/extensions/sd-{w}-prompt-all-in-one')
|
233 |
+
print("关键词插件不启用")
|
234 |
+
|
235 |
+
# 人物说话
|
236 |
+
if SadTalker:
|
237 |
+
if not os.path.exists(f'{wb}/extensions/SadTalker'):
|
238 |
+
get_ipython().system(f'git clone https://github.com/OpenTalker/SadTalker {wb}/extensions/SadTalker')
|
239 |
+
get_ipython().system(f'git -C {wb}/extensions/SadTalker clone https://huggingface.co/gmk123/checkpoints')
|
240 |
+
get_ipython().system(f'git -C {wb}/models clone https://huggingface.co/gmk123/GFPGAN')
|
241 |
+
print("SadTalker启用")
|
242 |
+
else:
|
243 |
+
get_ipython().system(f'rm -rf {wb}/extensions/SadTalker')
|
244 |
+
print("SadTalker不启用")
|
245 |
+
|
246 |
+
# 初始化本地环境
|
247 |
+
def initLocal():
|
248 |
+
|
249 |
+
#部署 env 环境变量
|
250 |
+
get_ipython().system(f'apt -y update -qq')
|
251 |
+
get_ipython().system(f'wget https://huggingface.co/gmk123/sd_config/resolve/main/libtcmalloc_minimal.so.4 -O /content/libtcmalloc_minimal.so.4')
|
252 |
+
get_ipython().run_line_magic('env', 'LD_PRELOAD=/content/libtcmalloc_minimal.so.4')
|
253 |
+
|
254 |
+
#设置 python 环境
|
255 |
+
get_ipython().system(f'apt -y install -qq aria2 libcairo2-dev pkg-config python3-dev')
|
256 |
+
get_ipython().system(f'pip install -q torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2+cu118 torchtext==0.15.2 torchdata==0.6.1 --extra-index-url https://download.pytorch.org/whl/cu118 -U')
|
257 |
+
get_ipython().system(f'pip install -q xformers==0.0.20 triton==2.0.0 gradio_client==0.2.7 -U')
|
258 |
+
|
259 |
+
#主框架模块
|
260 |
+
if Version == "A1111":
|
261 |
+
get_ipython().system(f'git clone https://github.com/AUTOMATIC1111/{sdw} {wb}')
|
262 |
+
elif Version == "V2.2":
|
263 |
+
get_ipython().system(f'git clone -b v2.2 https://github.com/camenduru/{sdw} {wb}')
|
264 |
+
elif Version == "V2.3":
|
265 |
+
get_ipython().system(f'git clone -b v2.5 https://github.com/camenduru/{sdw} {wb}')
|
266 |
+
|
267 |
+
# get_ipython().system(f'git -C {wb}/repositories/stable-diffusion-stability-ai reset --hard')
|
268 |
+
|
269 |
+
# 初始化云盘
|
270 |
+
initCloudDrive()
|
271 |
+
|
272 |
+
# 安装附加功能
|
273 |
+
installAdditional()
|
274 |
+
|
275 |
+
# 删除原配置
|
276 |
+
get_ipython().system(f'rm -f {wb}/config.json')
|
277 |
+
|
278 |
+
# 链接用户配置
|
279 |
+
get_ipython().system(f'ln -s {gwb}/Config/config.json {wb}/config.json')
|
280 |
+
|
281 |
+
# 如果云盘没有模型
|
282 |
+
if len(os.listdir(f"{gwb}/models")) == 0:
|
283 |
+
#下载主模型
|
284 |
+
get_ipython().system(f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/chilloutmix/resolve/main/chilloutmix_NiPrunedFp32Fix.safetensors -d {wb}/models/Stable-diffusion -o chilloutmix_NiPrunedFp32Fix.safetensors')
|
285 |
+
|
286 |
+
# 如果云盘Vae模型
|
287 |
+
if len(os.listdir(f"{gwb}/VAE")) == 0:
|
288 |
+
# #VAE
|
289 |
+
get_ipython().system(f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors -d {wb}/models/VAE -o vae-ft-mse-840000-ema-pruned.safetensors')
|
290 |
+
|
291 |
+
model_dir = os.path.join(wb, "models", "Stable-diffusion")
|
292 |
+
if any(f.endswith(('.ckpt', '.safetensors')) for f in os.listdir(model_dir)):
|
293 |
+
get_ipython().system(f'sed -i \'s@weight_load_location =.*@weight_load_location = "cuda"@\' {wb}/modules/shared.py')
|
294 |
+
get_ipython().system(f'sed -i "[email protected](model_file)@os.path.splitext(model_file); map_location=\'cuda\'@" {wb}/modules/sd_models.py')
|
295 |
+
get_ipython().system(f'sed -i "s@map_location=\'cpu\'@map_location=\'cuda\'@" {wb}/modules/extras.py')
|
296 |
+
get_ipython().system(f"sed -i '[email protected]_ui().*@ui.create_ui();shared.demo.queue(concurrency_count=999999,status_update_rate=0.1)@' {wb}/webui.py")
|
297 |
+
|
298 |
+
|
299 |
+
# 运行
|
300 |
+
def run(script):
|
301 |
+
clear_output()
|
302 |
+
get_ipython().run_line_magic('cd', f'{wb}')
|
303 |
+
get_ipython().system(f'python {script} --listen --xformers --enable-insecure-extension-access --theme dark --gradio-queue --no-half-vae --disable-console-progressbars --multiple --opt-sdp-attention --api --cors-allow-origins=*')
|
304 |
+
|
305 |
+
# 运行脚本
|
306 |
+
if os.path.exists(f'{wb}'):
|
307 |
+
run('webui.py')
|
308 |
+
else:
|
309 |
+
# 初化本地环境
|
310 |
+
initLocal()
|
311 |
+
# 运行
|
312 |
+
run('launch.py')
|