Update launch.py
Browse files
launch.py
CHANGED
@@ -1,599 +1,379 @@
|
|
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 |
-
d = ""
|
78 |
-
D = ""
|
79 |
-
w = ""
|
80 |
-
st = ""
|
81 |
-
ca = ""
|
82 |
-
t = ""
|
83 |
-
CS_download1 = CS_download2 = CS_download3 = CS_download4 = CS_download5 = CS_download6 = CS_download7 = CS_download8 = CS_download9 = CS_download10 = CS_download11 = CS_download12 = CS_download13 = False
|
84 |
-
|
85 |
-
CS_url1 = CS_url2 = CS_url3 = CS_url4 = CS_url5 = CS_url6 = CS_url7 = CS_url8 = CS_url9 = CS_url10 = CS_url11 = CS_url12 = CS_url13 = ""
|
86 |
-
|
87 |
-
CS_filename1 = CS_filename2 = CS_filename3 = CS_filename4 = CS_filename5 = CS_filename6 = CS_filename7 = CS_filename8 = CS_filename9 = CS_filename10 = CS_filename11 = CS_filename12 = CS_filename13 = ""
|
88 |
-
|
89 |
-
Lora_download1 = Lora_download2 = Lora_download3 = Lora_download4 = Lora_download5 = Lora_download6 = False
|
90 |
-
|
91 |
-
Lora_url1 = Lora_url2 = Lora_url3 = Lora_url4 = Lora_url5 = Lora_url6 = ""
|
92 |
-
|
93 |
-
Lora_filename1 = Lora_filename2 = Lora_filename3 = Lora_filename4 = Lora_filename5 = Lora_filename6 = ""
|
94 |
-
|
95 |
-
VAE_download1 = VAE_download2 = VAE_download3 = VAE_download4 = VAE_download5 = VAE_download6 = VAE_download7 = VAE_download8 = VAE_download9 = VAE_download10 = VAE_download11 = VAE_download12 = VAE_download13 = False
|
96 |
-
|
97 |
-
VAE_url1 = VAE_url2 = VAE_url3 = VAE_url4 = VAE_url5 = VAE_url6 = VAE_url7 = VAE_url8 = VAE_url9 = VAE_url10 = VAE_url11 = VAE_url12 = VAE_url13 = ""
|
98 |
-
|
99 |
-
VAE_filename1 = VAE_filename2 = VAE_filename3 = VAE_filename4 = VAE_filename5 = VAE_filename6 = VAE_filename7 = VAE_filename8 = VAE_filename9 = VAE_filename10 = VAE_filename11 = VAE_filename12 = VAE_filename13 = ""
|
100 |
-
|
101 |
-
embeddings_download1 = embeddings_download2 = embeddings_download3 = embeddings_download4 = embeddings_download5 = False
|
102 |
-
|
103 |
-
embeddings_url1 = embeddings_url2 = embeddings_url3 = embeddings_url4 = embeddings_url5 = ""
|
104 |
-
|
105 |
-
embeddings_filename1 = embeddings_filename2 = embeddings_filename3 = embeddings_filename4 = embeddings_filename5 = ""
|
106 |
-
|
107 |
-
# 打开并执行txt文件
|
108 |
-
with open('BianLiang.txt', 'r') as file:
|
109 |
-
code = file.read()
|
110 |
-
|
111 |
-
# 去除每行开头和结尾的空格、空行等
|
112 |
-
cleaned_code = '\n'.join(line.strip() for line in code.splitlines() if line.strip())
|
113 |
-
|
114 |
-
# 执行干净的代码
|
115 |
-
exec(cleaned_code)
|
116 |
-
|
117 |
-
|
118 |
-
# 安装插件
|
119 |
-
print ("开始安装插件...")
|
120 |
-
|
121 |
-
# 使用subprocess运行git clone命令
|
122 |
-
def run_git_clone(repo_url, destination):
|
123 |
-
subprocess.run(["git", "clone", repo_url, destination])
|
124 |
-
|
125 |
-
extensions_path = "/content/drive/MyDrive/lite_colab/extensions"
|
126 |
-
|
127 |
-
extensions_to_clone = [
|
128 |
-
(f"https://github.com/deforum-art/deforum-for-automatic1111-{w}", f"{extensions_path}/deforum-for-automatic1111-{w}"),
|
129 |
-
(f"https://github.com/deforum-art/sd-{w}-deforum", f"{extensions_path}/sd-{w}-deforum"),
|
130 |
-
(f"https://github.com/butaixianran/Stable-Diffusion-Webui-Civitai-Helper", f"{extensions_path}/Stable-Diffusion-Webui-Civitai-Helper"),
|
131 |
-
(f"https://github.com/Mikubill/{c}-{w}-controlnet", f"{extensions_path}/{c}-{w}-controlnet"),
|
132 |
-
(f"https://github.com/fkunn1326/openpose-editor", f"{extensions_path}/openpose-editor"),
|
133 |
-
(f"https://github.com/{ca}/{a}-{d}-{w}-huggingface", f"{extensions_path}/{a}-{d}-{w}-huggingface"),
|
134 |
-
(f"https://github.com/kohya-ss/{c}-{w}-additional-networks", f"{extensions_path}/{c}-{w}-additional-networks"),
|
135 |
-
(f"https://github.com/hnmr293/posex", f"{extensions_path}/posex"),
|
136 |
-
(f"https://github.com/nonnonstop/{c}-{w}-3d-open-pose-editor", f"{extensions_path}/{c}-{w}-3d-open-pose-editor"),
|
137 |
-
(f"https://github.com/{ca}/{c}-{w}-tunnels", f"{extensions_path}/{c}-{w}-tunnels"),
|
138 |
-
(f"https://github.com/etherealxx/batchlinks-{w}", f"{extensions_path}/batchlinks-{w}"),
|
139 |
-
(f"https://github.com/catppuccin/{a}-{d}-{w}", f"{extensions_path}/{a}-{d}-{w}-catppuccin"),
|
140 |
-
(f"https://github.com/AUTOMATIC1111/{a}-{d}-{w}-rembg", f"{extensions_path}/{a}-{d}-{w}-rembg"),
|
141 |
-
(f"https://github.com/ashen-sensored/{a}-{d}-{w}-two-shot.git", f"{extensions_path}/{a}-{d}-{w}-two-shot"),
|
142 |
-
(f"https://github.com/thomasasfk/{c}-{w}-aspect-ratio-helper", f"{extensions_path}/{c}-{w}-aspect-ratio-helper"),
|
143 |
-
(f"https://github.com/Bing-su/adetailer", f"{extensions_path}/adetailer"),
|
144 |
-
(f"https://github.com/mcmonkeyprojects/sd-dynamic-thresholding", f"{extensions_path}/{c}-dynamic-thresholding"),
|
145 |
-
(f"https://github.com/adieyal/{c}-dynamic-prompts", f"{extensions_path}/{c}-dynamic-prompts"),
|
146 |
-
(f"https://github.com/AUTOMATIC1111/{a}-{d}-{w}-wildcards", f"{extensions_path}/{a}-{d}-{w}-wildcards"),
|
147 |
-
(f"https://github.com/continue-revolution/{c}-{w}-segment-anything", f"{extensions_path}/{c}-{w}-segment-anything"),
|
148 |
-
(f"https://github.com/pkuliyi2015/multi{d}-upscaler-for-automatic1111.git", f"{extensions_path}/multi{d}-upscaler-for-automatic1111"),
|
149 |
-
(f"https://github.com/Physton/{c}-{w}-prompt-all-in-one", f"{extensions_path}/{c}-{w}-prompt-all-in-one"),
|
150 |
-
(f"https://github.com/journey-ad/{c}-{w}-bilingual-localization", f"{extensions_path}/{c}-{w}-bilingual-localization"),
|
151 |
-
(f"https://github.com/Bobo-1125/{c}-{w}-oldsix-prompt-dynamic", f"{extensions_path}/{c}-{w}-oldsix-prompt-dynamic"),
|
152 |
-
(f"https://github.com/dtlnor/{st}-localization-zh_CN", f"{extensions_path}{st}-localization-zh_CN-main"),
|
153 |
-
]
|
154 |
-
|
155 |
-
for repo_url, destination in extensions_to_clone:
|
156 |
-
run_git_clone(repo_url, destination)
|
157 |
-
|
158 |
-
|
159 |
-
# 定义一个函数来运行wget命令
|
160 |
-
def run_wget(url, output_path):
|
161 |
-
wget_command = ["wget", url, "-O", output_path]
|
162 |
-
subprocess.run(wget_command, check=True)
|
163 |
-
|
164 |
-
# 定义一个函数来创建文件夹(如果不存在的话)
|
165 |
-
def create_directory(directory):
|
166 |
-
mkdir_command = ["mkdir", "-p", directory]
|
167 |
-
subprocess.run(mkdir_command, check=True)
|
168 |
-
|
169 |
-
|
170 |
-
# 安装可选模块
|
171 |
-
print ("安装可选模块...")
|
172 |
-
|
173 |
-
# 其它基本配置
|
174 |
-
CONTROLNET_ = True
|
175 |
-
T2I_ = True
|
176 |
-
|
177 |
-
# CN
|
178 |
-
if CONTROLNET_:
|
179 |
-
os.makedirs('/content/drive/MyDrive/lite_colab/extensions/control/models', exist_ok=True)
|
180 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_ip2p_fp16.safetensors', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11e_sd15_ip2p_fp16.safetensors')
|
181 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_shuffle_fp16.safetensors', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11e_sd15_shuffle_fp16.safetensors')
|
182 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny_fp16.safetensors', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15_canny_fp16.safetensors')
|
183 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1p_sd15_depth_fp16.safetensors', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11f1p_sd15_depth_fp16.safetensors')
|
184 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_inpaint_fp16.safetensors', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15_inpaint_fp16.safetensors')
|
185 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_lineart_fp16.safetensors', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15_lineart_fp16.safetensors')
|
186 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_mlsd_fp16.safetensors', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15_mlsd_fp16.safetensors')
|
187 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_normalbae_fp16.safetensors', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15_normalbae_fp16.safetensors')
|
188 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_openpose_fp16.safetensors', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15_openpose_fp16.safetensors')
|
189 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_scribble_fp16.safetensors', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15_scribble_fp16.safetensors')
|
190 |
-
#wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_seg_fp16.safetensors', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15_seg_fp16.safetensors')
|
191 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_softedge_fp16.safetensors', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15_softedge_fp16.safetensors')
|
192 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15s2_lineart_anime_fp16.safetensors')
|
193 |
-
#wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_tile_fp16.yaml', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11e_sd15_tile_fp16.yaml')
|
194 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_ip2p_fp16.yaml', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11e_sd15_ip2p_fp16.yaml')
|
195 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_shuffle_fp16.yaml', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11e_sd15_shuffle_fp16.yaml')
|
196 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_canny_fp16.yaml', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15_canny_fp16.yaml')
|
197 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1p_sd15_depth_fp16.yaml', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11f1p_sd15_depth_fp16.yaml')
|
198 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_inpaint_fp16.yaml', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15_inpaint_fp16.yaml')
|
199 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_lineart_fp16.yaml', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15_lineart_fp16.yaml')
|
200 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_mlsd_fp16.yaml', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15_mlsd_fp16.yaml')
|
201 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_normalbae_fp16.yaml', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15_normalbae_fp16.yaml')
|
202 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_openpose_fp16.yaml', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15_openpose_fp16.yaml')
|
203 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_scribble_fp16.yaml', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15_scribble_fp16.yaml')
|
204 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_seg_fp16.yaml', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15_seg_fp16.yaml')
|
205 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_softedge_fp16.yaml', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15_softedge_fp16.yaml')
|
206 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15s2_lineart_anime_fp16.yaml', '/content/drive/MyDrive/lite_colab/extensions/control/models/control_v11p_sd15s2_lineart_anime_fp16.yaml')
|
207 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1e_sd15_tile_fp16.yaml', '/content/drive/MyDrive/lite_colab/extensions/control/models')
|
208 |
-
|
209 |
-
# T2I
|
210 |
-
if T2I_:
|
211 |
-
os.makedirs('/content/drive/MyDrive/lite_colab/extensions/control/models', exist_ok=True)
|
212 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_style_sd14v1.pth', '/content/drive/MyDrive/lite_colab/extensions/control/models/t2iadapter_style_sd14v1.pth')
|
213 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_sketch_sd14v1.pth', '/content/drive/MyDrive/lite_colab/extensions/control/models/t2iadapter_sketch_sd14v1.pth')
|
214 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_seg_sd14v1.pth', '/content/drive/MyDrive/lite_colab/extensions/control/models/t2iadapter_seg_sd14v1.pth')
|
215 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_openpose_sd14v1.pth', '/content/drive/MyDrive/lite_colab/extensions/control/models/t2iadapter_openpose_sd14v1.pth')
|
216 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_keypose_sd14v1.pth', '/content/drive/MyDrive/lite_colab/extensions/control/models/t2iadapter_keypose_sd14v1.pth')
|
217 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_depth_sd14v1.pth', '/content/drive/MyDrive/lite_colab/extensions/control/models/t2iadapter_depth_sd14v1.pth')
|
218 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_color_sd14v1.pth', '/content/drive/MyDrive/lite_colab/extensions/control/models/t2iadapter_color_sd14v1.pth')
|
219 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_canny_sd14v1.pth', '/content/drive/MyDrive/lite_colab/extensions/control/models/t2iadapter_canny_sd14v1.pth')
|
220 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_canny_sd15v2.pth', '/content/drive/MyDrive/lite_colab/extensions/control/models/t2iadapter_canny_sd15v2.pth')
|
221 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_depth_sd15v2.pth', '/content/drive/MyDrive/lite_colab/extensions/control/models/t2iadapter_depth_sd15v2.pth')
|
222 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_sketch_sd15v2.pth', '/content/drive/MyDrive/lite_colab/extensions/control/models/t2iadapter_sketch_sd15v2.pth')
|
223 |
-
wget.download('https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/t2iadapter_zoedepth_sd15v1.pth', '/content/drive/MyDrive/lite_colab/extensions/control/models/t2iadapter_zoedepth_sd15v1.pth')
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
"""# 模型下载"""
|
229 |
-
|
230 |
-
print ("开始下载Checkpoints/safetensors等大模型")
|
231 |
-
# Checkpoints/safetensors等大模型下载
|
232 |
-
# 下载任务1
|
233 |
-
CS_destination_folder1 = f"/content/drive/MyDrive/lite_colab/models/Stable-diffusion"
|
234 |
-
CS_target1 = f"{CS_destination_folder1}/{CS_filename1}"
|
235 |
-
|
236 |
-
if CS_download1:
|
237 |
-
os.makedirs(CS_destination_folder1, exist_ok=True)
|
238 |
-
response = requests.get(CS_url1)
|
239 |
-
with open(CS_target1, 'wb') as f:
|
240 |
-
f.write(response.content)
|
241 |
-
|
242 |
-
# 下载任务2
|
243 |
-
CS_destination_folder2 = f"/content/drive/MyDrive/lite_colab/models/Stable-diffusion"
|
244 |
-
CS_target2 = f"{CS_destination_folder2}/{CS_filename2}"
|
245 |
-
|
246 |
-
if CS_download2:
|
247 |
-
os.makedirs(CS_destination_folder2, exist_ok=True)
|
248 |
-
response = requests.get(CS_url2)
|
249 |
-
with open(CS_target2, 'wb') as f:
|
250 |
-
f.write(response.content)
|
251 |
-
|
252 |
-
# 下载任务3
|
253 |
-
CS_destination_folder3 = f"/content/drive/MyDrive/lite_colab/models/Stable-diffusion"
|
254 |
-
CS_target3 = f"{CS_destination_folder3}/{CS_filename3}"
|
255 |
-
|
256 |
-
if CS_download3:
|
257 |
-
os.makedirs(CS_destination_folder3, exist_ok=True)
|
258 |
-
response = requests.get(CS_url3)
|
259 |
-
with open(CS_target3, 'wb') as f:
|
260 |
-
f.write(response.content)
|
261 |
-
|
262 |
-
# 下载任务4
|
263 |
-
CS_destination_folder4 = f"/content/drive/MyDrive/lite_colab/models/Stable-diffusion"
|
264 |
-
CS_target4 = f"{CS_destination_folder4}/{CS_filename4}"
|
265 |
-
|
266 |
-
if CS_download4:
|
267 |
-
os.makedirs(CS_destination_folder4, exist_ok=True)
|
268 |
-
response = requests.get(CS_url4)
|
269 |
-
with open(CS_target4, 'wb') as f:
|
270 |
-
f.write(response.content)
|
271 |
-
|
272 |
-
# 下载任务5
|
273 |
-
CS_destination_folder5 = f"/content/drive/MyDrive/lite_colab/models/Stable-diffusion"
|
274 |
-
CS_target5 = f"{CS_destination_folder5}/{CS_filename5}"
|
275 |
-
|
276 |
-
if CS_download5:
|
277 |
-
os.makedirs(CS_destination_folder5, exist_ok=True)
|
278 |
-
response = requests.get(CS_url5)
|
279 |
-
with open(CS_target5, 'wb') as f:
|
280 |
-
f.write(response.content)
|
281 |
-
|
282 |
-
# 下载任务6
|
283 |
-
CS_destination_folder6 = f"/content/drive/MyDrive/lite_colab/models/Stable-diffusion"
|
284 |
-
CS_target6 = f"{CS_destination_folder6}/{CS_filename6}"
|
285 |
-
|
286 |
-
if CS_download6:
|
287 |
-
os.makedirs(CS_destination_folder6, exist_ok=True)
|
288 |
-
response = requests.get(CS_url6)
|
289 |
-
with open(CS_target6, 'wb') as f:
|
290 |
-
f.write(response.content)
|
291 |
-
|
292 |
-
# 下载任务7
|
293 |
-
CS_destination_folder7 = f"/content/drive/MyDrive/lite_colab/models/Stable-diffusion"
|
294 |
-
CS_target7 = f"{CS_destination_folder7}/{CS_filename7}"
|
295 |
-
|
296 |
-
if CS_download7:
|
297 |
-
os.makedirs(CS_destination_folder7, exist_ok=True)
|
298 |
-
response = requests.get(CS_url7)
|
299 |
-
with open(CS_target7, 'wb') as f:
|
300 |
-
f.write(response.content)
|
301 |
-
|
302 |
-
# 下载任务8
|
303 |
-
CS_destination_folder8 = f"/content/drive/MyDrive/lite_colab/models/Stable-diffusion"
|
304 |
-
CS_target8 = f"{CS_destination_folder8}/{CS_filename8}"
|
305 |
-
|
306 |
-
if CS_download8:
|
307 |
-
os.makedirs(CS_destination_folder8, exist_ok=True)
|
308 |
-
response = requests.get(CS_url8)
|
309 |
-
with open(CS_target8, 'wb') as f:
|
310 |
-
f.write(response.content)
|
311 |
-
|
312 |
-
# 下载任务9
|
313 |
-
CS_destination_folder9 = f"/content/drive/MyDrive/lite_colab/models/Stable-diffusion"
|
314 |
-
CS_target9 = f"{CS_destination_folder9}/{CS_filename9}"
|
315 |
-
|
316 |
-
if CS_download9:
|
317 |
-
os.makedirs(CS_destination_folder9, exist_ok=True)
|
318 |
-
response = requests.get(CS_url9)
|
319 |
-
with open(CS_target9, 'wb') as f:
|
320 |
-
f.write(response.content)
|
321 |
-
|
322 |
-
# 下载任务10
|
323 |
-
CS_destination_folder10 = f"/content/drive/MyDrive/lite_colab/models/Stable-diffusion"
|
324 |
-
CS_target10 = f"{CS_destination_folder10}/{CS_filename10}"
|
325 |
-
|
326 |
-
if CS_download10:
|
327 |
-
os.makedirs(CS_destination_folder10, exist_ok=True)
|
328 |
-
response = requests.get(CS_url10)
|
329 |
-
with open(CS_target10, 'wb') as f:
|
330 |
-
f.write(response.content)
|
331 |
-
|
332 |
-
# 下载任务11
|
333 |
-
CS_destination_folder11 = f"/content/drive/MyDrive/lite_colab/models/Stable-diffusion"
|
334 |
-
CS_target11 = f"{CS_destination_folder11}/{CS_filename11}"
|
335 |
-
|
336 |
-
if CS_download11:
|
337 |
-
os.makedirs(CS_destination_folder11, exist_ok=True)
|
338 |
-
response = requests.get(CS_url11)
|
339 |
-
with open(CS_target11, 'wb') as f:
|
340 |
-
f.write(response.content)
|
341 |
-
|
342 |
-
# 下载任务12
|
343 |
-
CS_destination_folder12 = f"/content/drive/MyDrive/lite_colab/models/Stable-diffusion"
|
344 |
-
CS_target12 = f"{CS_destination_folder12}/{CS_filename12}"
|
345 |
-
|
346 |
-
if CS_download12:
|
347 |
-
os.makedirs(CS_destination_folder12, exist_ok=True)
|
348 |
-
response = requests.get(CS_url12)
|
349 |
-
with open(CS_target12, 'wb') as f:
|
350 |
-
f.write(response.content)
|
351 |
-
|
352 |
-
# 下载任务13
|
353 |
-
CS_destination_folder13 = f"/content/drive/MyDrive/lite_colab/models/Stable-diffusion"
|
354 |
-
CS_target13 = f"{CS_destination_folder13}/{CS_filename13}"
|
355 |
-
|
356 |
-
if CS_download13:
|
357 |
-
os.makedirs(CS_destination_folder13, exist_ok=True)
|
358 |
-
response = requests.get(CS_url13)
|
359 |
-
with open(CS_target13, 'wb') as f:
|
360 |
-
f.write(response.content)
|
361 |
-
|
362 |
-
|
363 |
-
#Lora模型下载
|
364 |
-
|
365 |
-
print("开始下载Lora模型")
|
366 |
-
# Lora任务1
|
367 |
-
Lora_destination_folder1 = "/content/drive/MyDrive/lite_colab/models/Lora"
|
368 |
-
Lora_target1 = os.path.join(Lora_destination_folder1, Lora_filename1)
|
369 |
-
|
370 |
-
if Lora_download1:
|
371 |
-
response = requests.get(Lora_url1)
|
372 |
-
if response.status_code == 200:
|
373 |
-
with open(Lora_target1, 'wb') as f:
|
374 |
-
f.write(response.content)
|
375 |
-
|
376 |
-
# Lora任务2
|
377 |
-
Lora_destination_folder2 = "/content/drive/MyDrive/lite_colab/models/Lora"
|
378 |
-
Lora_target2 = os.path.join(Lora_destination_folder2, Lora_filename2)
|
379 |
-
|
380 |
-
if Lora_download2:
|
381 |
-
response = requests.get(Lora_url2)
|
382 |
-
if response.status_code == 200:
|
383 |
-
with open(Lora_target2, 'wb') as f:
|
384 |
-
f.write(response.content)
|
385 |
-
|
386 |
-
# Lora任务3
|
387 |
-
Lora_destination_folder3 = "/content/drive/MyDrive/lite_colab/models/Lora"
|
388 |
-
Lora_target3 = os.path.join(Lora_destination_folder3, Lora_filename3)
|
389 |
-
|
390 |
-
if Lora_download3:
|
391 |
-
response = requests.get(Lora_url3)
|
392 |
-
if response.status_code == 200:
|
393 |
-
with open(Lora_target3, 'wb') as f:
|
394 |
-
f.write(response.content)
|
395 |
-
|
396 |
-
# Lora任务4
|
397 |
-
Lora_destination_folder4 = Lora_destination_folder3
|
398 |
-
Lora_target4 = os.path.join(Lora_destination_folder4, Lora_filename4)
|
399 |
-
|
400 |
-
if Lora_download4:
|
401 |
-
response = requests.get(Lora_url4)
|
402 |
-
if response.status_code == 200:
|
403 |
-
with open(Lora_target4, 'wb') as f:
|
404 |
-
f.write(response.content)
|
405 |
-
|
406 |
-
# Lora任务5
|
407 |
-
Lora_destination_folder5 = Lora_destination_folder3
|
408 |
-
Lora_target5 = os.path.join(Lora_destination_folder5, Lora_filename5)
|
409 |
-
|
410 |
-
if Lora_download5:
|
411 |
-
response = requests.get(Lora_url5)
|
412 |
-
if response.status_code == 200:
|
413 |
-
with open(Lora_target5, 'wb') as f:
|
414 |
-
f.write(response.content)
|
415 |
-
|
416 |
-
# Lora任务6
|
417 |
-
Lora_destination_folder6 = Lora_destination_folder3
|
418 |
-
Lora_target6 = os.path.join(Lora_destination_folder6, Lora_filename6)
|
419 |
-
|
420 |
-
if Lora_download6:
|
421 |
-
response = requests.get(Lora_url6)
|
422 |
-
if response.status_code == 200:
|
423 |
-
with open(Lora_target6, 'wb') as f:
|
424 |
-
f.write(response.content)
|
425 |
-
|
426 |
-
|
427 |
-
# VAE下载
|
428 |
-
|
429 |
-
print ("开始下载VAE模型")
|
430 |
-
# VAE任务1
|
431 |
-
VAE_destination_folder1 = "/content/drive/MyDrive/lite_colab/models/VAE"
|
432 |
-
VAE_target1 = f"{VAE_destination_folder1}/{VAE_filename1}"
|
433 |
-
|
434 |
-
if VAE_download1:
|
435 |
-
response = requests.get(VAE_url1)
|
436 |
-
with open(VAE_target1, 'wb') as file:
|
437 |
-
file.write(response.content)
|
438 |
-
|
439 |
-
# VAE任务2
|
440 |
-
VAE_destination_folder2 = "/content/drive/MyDrive/lite_colab/models/VAE"
|
441 |
-
VAE_target2 = f"{VAE_destination_folder2}/{VAE_filename2}"
|
442 |
-
|
443 |
-
if VAE_download2:
|
444 |
-
response = requests.get(VAE_url2)
|
445 |
-
with open(VAE_target2, 'wb') as file:
|
446 |
-
file.write(response.content)
|
447 |
-
|
448 |
-
# VAE任务3
|
449 |
-
VAE_destination_folder3 = "/content/drive/MyDrive/lite_colab/models/VAE"
|
450 |
-
VAE_target3 = f"{VAE_destination_folder3}/{VAE_filename3}"
|
451 |
-
|
452 |
-
if VAE_download3:
|
453 |
-
response = requests.get(VAE_url3)
|
454 |
-
with open(VAE_target3, 'wb') as file:
|
455 |
-
file.write(response.content)
|
456 |
-
|
457 |
-
# VAE任务4
|
458 |
-
VAE_destination_folder4 = "/content/drive/MyDrive/lite_colab/models/VAE"
|
459 |
-
VAE_target4 = f"{VAE_destination_folder4}/{VAE_filename4}"
|
460 |
-
|
461 |
-
if VAE_download4:
|
462 |
-
response = requests.get(VAE_url4)
|
463 |
-
with open(VAE_target4, 'wb') as file:
|
464 |
-
file.write(response.content)
|
465 |
-
|
466 |
-
# VAE任务5
|
467 |
-
VAE_destination_folder5 = "/content/drive/MyDrive/lite_colab/models/VAE"
|
468 |
-
VAE_target5 = f"{VAE_destination_folder5}/{VAE_filename5}"
|
469 |
-
|
470 |
-
if VAE_download5:
|
471 |
-
response = requests.get(VAE_url5)
|
472 |
-
with open(VAE_target5, 'wb') as file:
|
473 |
-
file.write(response.content)
|
474 |
-
|
475 |
-
# VAE任务6
|
476 |
-
VAE_destination_folder6 = "/content/drive/MyDrive/lite_colab/models/VAE"
|
477 |
-
VAE_target6 = f"{VAE_destination_folder6}/{VAE_filename6}"
|
478 |
-
|
479 |
-
if VAE_download6:
|
480 |
-
response = requests.get(VAE_url6)
|
481 |
-
with open(VAE_target6, 'wb') as file:
|
482 |
-
file.write(response.content)
|
483 |
-
|
484 |
-
# VAE任务7
|
485 |
-
VAE_destination_folder7 = "/content/drive/MyDrive/lite_colab/models/VAE"
|
486 |
-
VAE_target7 = f"{VAE_destination_folder7}/{VAE_filename7}"
|
487 |
-
|
488 |
-
if VAE_download7:
|
489 |
-
response = requests.get(VAE_url7)
|
490 |
-
with open(VAE_target7, 'wb') as file:
|
491 |
-
file.write(response.content)
|
492 |
-
|
493 |
-
# VAE任务8
|
494 |
-
VAE_destination_folder8 = "/content/drive/MyDrive/lite_colab/models/VAE"
|
495 |
-
VAE_target8 = f"{VAE_destination_folder8}/{VAE_filename8}"
|
496 |
-
|
497 |
-
if VAE_download8:
|
498 |
-
response = requests.get(VAE_url8)
|
499 |
-
with open(VAE_target8, 'wb') as file:
|
500 |
-
file.write(response.content)
|
501 |
-
|
502 |
-
# VAE任务9
|
503 |
-
VAE_destination_folder9 = "/content/drive/MyDrive/lite_colab/models/VAE"
|
504 |
-
VAE_target9 = f"{VAE_destination_folder9}/{VAE_filename9}"
|
505 |
-
|
506 |
-
if VAE_download9:
|
507 |
-
response = requests.get(VAE_url9)
|
508 |
-
with open(VAE_target9, 'wb') as file:
|
509 |
-
file.write(response.content)
|
510 |
-
|
511 |
-
# VAE任务10
|
512 |
-
VAE_destination_folder10 = "/content/drive/MyDrive/lite_colab/models/VAE"
|
513 |
-
VAE_target10 = f"{VAE_destination_folder10}/{VAE_filename10}"
|
514 |
-
|
515 |
-
if VAE_download10:
|
516 |
-
response = requests.get(VAE_url10)
|
517 |
-
with open(VAE_target10, 'wb') as file:
|
518 |
-
file.write(response.content)
|
519 |
-
|
520 |
-
# VAE任务11
|
521 |
-
VAE_destination_folder11 = "/content/drive/MyDrive/lite_colab/models/VAE"
|
522 |
-
VAE_target11 = f"{VAE_destination_folder11}/{VAE_filename11}"
|
523 |
-
|
524 |
-
if VAE_download11:
|
525 |
-
response = requests.get(VAE_url11)
|
526 |
-
with open(VAE_target11, 'wb') as file:
|
527 |
-
file.write(response.content)
|
528 |
-
|
529 |
-
# VAE任务12
|
530 |
-
VAE_destination_folder12 = "/content/drive/MyDrive/lite_colab/models/VAE"
|
531 |
-
VAE_target12 = f"{VAE_destination_folder12}/{VAE_filename12}"
|
532 |
-
|
533 |
-
if VAE_download12:
|
534 |
-
response = requests.get(VAE_url12)
|
535 |
-
with open(VAE_target12, 'wb') as file:
|
536 |
-
file.write(response.content)
|
537 |
-
|
538 |
-
# VAE任务13
|
539 |
-
VAE_destination_folder13 = "/content/drive/MyDrive/lite_colab/models/VAE"
|
540 |
-
VAE_target13 = f"{VAE_destination_folder13}/{VAE_filename13}"
|
541 |
-
|
542 |
-
if VAE_download13:
|
543 |
-
response = requests.get(VAE_url13)
|
544 |
-
with open(VAE_target13, 'wb') as file:
|
545 |
-
file.write(response.content)
|
546 |
-
|
547 |
-
|
548 |
-
# embeddings模型下载
|
549 |
-
|
550 |
-
print ("开始下载embeddings模型")
|
551 |
-
# 下载任务1
|
552 |
-
embeddings_destination_folder1 = "/content/drive/MyDrive/lite_colab/embeddings"
|
553 |
-
embeddings_target1 = f'{embeddings_destination_folder1}/{embeddings_filename1}'
|
554 |
-
|
555 |
-
if embeddings_download1:
|
556 |
-
os.makedirs(embeddings_destination_folder1, exist_ok=True)
|
557 |
-
response = requests.get(embeddings_url1)
|
558 |
-
with open(embeddings_target1, 'wb') as file:
|
559 |
-
file.write(response.content)
|
560 |
-
|
561 |
-
# 下载任务2
|
562 |
-
embeddings_destination_folder2 = "/content/drive/MyDrive/lite_colab/embeddings"
|
563 |
-
embeddings_target2 = f'{embeddings_destination_folder2}/{embeddings_filename2}'
|
564 |
-
|
565 |
-
if embeddings_download2:
|
566 |
-
os.makedirs(embeddings_destination_folder2, exist_ok=True)
|
567 |
-
response = requests.get(embeddings_url2)
|
568 |
-
with open(embeddings_target2, 'wb') as file:
|
569 |
-
file.write(response.content)
|
570 |
-
|
571 |
-
# 下载任务3
|
572 |
-
embeddings_destination_folder3 = "/content/drive/MyDrive/lite_colab/embeddings"
|
573 |
-
embeddings_target3 = f'{embeddings_destination_folder3}/{embeddings_filename3}'
|
574 |
-
|
575 |
-
if embeddings_download3:
|
576 |
-
os.makedirs(embeddings_destination_folder3, exist_ok=True)
|
577 |
-
response = requests.get(embeddings_url3)
|
578 |
-
with open(embeddings_target3, 'wb') as file:
|
579 |
-
file.write(response.content)
|
580 |
-
|
581 |
-
# 下载任务4
|
582 |
-
embeddings_destination_folder4 = "/content/drive/MyDrive/lite_colab/embeddings"
|
583 |
-
embeddings_target4 = f'{embeddings_destination_folder4}/{embeddings_filename4}'
|
584 |
-
|
585 |
-
if embeddings_download4:
|
586 |
-
os.makedirs(embeddings_destination_folder4, exist_ok=True)
|
587 |
-
response = requests.get(embeddings_url4)
|
588 |
-
with open(embeddings_target4, 'wb') as file:
|
589 |
-
file.write(response.content)
|
590 |
-
|
591 |
-
# 下载任务5
|
592 |
-
embeddings_destination_folder5 = "/content/drive/MyDrive/lite_colab/embeddings"
|
593 |
-
embeddings_target5 = f'{embeddings_destination_folder5}/{embeddings_filename5}'
|
594 |
-
|
595 |
-
if embeddings_download5:
|
596 |
-
os.makedirs(embeddings_destination_folder5, exist_ok=True)
|
597 |
-
response = requests.get(embeddings_url5)
|
598 |
-
with open(embeddings_target5, 'wb') as file:
|
599 |
-
file.write(response.content)
|
|
|
1 |
+
# this scripts installs necessary requirements and launches main program in .py
|
2 |
+
import subprocess
|
3 |
+
import os
|
4 |
+
import sys
|
5 |
+
import importlib.util
|
6 |
+
import shlex
|
7 |
+
import platform
|
8 |
+
import json
|
9 |
+
from pathlib import Path
|
10 |
+
|
11 |
+
from modules import cmd_args
|
12 |
+
from modules.paths_internal import script_path, extensions_dir
|
13 |
+
|
14 |
+
#ngrok穿透
|
15 |
+
ngrok_use = True
|
16 |
+
ngrokTokenFile='/content/drive/MyDrive/Authtoken.txt' # 非必填 存放ngrokToken的文件的路径
|
17 |
+
|
18 |
+
def ngrok_start(ngrokTokenFile: str, port: int, address_name: str, should_run: bool):
|
19 |
+
if not should_run:
|
20 |
+
print('Skipping ngrok start')
|
21 |
+
return
|
22 |
+
if Path(ngrokTokenFile).exists():
|
23 |
+
with open(ngrokTokenFile, encoding="utf-8") as nkfile:
|
24 |
+
ngrokToken = nkfile.readline()
|
25 |
+
print('use nrgok')
|
26 |
+
from pyngrok import conf, ngrok
|
27 |
+
conf.get_default().auth_token = ngrokToken
|
28 |
+
conf.get_default().monitor_thread = False
|
29 |
+
ssh_tunnels = ngrok.get_tunnels(conf.get_default())
|
30 |
+
if len(ssh_tunnels) == 0:
|
31 |
+
ssh_tunnel = ngrok.connect(port, bind_tls=True)
|
32 |
+
print(f'{address_name}:' + ssh_tunnel.public_url)
|
33 |
+
else:
|
34 |
+
print(f'{address_name}:' + ssh_tunnels[0].public_url)
|
35 |
+
else:
|
36 |
+
print('skip start ngrok')
|
37 |
+
|
38 |
+
|
39 |
+
commandline_args = os.environ.get('COMMANDLINE_ARGS', "")
|
40 |
+
sys.argv += shlex.split(commandline_args)
|
41 |
+
|
42 |
+
args, _ = cmd_args.parser.parse_known_args()
|
43 |
+
|
44 |
+
python = sys.executable
|
45 |
+
git = os.environ.get('GIT', "git")
|
46 |
+
index_url = os.environ.get('INDEX_URL', "")
|
47 |
+
stored_commit_hash = None
|
48 |
+
dir_repos = "repositories"
|
49 |
+
|
50 |
+
if 'GRADIO_ANALYTICS_ENABLED' not in os.environ:
|
51 |
+
os.environ['GRADIO_ANALYTICS_ENABLED'] = 'False'
|
52 |
+
|
53 |
+
|
54 |
+
def check_python_version():
|
55 |
+
is_windows = platform.system() == "Windows"
|
56 |
+
major = sys.version_info.major
|
57 |
+
minor = sys.version_info.minor
|
58 |
+
micro = sys.version_info.micro
|
59 |
+
|
60 |
+
if is_windows:
|
61 |
+
supported_minors = [10]
|
62 |
+
else:
|
63 |
+
supported_minors = [7, 8, 9, 10, 11]
|
64 |
+
|
65 |
+
if not (major == 3 and minor in supported_minors):
|
66 |
+
import modules.errors
|
67 |
+
|
68 |
+
modules.errors.print_error_explanation(f"""
|
69 |
+
INCOMPATIBLE PYTHON VERSION
|
70 |
+
|
71 |
+
This program is tested with 3.10.6 Python, but you have {major}.{minor}.{micro}.
|
72 |
+
If you encounter an error with "RuntimeError: Couldn't install torch." message,
|
73 |
+
or any other error regarding unsuccessful package (library) installation,
|
74 |
+
please downgrade (or upgrade) to the latest version of 3.10 Python
|
75 |
+
and delete current Python and "venv" folder in startfk's directory.
|
76 |
+
|
77 |
+
You can download 3.10 Python from here: https://www.python.org/downloads/release/python-3106/
|
78 |
+
|
79 |
+
{"Alternatively, use a binary release of startfk: " if is_windows else ""}
|
80 |
+
|
81 |
+
Use --skip-python-version-check to suppress this warning.
|
82 |
+
""")
|
83 |
+
|
84 |
+
|
85 |
+
def commit_hash():
|
86 |
+
global stored_commit_hash
|
87 |
+
|
88 |
+
if stored_commit_hash is not None:
|
89 |
+
return stored_commit_hash
|
90 |
+
|
91 |
+
try:
|
92 |
+
stored_commit_hash = run(f"{git} rev-parse HEAD").strip()
|
93 |
+
except Exception:
|
94 |
+
stored_commit_hash = "<none>"
|
95 |
+
|
96 |
+
return stored_commit_hash
|
97 |
+
|
98 |
+
|
99 |
+
def run(command, desc=None, errdesc=None, custom_env=None, live=False):
|
100 |
+
if desc is not None:
|
101 |
+
print(desc)
|
102 |
+
|
103 |
+
if live:
|
104 |
+
result = subprocess.run(command, shell=True, env=os.environ if custom_env is None else custom_env)
|
105 |
+
if result.returncode != 0:
|
106 |
+
raise RuntimeError(f"""{errdesc or 'Error running command'}.
|
107 |
+
Command: {command}
|
108 |
+
Error code: {result.returncode}""")
|
109 |
+
|
110 |
+
return ""
|
111 |
+
|
112 |
+
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, env=os.environ if custom_env is None else custom_env)
|
113 |
+
|
114 |
+
if result.returncode != 0:
|
115 |
+
|
116 |
+
message = f"""{errdesc or 'Error running command'}.
|
117 |
+
Command: {command}
|
118 |
+
Error code: {result.returncode}
|
119 |
+
stdout: {result.stdout.decode(encoding="utf8", errors="ignore") if len(result.stdout)>0 else '<empty>'}
|
120 |
+
stderr: {result.stderr.decode(encoding="utf8", errors="ignore") if len(result.stderr)>0 else '<empty>'}
|
121 |
"""
|
122 |
+
raise RuntimeError(message)
|
123 |
|
124 |
+
return result.stdout.decode(encoding="utf8", errors="ignore")
|
125 |
+
|
126 |
+
|
127 |
+
def check_run(command):
|
128 |
+
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
129 |
+
return result.returncode == 0
|
130 |
+
|
131 |
+
|
132 |
+
def is_installed(package):
|
133 |
+
try:
|
134 |
+
spec = importlib.util.find_spec(package)
|
135 |
+
except ModuleNotFoundError:
|
136 |
+
return False
|
137 |
+
|
138 |
+
return spec is not None
|
139 |
+
|
140 |
+
|
141 |
+
def repo_dir(name):
|
142 |
+
return os.path.join(script_path, dir_repos, name)
|
143 |
+
|
144 |
+
|
145 |
+
def run_python(code, desc=None, errdesc=None):
|
146 |
+
return run(f'"{python}" -c "{code}"', desc, errdesc)
|
147 |
+
|
148 |
+
|
149 |
+
def run_pip(command, desc=None, live=False):
|
150 |
+
if args.skip_install:
|
151 |
+
return
|
152 |
+
|
153 |
+
index_url_line = f' --index-url {index_url}' if index_url != '' else ''
|
154 |
+
return run(f'"{python}" -m pip {command} --prefer-binary{index_url_line}', desc=f"Installing {desc}", errdesc=f"Couldn't install {desc}", live=live)
|
155 |
+
|
156 |
+
|
157 |
+
def check_run_python(code):
|
158 |
+
return check_run(f'"{python}" -c "{code}"')
|
159 |
+
|
160 |
+
|
161 |
+
def git_clone(url, dir, name, commithash=None):
|
162 |
+
# TODO clone into temporary dir and move if successful
|
163 |
+
|
164 |
+
if os.path.exists(dir):
|
165 |
+
if commithash is None:
|
166 |
+
return
|
167 |
+
|
168 |
+
current_hash = run(f'"{git}" -C "{dir}" rev-parse HEAD', None, f"Couldn't determine {name}'s hash: {commithash}").strip()
|
169 |
+
if current_hash == commithash:
|
170 |
+
return
|
171 |
+
|
172 |
+
run(f'"{git}" -C "{dir}" fetch', f"Fetching updates for {name}...", f"Couldn't fetch {name}")
|
173 |
+
run(f'"{git}" -C "{dir}" checkout {commithash}', f"Checking out commit for {name} with hash: {commithash}...", f"Couldn't checkout commit {commithash} for {name}")
|
174 |
+
return
|
175 |
+
|
176 |
+
run(f'"{git}" clone "{url}" "{dir}"', f"Cloning {name} into {dir}...", f"Couldn't clone {name}")
|
177 |
+
|
178 |
+
if commithash is not None:
|
179 |
+
run(f'"{git}" -C "{dir}" checkout {commithash}', None, "Couldn't checkout {name}'s hash: {commithash}")
|
180 |
+
|
181 |
+
|
182 |
+
def git_pull_recursive(dir):
|
183 |
+
for subdir, _, _ in os.walk(dir):
|
184 |
+
if os.path.exists(os.path.join(subdir, '.git')):
|
185 |
+
try:
|
186 |
+
output = subprocess.check_output([git, '-C', subdir, 'pull', '--autostash'])
|
187 |
+
print(f"Pulled changes for repository in '{subdir}':\n{output.decode('utf-8').strip()}\n")
|
188 |
+
except subprocess.CalledProcessError as e:
|
189 |
+
print(f"Couldn't perform 'git pull' on repository in '{subdir}':\n{e.output.decode('utf-8').strip()}\n")
|
190 |
+
|
191 |
+
|
192 |
+
def version_check(commit):
|
193 |
+
try:
|
194 |
+
import requests
|
195 |
+
commits = requests.get('https://api.github.com/repos/zetclansu/lite-kaggle/branches/main').json()
|
196 |
+
if commit != "<none>" and commits['commit']['sha'] != commit:
|
197 |
+
print("--------------------------------------------------------")
|
198 |
+
print("| You are not up to date with the most recent release. |")
|
199 |
+
print("| Consider running `git pull` to update. |")
|
200 |
+
print("--------------------------------------------------------")
|
201 |
+
elif commits['commit']['sha'] == commit:
|
202 |
+
print("You are up to date with the most recent release.")
|
203 |
+
else:
|
204 |
+
print("Not a git clone, can't perform version check.")
|
205 |
+
except Exception as e:
|
206 |
+
print("version check failed", e)
|
207 |
+
|
208 |
+
|
209 |
+
def run_extension_installer(extension_dir):
|
210 |
+
path_installer = os.path.join(extension_dir, "install.py")
|
211 |
+
if not os.path.isfile(path_installer):
|
212 |
+
return
|
213 |
+
|
214 |
+
try:
|
215 |
+
env = os.environ.copy()
|
216 |
+
env['PYTHONPATH'] = os.path.abspath(".")
|
217 |
+
|
218 |
+
print(run(f'"{python}" "{path_installer}"', errdesc=f"Error running install.py for extension {extension_dir}", custom_env=env))
|
219 |
+
except Exception as e:
|
220 |
+
print(e, file=sys.stderr)
|
221 |
+
|
222 |
+
|
223 |
+
def list_extensions(settings_file):
|
224 |
+
settings = {}
|
225 |
+
|
226 |
+
try:
|
227 |
+
if os.path.isfile(settings_file):
|
228 |
+
with open(settings_file, "r", encoding="utf8") as file:
|
229 |
+
settings = json.load(file)
|
230 |
+
except Exception as e:
|
231 |
+
print(e, file=sys.stderr)
|
232 |
+
|
233 |
+
disabled_extensions = set(settings.get('disabled_extensions', []))
|
234 |
+
disable_all_extensions = settings.get('disable_all_extensions', 'none')
|
235 |
+
|
236 |
+
if disable_all_extensions != 'none':
|
237 |
+
return []
|
238 |
+
|
239 |
+
return [x for x in os.listdir(extensions_dir) if x not in disabled_extensions]
|
240 |
+
|
241 |
+
|
242 |
+
def run_extensions_installers(settings_file):
|
243 |
+
if not os.path.isdir(extensions_dir):
|
244 |
+
return
|
245 |
+
|
246 |
+
for dirname_extension in list_extensions(settings_file):
|
247 |
+
run_extension_installer(os.path.join(extensions_dir, dirname_extension))
|
248 |
+
|
249 |
+
|
250 |
+
def prepare_environment():
|
251 |
+
torch_command = os.environ.get('TORCH_COMMAND', "pip install torch==2.0.0 torchvision==0.15.1 --extra-index-url https://download.pytorch.org/whl/cu118")
|
252 |
+
requirements_file = os.environ.get('REQS_FILE', "requirements_versions.txt")
|
253 |
+
ngrok_start(ngrokTokenFile,7860,'',ngrok_use)
|
254 |
+
xformers_package = os.environ.get('XFORMERS_PACKAGE', 'xformers==0.0.17')
|
255 |
+
gfpgan_package = os.environ.get('GFPGAN_PACKAGE', "git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379")
|
256 |
+
clip_package = os.environ.get('CLIP_PACKAGE', "git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1")
|
257 |
+
openclip_package = os.environ.get('OPENCLIP_PACKAGE', "git+https://github.com/mlfoundations/open_clip.git@bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b")
|
258 |
+
|
259 |
+
stable_diffusion_repo = os.environ.get('STABLE_DIFFUSION_REPO', "https://github.com/Stability-AI/stablediffusion.git")
|
260 |
+
taming_transformers_repo = os.environ.get('TAMING_TRANSFORMERS_REPO', "https://github.com/CompVis/taming-transformers.git")
|
261 |
+
k_diffusion_repo = os.environ.get('K_DIFFUSION_REPO', 'https://github.com/crowsonkb/k-diffusion.git')
|
262 |
+
codeformer_repo = os.environ.get('CODEFORMER_REPO', 'https://github.com/sczhou/CodeFormer.git')
|
263 |
+
blip_repo = os.environ.get('BLIP_REPO', 'https://github.com/salesforce/BLIP.git')
|
264 |
+
|
265 |
+
stable_diffusion_commit_hash = os.environ.get('STABLE_DIFFUSION_COMMIT_HASH', "cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf")
|
266 |
+
taming_transformers_commit_hash = os.environ.get('TAMING_TRANSFORMERS_COMMIT_HASH', "24268930bf1dce879235a7fddd0b2355b84d7ea6")
|
267 |
+
k_diffusion_commit_hash = os.environ.get('K_DIFFUSION_COMMIT_HASH', "5b3af030dd83e0297272d861c19477735d0317ec")
|
268 |
+
codeformer_commit_hash = os.environ.get('CODEFORMER_COMMIT_HASH', "c5b4593074ba6214284d6acd5f1719b6c5d739af")
|
269 |
+
blip_commit_hash = os.environ.get('BLIP_COMMIT_HASH', "48211a1594f1321b00f14c9f7a5b4813144b2fb9")
|
270 |
+
|
271 |
+
if not args.skip_python_version_check:
|
272 |
+
check_python_version()
|
273 |
+
|
274 |
+
commit = commit_hash()
|
275 |
+
|
276 |
+
print(f"Python {sys.version}")
|
277 |
+
print(f"Commit hash: {commit}")
|
278 |
+
|
279 |
+
if args.reinstall_torch or not is_installed("torch") or not is_installed("torchvision"):
|
280 |
+
run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
|
281 |
+
|
282 |
+
if not args.skip_torch_cuda_test:
|
283 |
+
run_python("import torch; assert torch.cuda.is_available(), 'Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'")
|
284 |
+
|
285 |
+
if not is_installed("gfpgan"):
|
286 |
+
run_pip(f"install {gfpgan_package}", "gfpgan")
|
287 |
+
|
288 |
+
if not is_installed("clip"):
|
289 |
+
run_pip(f"install {clip_package}", "clip")
|
290 |
+
|
291 |
+
if not is_installed("open_clip"):
|
292 |
+
run_pip(f"install {openclip_package}", "open_clip")
|
293 |
+
|
294 |
+
if (not is_installed("xformers") or args.reinstall_xformers) and args.xformers:
|
295 |
+
if platform.system() == "Windows":
|
296 |
+
if platform.python_version().startswith("3.10"):
|
297 |
+
run_pip(f"install -U -I --no-deps {xformers_package}", "xformers", live=True)
|
298 |
+
else:
|
299 |
+
print("Installation of xformers is not supported in this version of Python.")
|
300 |
+
print("You can also check this and build manually: ")
|
301 |
+
if not is_installed("xformers"):
|
302 |
+
exit(0)
|
303 |
+
elif platform.system() == "Linux":
|
304 |
+
run_pip(f"install {xformers_package}", "xformers")
|
305 |
+
|
306 |
+
if not is_installed("pyngrok") and args.ngrok:
|
307 |
+
run_pip("install pyngrok", "ngrok")
|
308 |
+
|
309 |
+
os.makedirs(os.path.join(script_path, dir_repos), exist_ok=True)
|
310 |
+
|
311 |
+
git_clone(stable_diffusion_repo, repo_dir('stable-diffusion-stability-ai'), "Stable Diffusion", stable_diffusion_commit_hash)
|
312 |
+
git_clone(taming_transformers_repo, repo_dir('taming-transformers'), "Taming Transformers", taming_transformers_commit_hash)
|
313 |
+
git_clone(k_diffusion_repo, repo_dir('k-diffusion'), "K-diffusion", k_diffusion_commit_hash)
|
314 |
+
git_clone(codeformer_repo, repo_dir('CodeFormer'), "CodeFormer", codeformer_commit_hash)
|
315 |
+
git_clone(blip_repo, repo_dir('BLIP'), "BLIP", blip_commit_hash)
|
316 |
+
|
317 |
+
if not is_installed("lpips"):
|
318 |
+
run_pip(f"install -r \"{os.path.join(repo_dir('CodeFormer'), 'requirements.txt')}\"", "requirements for CodeFormer")
|
319 |
+
|
320 |
+
if not os.path.isfile(requirements_file):
|
321 |
+
requirements_file = os.path.join(script_path, requirements_file)
|
322 |
+
run_pip(f"install -r \"{requirements_file}\"", "requirements")
|
323 |
+
|
324 |
+
run_extensions_installers(settings_file=args.ui_settings_file)
|
325 |
+
|
326 |
+
if args.update_check:
|
327 |
+
version_check(commit)
|
328 |
+
|
329 |
+
if args.update_all_extensions:
|
330 |
+
git_pull_recursive(extensions_dir)
|
331 |
+
|
332 |
+
if "--exit" in sys.argv:
|
333 |
+
print("Exiting because of --exit argument")
|
334 |
+
exit(0)
|
335 |
+
|
336 |
+
if args.tests and not args.no_tests:
|
337 |
+
exitcode = tests(args.tests)
|
338 |
+
exit(exitcode)
|
339 |
+
|
340 |
+
|
341 |
+
def tests(test_dir):
|
342 |
+
if "--api" not in sys.argv:
|
343 |
+
sys.argv.append("--api")
|
344 |
+
if "--ckpt" not in sys.argv:
|
345 |
+
sys.argv.append("--ckpt")
|
346 |
+
sys.argv.append(os.path.join(script_path, "test/test_files/empty.pt"))
|
347 |
+
if "--skip-torch-cuda-test" not in sys.argv:
|
348 |
+
sys.argv.append("--skip-torch-cuda-test")
|
349 |
+
if "--disable-nan-check" not in sys.argv:
|
350 |
+
sys.argv.append("--disable-nan-check")
|
351 |
+
if "--no-tests" not in sys.argv:
|
352 |
+
sys.argv.append("--no-tests")
|
353 |
+
|
354 |
+
print(f"Launching startfk in another process for testing with arguments: {' '.join(sys.argv[1:])}")
|
355 |
+
|
356 |
+
os.environ['COMMANDLINE_ARGS'] = ""
|
357 |
+
with open(os.path.join(script_path, 'test/stdout.txt'), "w", encoding="utf8") as stdout, open(os.path.join(script_path, 'test/stderr.txt'), "w", encoding="utf8") as stderr:
|
358 |
+
proc = subprocess.Popen([sys.executable, *sys.argv], stdout=stdout, stderr=stderr)
|
359 |
+
|
360 |
+
import test.server_poll
|
361 |
+
exitcode = test.server_poll.run_tests(proc, test_dir)
|
362 |
+
|
363 |
+
print(f"Stopping startfk process with id {proc.pid}")
|
364 |
+
proc.kill()
|
365 |
+
return exitcode
|
366 |
+
|
367 |
+
|
368 |
+
def startfk():
|
369 |
+
print(f"Launching {'API server' if '--nostartfk' in sys.argv else 'startfk'} with arguments: {' '.join(sys.argv[1:])}")
|
370 |
+
import startfk
|
371 |
+
if '--nostartfk' in sys.argv:
|
372 |
+
startfk.api_only()
|
373 |
+
else:
|
374 |
+
startfk.startfk()
|
375 |
|
376 |
+
|
377 |
+
if __name__ == "__main__":
|
378 |
+
prepare_environment()
|
379 |
+
startfk()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|