Update v2_3.py
Browse files
v2_3.py
CHANGED
|
@@ -189,38 +189,29 @@ for repo_url, destination in extensions_to_clone:
|
|
| 189 |
run_git_clone(repo_url, destination)
|
| 190 |
|
| 191 |
print ("修改启动文件...")
|
| 192 |
-
#
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
content =
|
| 196 |
-
|
| 197 |
-
content =
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
#
|
| 210 |
-
content =
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
# 第三个命令:将列表中添加元素
|
| 216 |
-
shared_file_path = "/bushu/ui/modules/shared.py"
|
| 217 |
-
with open(shared_file_path, 'r') as file:
|
| 218 |
-
content = file.read()
|
| 219 |
-
|
| 220 |
-
content = re.sub(r'\["sd_model_checkpoint"\]', '["sd_model_checkpoint","sd_vae","CLIP_stop_at_last_layers"]', content)
|
| 221 |
-
|
| 222 |
-
with open(shared_file_path, 'w') as file:
|
| 223 |
-
file.write(content)
|
| 224 |
|
| 225 |
|
| 226 |
|
|
@@ -305,35 +296,30 @@ if T2I_:
|
|
| 305 |
|
| 306 |
|
| 307 |
print ("修改启动文件...")
|
| 308 |
-
#
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
content =
|
| 312 |
-
|
| 313 |
-
content =
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
content = file.read()
|
| 332 |
-
|
| 333 |
-
content = re.sub(r'\["sd_model_checkpoint"\]', '["sd_model_checkpoint","sd_vae","CLIP_stop_at_last_layers"]', content)
|
| 334 |
|
| 335 |
-
with open(shared_file_path, 'w') as file:
|
| 336 |
-
file.write(content)
|
| 337 |
|
| 338 |
|
| 339 |
|
|
|
|
| 189 |
run_git_clone(repo_url, destination)
|
| 190 |
|
| 191 |
print ("修改启动文件...")
|
| 192 |
+
# 打开launch.py文件
|
| 193 |
+
with open("/content/ui/launch.py", "r+") as f:
|
| 194 |
+
# 读取文件内容
|
| 195 |
+
content = f.read()
|
| 196 |
+
# 在from modules import launch_utils后面插入import os
|
| 197 |
+
content = content.replace("from modules import launch_utils", "from modules import launch_utils\nimport os")
|
| 198 |
+
# 在prepare_environment()后面插入os.system命令
|
| 199 |
+
content = content.replace("prepare_environment()", "prepare_environment()\n os.system(f\"\"\"sed -i -e ''\"s/stable/dict()))/dict())).cuda()/g\"'' /content/ui/repositories/diffusion-stability-stable/ldm/util.py\"\"\")")
|
| 200 |
+
# 重写文件内容
|
| 201 |
+
f.seek(0)
|
| 202 |
+
f.write(content)
|
| 203 |
+
f.truncate()
|
| 204 |
+
|
| 205 |
+
# 打开shared.py文件
|
| 206 |
+
with open("/content/ui/modules/shared.py", "r+") as f:
|
| 207 |
+
# 读取文件内容
|
| 208 |
+
content = f.read()
|
| 209 |
+
# 替换["sd_model_checkpoint"]为["sd_model_checkpoint","sd_vae","CLIP_stop_at_last_layers"]
|
| 210 |
+
content = content.replace('["sd_model_checkpoint"]', '["sd_model_checkpoint","sd_vae","CLIP_stop_at_last_layers"]')
|
| 211 |
+
# 重写文件内容
|
| 212 |
+
f.seek(0)
|
| 213 |
+
f.write(content)
|
| 214 |
+
f.truncate()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
|
| 216 |
|
| 217 |
|
|
|
|
| 296 |
|
| 297 |
|
| 298 |
print ("修改启动文件...")
|
| 299 |
+
# 打开launch.py文件
|
| 300 |
+
with open("/content/ui/launch.py", "r+") as f:
|
| 301 |
+
# 读取文件内容
|
| 302 |
+
content = f.read()
|
| 303 |
+
# 在from modules import launch_utils后面插入import os
|
| 304 |
+
content = content.replace("from modules import launch_utils", "from modules import launch_utils\nimport os")
|
| 305 |
+
# 在prepare_environment()后面插入os.system命令
|
| 306 |
+
content = content.replace("prepare_environment()", "prepare_environment()\n os.system(f\"\"\"sed -i -e ''\"s/dict()))/dict())).cuda()/g\"'' /content/ui/repositories/stable-diffusion-stability-ai/ldm/util.py\"\"\")")
|
| 307 |
+
# 重写文件内容
|
| 308 |
+
f.seek(0)
|
| 309 |
+
f.write(content)
|
| 310 |
+
f.truncate()
|
| 311 |
+
|
| 312 |
+
# 打开shared.py文件
|
| 313 |
+
with open("/content/ui/modules/shared.py", "r+") as f:
|
| 314 |
+
# 读取文件内容
|
| 315 |
+
content = f.read()
|
| 316 |
+
# 替换["sd_model_checkpoint"]为["sd_model_checkpoint","sd_vae","CLIP_stop_at_last_layers"]
|
| 317 |
+
content = content.replace('["sd_model_checkpoint"]', '["sd_model_checkpoint","sd_vae","CLIP_stop_at_last_layers"]')
|
| 318 |
+
# 重写文件内容
|
| 319 |
+
f.seek(0)
|
| 320 |
+
f.write(content)
|
| 321 |
+
f.truncate()
|
|
|
|
|
|
|
|
|
|
| 322 |
|
|
|
|
|
|
|
| 323 |
|
| 324 |
|
| 325 |
|