BBrother commited on
Commit
29e7157
1 Parent(s): f463731

Update v2_3.py

Browse files
Files changed (1) hide show
  1. v2_3.py +65 -77
v2_3.py CHANGED
@@ -1,6 +1,6 @@
1
  # -*- coding: utf-8 -*-
2
 
3
- """“SD_CLSA_web{t}_colab_ipynb” 修复V2.2.ipynb
4
 
5
  Automatically generated by Colaboratory.
6
 
@@ -11,7 +11,7 @@ Original file is located at
11
 
12
  # 使用说明:
13
 
14
- * 代码基于https://github.com/{ca}/【将此括号自行更换成"s*****-d********-web{t}】内容进行了修改调整
15
  * 由于官方对免费用户限制,修改代码绕开运行警告
16
  * Pro用户同样可用
17
  * Colab云免费空间为50G,若一些插件或者模型不需要,可以注释或者删除
@@ -34,34 +34,33 @@ Original file is located at
34
  手动将所有的括号换成指定的内容:
35
  (s)=s t a b l e
36
  (d)=d i f f u s i o n
37
- 1. deforum-for-automatic1111-web{t}: 这是一个用于自动化web界面的插件,它可以让您在网页上创建和管理您的项目。
38
- 2. (s)-(d)-Web{t}-Civitai-Helper: 这是一个用于稳定扩散web界面的插件,它可以帮助您使用Civitai平台进行人工智能开发。
39
  3. sd-web-controlnet: 这是一个用于sd-web的插件,它可以让您控制和监控您的网络状态。
40
  4. openpose-editor: 这是一个用于编辑人体姿态的插件,它可以让您在web界面上对人体姿态进行修改和优化。
41
  5. sd-web-depth-lib: 这是一个用于sd-web的插件,它可以让您使用深度学习库进行图像处理。
42
- 6. (s)-(d)-web{t}-huggingface: 这是一个用于稳定扩散web界面的插件,它可以让您使用huggingface平台进行自然语言处理。
43
  7. sd-web-additional-networks: 这是一个用于sd-web的插件,它可以让您使用额外的网络模型进行图像处理。
44
  8. posex: 这是一个用于生成人体姿态的插件,它可以让您在web界面上创建和编辑人体姿态。
45
  9. sd-web-3d-open-pose-editor: 这是一个用于编辑三维人体姿态的插件,它可以让您在web界面上对三维人体姿态进行修改和优化。
46
  10. sd-web-t'u'n'n'e'l's: 这是一个用于sd-web的插件,它可以让您使用隧道技术进行网络连接。
47
- 11. batchlinks-web{t}: 这是一个用于批量下载链接的插件,它可以让您在web界面上输入和管理链接。
48
- 12. (s)-(d)-web{t}-catppuccin: 这是一个用于稳定扩散web界面的插件,它可以让您使用catppuccin主题美化您的界面。
49
- 13. (s)-(d)-web{t}-rembg: 这是一个用于稳定扩散web界面的插件,它可以让您使用rembg工具去除图像背景。
50
- 14. (s)-(d)-web{t}-two-shot: 这是一个用于稳定扩散web界面的插件,它可以让您使用two-shot技术生成图像。
51
  15. sd-web-aspect-ratio-helper: 这是一个用于sd-web的插件,它可以帮助您调整图像的纵横比。
52
  16. adetailer: 这是一个用于增强图像细节的插件,它可以让您在web界面上对图像进行放大和清晰化。
53
  17. sd-dynamic-thresholding: 这是一个用于sd-web的插件,它可以让您使用动态阈值法进行图像分割。
54
  18. sd-dynamic-prompts: 这是一个用于sd-web的插件,它可以让您使用动态提示法生成图像。
55
- 19. (s)-(d)-web{t}-wildcards: 这是一个用于稳定扩散web界面的插件,它可以让您使用通配符法生成图像。
56
  20. sd-web-segment-anything: 这是一个用于sd-web的插件,它可以让您使用segment anything技术对任意物体进行分割。
57
- 21. (s)-(d)-web{t}-localization-zh_CN: 这是一个用于稳定扩散web界面的插件,它可以让您使用中文语言进行界面操作。
58
  22. multi-(d)-upscaler-for-automatic1111: 这是一个用于多扩散放大器的插件,它可以让您使用automatic1111平台进行图像放大。
59
  23. sd-web-prompt-all-in-one: 这是一个用于sd-web的插件,它可以让您使用一体化提示法生成图像。
60
 
61
  # 环境安装及运行
62
  """
63
 
64
-
65
  import binascii
66
  import os
67
  import subprocess
@@ -70,7 +69,6 @@ import fileinput
70
  import requests
71
  import datetime
72
 
73
-
74
  # 初始化变量
75
  a = ""
76
  b = ""
@@ -99,16 +97,6 @@ current_time = datetime.datetime.now()
99
  t = f"{current_time.hour:02d}_{current_time.minute:02d}"
100
 
101
 
102
- # 创建文件名随机的文件夹
103
- time_command = f"mkdir -p /bushu/{t}"
104
-
105
- try:
106
- subprocess.run(time_command, shell=True, check=True)
107
- print(f"成功创建目录:/bushu/{t}")
108
- except subprocess.CalledProcessError as e:
109
- print(f"创建目录失败:{e}")
110
-
111
-
112
 
113
  # %cd /bushu
114
  # %env TF_CPP_MIN_LOG_LEVEL=1
@@ -126,15 +114,15 @@ subprocess.run(["apt", "-y", "install", "-qq", "aria2"])
126
  subprocess.run(["pip", "install", "-q", "xformers==0.0.20", "triton==2.0.0", "-U"])
127
 
128
  # 使用subprocess运行git clone命令
129
- subprocess.run(["git", "clone", "-b", "v2.5", f"https://github.com/{ca}/{st}", "/bushu/{t}"])
130
- subprocess.run(["git", "clone", "https://huggingface.co/embed/negative", "/bushu/{t}/embeddings/negative"])
131
- subprocess.run(["git", "clone", "https://huggingface.co/embed/lora", "/bushu/{t}/models/Lora/positive"])
132
 
133
  # 使用subprocess运行mkdir命令
134
- subprocess.run(["mkdir", "-p", "/bushu/{t}/models/ESRGAN"])
135
 
136
  # 使用subprocess运行wget命令
137
- subprocess.run(["wget", "https://huggingface.co/embed/upscale/resolve/main/4x-UltraSharp.pth", "-O", "/bushu/{t}/models/ESRGAN/4x-UltraSharp.pth"])
138
 
139
 
140
 
@@ -142,12 +130,12 @@ subprocess.run(["wget", "https://huggingface.co/embed/upscale/resolve/main/4x-Ul
142
  def run_git_clone(repo_url, destination):
143
  subprocess.run(["git", "clone", repo_url, destination])
144
 
145
- extensions_path = "/bushu/{t}/extensions"
146
 
147
  extensions_to_clone = [
148
  (f"https://github.com/deforum-art/deforum-for-automatic1111-{w}", f"{extensions_path}/deforum-for-automatic1111-{w}"),
149
  (f"https://github.com/deforum-art/sd-{w}-deforum", f"{extensions_path}/sd-{w}-deforum"),
150
- (f"https://github.com/butaixianran/Stable-Diffusion-Web{t}-Civitai-Helper", f"{extensions_path}/Stable-Diffusion-Web{t}-Civitai-Helper"),
151
  (f"https://github.com/Mikubill/{c}-{w}-controlnet", f"{extensions_path}/{c}-{w}-controlnet"),
152
  (f"https://github.com/fkunn1326/openpose-editor", f"{extensions_path}/openpose-editor"),
153
  (f"https://github.com/{ca}/{a}-{d}-{w}-huggingface", f"{extensions_path}/{a}-{d}-{w}-huggingface"),
@@ -176,9 +164,9 @@ for repo_url, destination in extensions_to_clone:
176
 
177
 
178
  # 定义要操作的文件路径
179
- launch_py_path = "/bushu/{t}/launch.py"
180
- util_py_path = "/bushu/{t}/repositories/diffusion-stability-stable/ldm/util.py"
181
- shared_py_path = "/bushu/{t}/modules/shared.py"
182
 
183
  # 使用fileinput模块编辑launch.py文件
184
  with fileinput.FileInput(launch_py_path, inplace=True, backup=".bak") as file:
@@ -190,7 +178,7 @@ with fileinput.FileInput(launch_py_path, inplace=True, backup=".bak") as file:
190
  # 在prepare_environment()函数后插入os.system命令
191
  elif "prepare_environment()" in line:
192
  print(line, end='')
193
- print(' os.system(f"sed -i -e \'s/stable/dict()))/dict())).cuda()/g\' /bushu/{t}/repositories/diffusion-stability-stable/ldm/util.py")')
194
  # 替换指定文本
195
  else:
196
  print(line, end='')
@@ -238,7 +226,7 @@ T2I_ = True
238
 
239
  # CONTROLNET
240
  if CONTROLNET_:
241
- controlnet_directory = "/bushu/{t}/extensions/control/models"
242
  create_directory(controlnet_directory)
243
 
244
  urls_and_outputs = [
@@ -252,7 +240,7 @@ if CONTROLNET_:
252
 
253
  # T2I
254
  if T2I_:
255
- t2i_directory = "/bushu/{t}/extensions/control/models"
256
  create_directory(t2i_directory)
257
 
258
  urls_and_outputs = [
@@ -268,9 +256,9 @@ import fileinput
268
  import os
269
 
270
  # 定义要操作的文件路径
271
- launch_py_path = "/bushu/{t}/launch.py"
272
- util_py_path = "/bushu/{t}/repositories/stable-diffusion-stability-ai/ldm/util.py"
273
- shared_py_path = "/bushu/{t}/modules/shared.py"
274
 
275
  # 更新相关的sed命令
276
  sed_command_1 = 'import os'
@@ -309,7 +297,7 @@ for path in [launch_py_path + '.bak', shared_py_path + '.bak']:
309
  # 下载任务1
310
  CS_download_task1 = False
311
  CS_url1 = "https://civitai.com/api/download/models/17701"
312
- CS_destination_folder1 = f"/bushu/{t}/models/Stable-diffusion"
313
  CS_filename1 = "anypastelAnythingV45_anypastelAnythingV45.safetensors"
314
  CS_target1 = f"{CS_destination_folder1}/{CS_filename1}"
315
 
@@ -322,7 +310,7 @@ if CS_download_task1:
322
  # 下载任务2
323
  CS_download_task2 = False
324
  CS_url2 = "https://civitai.com/api/download/models/26633?type=Model&format=PickleTensor&size=full&fp=fp16"
325
- CS_destination_folder2 = f"/bushu/{t}/models/Stable-diffusion"
326
  CS_filename2 = "07CounterfeitV2503_10.ckpt"
327
  CS_target2 = f"{CS_destination_folder2}/{CS_filename2}"
328
 
@@ -335,7 +323,7 @@ if CS_download_task2:
335
  # 下载任务3
336
  CS_download_task3 = True
337
  CS_url3 = "https://civitai.com/api/download/models/90854"
338
- CS_destination_folder3 = f"/bushu/{t}/models/Stable-diffusion"
339
  CS_filename3 = "AnythingV5Ink.safetensors"
340
  CS_target3 = f"{CS_destination_folder3}/{CS_filename3}"
341
 
@@ -348,7 +336,7 @@ if CS_download_task3:
348
  # 下载任务4
349
  CS_download_task4 = False
350
  CS_url4 = "https://civitai.com/api/download/models/57618"
351
- CS_destination_folder4 = f"/bushu/{t}/models/Stable-diffusion"
352
  CS_filename4 = "CounterfeitV30_v30.safetensors"
353
  CS_target4 = f"{CS_destination_folder4}/{CS_filename4}"
354
 
@@ -361,7 +349,7 @@ if CS_download_task4:
361
  # 下载任务5
362
  CS_download_task5 = False
363
  CS_url5 = "https://civitai.com/api/download/models/1356"
364
- CS_destination_folder5 = f"/bushu/{t}/models/Stable-diffusion"
365
  CS_filename5 = "dreamlike10_10.ckpt"
366
  CS_target5 = f"{CS_destination_folder5}/{CS_filename5}"
367
 
@@ -374,7 +362,7 @@ if CS_download_task5:
374
  # 下载任务6
375
  CS_download_task6 = True
376
  CS_url6 = "https://civitai.com/api/download/models/17233"
377
- CS_destination_folder6 = f"/bushu/{t}/models/Stable-diffusion"
378
  CS_filename6 = "abyssorangemix3AOM3_aom3a1b.safetensors"
379
  CS_target6 = f"{CS_destination_folder6}/{CS_filename6}"
380
 
@@ -387,7 +375,7 @@ if CS_download_task6:
387
  # 下载任务7
388
  CS_download_task7 = False
389
  CS_url7 = ""
390
- CS_destination_folder7 = f"/bushu/{t}/models/Stable-diffusion"
391
  CS_filename7 = ""
392
  CS_target7 = f"{CS_destination_folder7}/{CS_filename7}"
393
 
@@ -400,7 +388,7 @@ if CS_download_task7:
400
  # 下载任务8
401
  CS_download_task8 = False
402
  CS_url8 = ""
403
- CS_destination_folder8 = f"/bushu/{t}/models/Stable-diffusion"
404
  CS_filename8 = ""
405
  CS_target8 = f"{CS_destination_folder8}/{CS_filename8}"
406
 
@@ -413,7 +401,7 @@ if CS_download_task8:
413
  # 下载任务9
414
  CS_download_task9 = False
415
  CS_url9 = ""
416
- CS_destination_folder9 = f"/bushu/{t}/models/Stable-diffusion"
417
  CS_filename9 = ""
418
  CS_target9 = f"{CS_destination_folder9}/{CS_filename9}"
419
 
@@ -426,7 +414,7 @@ if CS_download_task9:
426
  # 下载任务10
427
  CS_download_task10 = False
428
  CS_url10 = ""
429
- CS_destination_folder10 = f"/bushu/{t}/models/Stable-diffusion"
430
  CS_filename10 = ""
431
  CS_target10 = f"{CS_destination_folder10}/{CS_filename10}"
432
 
@@ -439,7 +427,7 @@ if CS_download_task10:
439
  # 下载任务11
440
  CS_download_task11 = False
441
  CS_url11 = ""
442
- CS_destination_folder11 = f"/bushu/{t}/models/Stable-diffusion"
443
  CS_filename11 = ""
444
  CS_target11 = f"{CS_destination_folder11}/{CS_filename11}"
445
 
@@ -452,7 +440,7 @@ if CS_download_task11:
452
  # 下载任务12
453
  CS_download_task12 = False
454
  CS_url12 = ""
455
- CS_destination_folder12 = f"/bushu/{t}/models/Stable-diffusion"
456
  CS_filename12 = ""
457
  CS_target12 = f"{CS_destination_folder12}/{CS_filename12}"
458
 
@@ -465,7 +453,7 @@ if CS_download_task12:
465
  # 下载任务13
466
  CS_download_task13 = False
467
  CS_url13 = ""
468
- CS_destination_folder13 = f"/bushu/{t}/models/Stable-diffusion"
469
  CS_filename13 = ""
470
  CS_target13 = f"{CS_destination_folder13}/{CS_filename13}"
471
 
@@ -481,7 +469,7 @@ if CS_download_task13:
481
  # Lora任务1
482
  Lora_download_task1 = True
483
  Lora_url1 = "https://civitai.com/api/download/models/64842"
484
- Lora_destination_folder1 = "/bushu/{t}/models/Lora"
485
  Lora_filename1 = "arona_puranalora_v1.safetensors"
486
  Lora_target1 = os.path.join(Lora_destination_folder1, Lora_filename1)
487
 
@@ -494,7 +482,7 @@ if Lora_download_task1:
494
  # Lora任务2
495
  Lora_download_task2 = False
496
  Lora_url2 = "https://liblibai-online.liblibai.ai/web/model/25e9f1fa5137b2517b46c0a07f068e7328d5bd28744255d476c40e3ce61abed4.safetensors?attname=Xian-T%E6%89%8B%E9%83%A8%E4%BF%AE%E5%A4%8Dlora%EF%BC%88%E4%B8%8D%E7%94%A8controlnet%E4%B9%9F%E4%B8%8D%E5%9D%8F%E6%89%8B%E4%BA%86%EF%BC%89_v3.0.safetensors"
497
- Lora_destination_folder2 = "/bushu/{t}/models/Lora"
498
  Lora_filename2 = "Xian-T\u624B\u90E8\u4FEE\u590Dlora\uFF08\u4E0D%E7%94%A8controlnet%E4%B4%9B%E4%B8%8D%E5%9D%8F%E6%89%8B%E4%BA%86\uFF09_v3.0.safetensors"
499
  Lora_target2 = os.path.join(Lora_destination_folder2, Lora_filename2)
500
 
@@ -507,7 +495,7 @@ if Lora_download_task2:
507
  # Lora任务3
508
  Lora_download_task3 = True
509
  Lora_url3 = "https://civitai.com/api/download/models/52900"
510
- Lora_destination_folder3 = "/bushu/{t}/models/Lora"
511
  Lora_filename3 = "cailaiarona-000007.safetensors"
512
  Lora_target3 = os.path.join(Lora_destination_folder3, Lora_filename3)
513
 
@@ -561,7 +549,7 @@ if Lora_download_task6:
561
  # VAE任务1
562
  VAE_download_task1 = True
563
  VAE_url1 = "https://civitai.com/api/download/models/25986"
564
- VAE_destination_folder1 = "/bushu/{t}/models/VAE"
565
  VAE_filename1 = "anypastelAnythingV45_anypastelAnythingV45.zip"
566
  VAE_target1 = f"{VAE_destination_folder1}/{VAE_filename1}"
567
 
@@ -573,7 +561,7 @@ if VAE_download_task1:
573
  # VAE任务2
574
  VAE_download_task2 = True
575
  VAE_url2 = "https://civitai.com/api/download/models/64133"
576
- VAE_destination_folder2 = "/bushu/{t}/models/VAE"
577
  VAE_filename2 = "counterfeit.pt"
578
  VAE_target2 = f"{VAE_destination_folder2}/{VAE_filename2}"
579
 
@@ -585,7 +573,7 @@ if VAE_download_task2:
585
  # VAE任务3
586
  VAE_download_task3 = True
587
  VAE_url3 = "https://civitai.com/api/download/models/80869?type=Model&format=Other"
588
- VAE_destination_folder3 = "/bushu/{t}/models/VAE"
589
  VAE_filename3 = "vaeFtMse840000Ema_v100.safetensors"
590
  VAE_target3 = f"{VAE_destination_folder3}/{VAE_filename3}"
591
 
@@ -597,7 +585,7 @@ if VAE_download_task3:
597
  # VAE任务4
598
  VAE_download_task4 = False
599
  VAE_url4 = "https://huggingface.co/admruul/anything-v3.0/resolve/main/Anything-V3.0.vae.pt"
600
- VAE_destination_folder4 = "/bushu/{t}/models/VAE"
601
  VAE_filename4 = "Anything-V3.0.pt"
602
  VAE_target4 = f"{VAE_destination_folder4}/{VAE_filename4}"
603
 
@@ -609,7 +597,7 @@ if VAE_download_task4:
609
  # VAE任务5
610
  VAE_download_task5 = True
611
  VAE_url5 = "https://civitai.com/api/download/models/131654?type=Model&format=SafeTensor"
612
- VAE_destination_folder5 = "/bushu/{t}/models/VAE"
613
  VAE_filename5 = "anythingKlF8Anime2VaeFtMse840000_klF8Anime2.safetensors"
614
  VAE_target5 = f"{VAE_destination_folder5}/{VAE_filename5}"
615
 
@@ -621,7 +609,7 @@ if VAE_download_task5:
621
  # VAE任务6
622
  VAE_download_task6 = True
623
  VAE_url6 = "https://civitai.com/api/download/models/88156?type=Model&format=Other"
624
- VAE_destination_folder6 = "/bushu/{t}/models/VAE"
625
  VAE_filename6 = "ClearVAE.2.3.pt"
626
  VAE_target6 = f"{VAE_destination_folder6}/{VAE_filename6}"
627
 
@@ -633,7 +621,7 @@ if VAE_download_task6:
633
  # VAE任务7
634
  VAE_download_task7 = True
635
  VAE_url7 = "https://civitai.com/api/download/models/121354?type=Model&format=Other"
636
- VAE_destination_folder7 = "/bushu/{t}/models/VAE"
637
  VAE_filename7 = "orangemix_v1.pt"
638
  VAE_target7 = f"{VAE_destination_folder7}/{VAE_filename7}"
639
 
@@ -645,7 +633,7 @@ if VAE_download_task7:
645
  # VAE任务8
646
  VAE_download_task8 = True
647
  VAE_url8 = "https://civitai.com/api/download/models/28569?type=Model&format=Other"
648
- VAE_destination_folder8 = "/bushu/{t}/models/VAE"
649
  VAE_filename8 = "klF8Anime2_klF8Anime2VAE.pt"
650
  VAE_target8 = f"{VAE_destination_folder8}/{VAE_filename8}"
651
 
@@ -657,7 +645,7 @@ if VAE_download_task8:
657
  # VAE任务9
658
  VAE_download_task9 = False
659
  VAE_url9 = ""
660
- VAE_destination_folder9 = "/bushu/{t}/models/VAE"
661
  VAE_filename9 = ""
662
  VAE_target9 = f"{VAE_destination_folder9}/{VAE_filename9}"
663
 
@@ -669,7 +657,7 @@ if VAE_download_task9:
669
  # VAE任务10
670
  VAE_download_task10 = False
671
  VAE_url10 = ""
672
- VAE_destination_folder10 = "/bushu/{t}/models/VAE"
673
  VAE_filename10 = ""
674
  VAE_target10 = f"{VAE_destination_folder10}/{VAE_filename10}"
675
 
@@ -681,7 +669,7 @@ if VAE_download_task10:
681
  # VAE任务11
682
  VAE_download_task11 = False
683
  VAE_url11 = ""
684
- VAE_destination_folder11 = "/bushu/{t}/models/VAE"
685
  VAE_filename11 = ""
686
  VAE_target11 = f"{VAE_destination_folder11}/{VAE_filename11}"
687
 
@@ -693,7 +681,7 @@ if VAE_download_task11:
693
  # VAE任务12
694
  VAE_download_task12 = False
695
  VAE_url12 = ""
696
- VAE_destination_folder12 = "/bushu/{t}/models/VAE"
697
  VAE_filename12 = ""
698
  VAE_target12 = f"{VAE_destination_folder12}/{VAE_filename12}"
699
 
@@ -705,7 +693,7 @@ if VAE_download_task12:
705
  # VAE任务13
706
  VAE_download_task13 = False
707
  VAE_url13 = ""
708
- VAE_destination_folder13 = "/bushu/{t}/models/VAE"
709
  VAE_filename13 = ""
710
  VAE_target13 = f"{VAE_destination_folder13}/{VAE_filename13}"
711
 
@@ -727,7 +715,7 @@ def download_file(url, destination_folder, filename):
727
  # _下载任务1_
728
  embeddings_download_task1 = True #@param {type:"boolean"}
729
  embeddings_url1 = "https://civitai.com/api/download/models/125849"
730
- embeddings_destination_folder1 = "/bushu/{t}/embeddings" #@ param {type:"string"}
731
  embeddings_filename1 = "bad-hands-5.pt"
732
  embeddings_target1 = f'{embeddings_destination_folder1}/{embeddings_filename1}'
733
 
@@ -737,7 +725,7 @@ if embeddings_download_task1:
737
  # _下载任务2_
738
  embeddings_download_task2 = False #@param {type:"boolean"}
739
  embeddings_url2 = ""
740
- embeddings_destination_folder2 = "/bushu/{t}/embeddings" #@ param {type:"string"}
741
  embeddings_filename2 = ""
742
  embeddings_target2 = f'{embeddings_destination_folder2}/{embeddings_filename2}'
743
 
@@ -747,7 +735,7 @@ if embeddings_download_task2:
747
  # _下载任务3_
748
  embeddings_download_task3 = False #@param {type:"boolean"}
749
  embeddings_url3 = ""
750
- embeddings_destination_folder3 = "/bushu/{t}/embeddings" #@ param {type:"string"}
751
  embeddings_filename3 = ""
752
  embeddings_target3 = f'{embeddings_destination_folder3}/{embeddings_filename3}'
753
 
@@ -757,7 +745,7 @@ if embeddings_download_task3:
757
  # _下载任务4_
758
  embeddings_download_task4 = False #@param {type:"boolean"}
759
  embeddings_url4 = ""
760
- embeddings_destination_folder4 = "/bushu/{t}/embeddings" #@ param {type:"string"}
761
  embeddings_filename4 = ""
762
  embeddings_target4 = f'{embeddings_destination_folder4}/{embeddings_filename4}'
763
 
@@ -767,7 +755,7 @@ if embeddings_download_task4:
767
  # _下载任务5_
768
  embeddings_download_task5 = False #@param {type:"boolean"}
769
  embeddings_url5 = ""
770
- embeddings_destination_folder5 = "/bushu/{t}/embeddings" #@ param {type:"string"}
771
  embeddings_filename5 = ""
772
  embeddings_target5 = f'{embeddings_destination_folder5}/{embeddings_filename5}'
773
 
@@ -804,11 +792,11 @@ d = binascii.unhexlify("646966667573696f6e").decode("ascii")
804
  w = binascii.unhexlify("7765627569").decode("ascii")
805
 
806
 
807
- # 切换到/bushu/{t}目录
808
- subprocess.run(["cd", "/bushu/{t}"], shell=True)
809
 
810
- # 安装req{t}rements.txt中的依赖项
811
- subprocess.run(["pip", "install", "-r", "/bushu/{t}/requirements.txt"])
812
 
813
 
814
 
 
1
  # -*- coding: utf-8 -*-
2
 
3
+ """“SD_CLSA_webui_colab_ipynb” 修复V2.2.ipynb
4
 
5
  Automatically generated by Colaboratory.
6
 
 
11
 
12
  # 使用说明:
13
 
14
+ * 代码基于https://github.com/{ca}/【将此括号自行更换成"s*****-d********-webui】内容进行了修改调整
15
  * 由于官方对免费用户限制,修改代码绕开运行警告
16
  * Pro用户同样可用
17
  * Colab云免费空间为50G,若一些插件或者模型不需要,可以注释或者删除
 
34
  手动将所有的括号换成指定的内容:
35
  (s)=s t a b l e
36
  (d)=d i f f u s i o n
37
+ 1. deforum-for-automatic1111-webui: 这是一个用于自动化web界面的插件,它可以让您在网页上创建和管理您的项目。
38
+ 2. (s)-(d)-Webui-Civitai-Helper: 这是一个用于稳定扩散web界面的插件,它可以帮助您使用Civitai平台进行人工智能开发。
39
  3. sd-web-controlnet: 这是一个用于sd-web的插件,它可以让您控制和监控您的网络状态。
40
  4. openpose-editor: 这是一个用于编辑人体姿态的插件,它可以让您在web界面上对人体姿态进行修改和优化。
41
  5. sd-web-depth-lib: 这是一个用于sd-web的插件,它可以让您使用深度学习库进行图像处理。
42
+ 6. (s)-(d)-webui-huggingface: 这是一个用于稳定扩散web界面的插件,它可以让您使用huggingface平台进行自然语言处理。
43
  7. sd-web-additional-networks: 这是一个用于sd-web的插件,它可以让您使用额外的网络模型进行图像处理。
44
  8. posex: 这是一个用于生成人体姿态的插件,它可以让您在web界面上创建和编辑人体姿态。
45
  9. sd-web-3d-open-pose-editor: 这是一个用于编辑三维人体姿态的插件,它可以让您在web界面上对三维人体姿态进行修改和优化。
46
  10. sd-web-t'u'n'n'e'l's: 这是一个用于sd-web的插件,它可以让您使用隧道技术进行网络连接。
47
+ 11. batchlinks-webui: 这是一个用于批量下载链接的插件,它可以让您在web界面上输入和管理链接。
48
+ 12. (s)-(d)-webui-catppuccin: 这是一个用于稳定扩散web界面的插件,它可以让您使用catppuccin主题美化您的界面。
49
+ 13. (s)-(d)-webui-rembg: 这是一个用于稳定扩散web界面的插件,它可以让您使用rembg工具去除图像背景。
50
+ 14. (s)-(d)-webui-two-shot: 这是一个用于稳定扩散web界面的插件,它可以让您使用two-shot技术生成图像。
51
  15. sd-web-aspect-ratio-helper: 这是一个用于sd-web的插件,它可以帮助您调整图像的纵横比。
52
  16. adetailer: 这是一个用于增强图像细节的插件,它可以让您在web界面上对图像进行放大和清晰化。
53
  17. sd-dynamic-thresholding: 这是一个用于sd-web的插件,它可以让您使用动态阈值法进行图像分割。
54
  18. sd-dynamic-prompts: 这是一个用于sd-web的插件,它可以让您使用动态提示法生成图像。
55
+ 19. (s)-(d)-webui-wildcards: 这是一个用于稳定扩散web界面的插件,它可以让您使用通配符法生成图像。
56
  20. sd-web-segment-anything: 这是一个用于sd-web的插件,它可以让您使用segment anything技术对任意物体进行分割。
57
+ 21. (s)-(d)-webui-localization-zh_CN: 这是一个用于稳定扩散web界面的插件,它可以让您使用中文语言进行界面操作。
58
  22. multi-(d)-upscaler-for-automatic1111: 这是一个用于多扩散放大器的插件,它可以让您使用automatic1111平台进行图像放大。
59
  23. sd-web-prompt-all-in-one: 这是一个用于sd-web的插件,它可以让您使用一体化提示法生成图像。
60
 
61
  # 环境安装及运行
62
  """
63
 
 
64
  import binascii
65
  import os
66
  import subprocess
 
69
  import requests
70
  import datetime
71
 
 
72
  # 初始化变量
73
  a = ""
74
  b = ""
 
97
  t = f"{current_time.hour:02d}_{current_time.minute:02d}"
98
 
99
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  # %cd /bushu
102
  # %env TF_CPP_MIN_LOG_LEVEL=1
 
114
  subprocess.run(["pip", "install", "-q", "xformers==0.0.20", "triton==2.0.0", "-U"])
115
 
116
  # 使用subprocess运行git clone命令
117
+ subprocess.run(["git", "clone", "-b", "v2.5", f"https://github.com/{ca}/{st}", "/bushu/ui"])
118
+ subprocess.run(["git", "clone", "https://huggingface.co/embed/negative", "/bushu/ui/embeddings/negative"])
119
+ subprocess.run(["git", "clone", "https://huggingface.co/embed/lora", "/bushu/ui/models/Lora/positive"])
120
 
121
  # 使用subprocess运行mkdir命令
122
+ subprocess.run(["mkdir", "-p", "/bushu/ui/models/ESRGAN"])
123
 
124
  # 使用subprocess运行wget命令
125
+ subprocess.run(["wget", "https://huggingface.co/embed/upscale/resolve/main/4x-UltraSharp.pth", "-O", "/bushu/ui/models/ESRGAN/4x-UltraSharp.pth"])
126
 
127
 
128
 
 
130
  def run_git_clone(repo_url, destination):
131
  subprocess.run(["git", "clone", repo_url, destination])
132
 
133
+ extensions_path = "/bushu/ui/extensions"
134
 
135
  extensions_to_clone = [
136
  (f"https://github.com/deforum-art/deforum-for-automatic1111-{w}", f"{extensions_path}/deforum-for-automatic1111-{w}"),
137
  (f"https://github.com/deforum-art/sd-{w}-deforum", f"{extensions_path}/sd-{w}-deforum"),
138
+ (f"https://github.com/butaixianran/Stable-Diffusion-Webui-Civitai-Helper", f"{extensions_path}/Stable-Diffusion-Webui-Civitai-Helper"),
139
  (f"https://github.com/Mikubill/{c}-{w}-controlnet", f"{extensions_path}/{c}-{w}-controlnet"),
140
  (f"https://github.com/fkunn1326/openpose-editor", f"{extensions_path}/openpose-editor"),
141
  (f"https://github.com/{ca}/{a}-{d}-{w}-huggingface", f"{extensions_path}/{a}-{d}-{w}-huggingface"),
 
164
 
165
 
166
  # 定义要操作的文件路径
167
+ launch_py_path = "/bushu/ui/launch.py"
168
+ util_py_path = "/bushu/ui/repositories/diffusion-stability-stable/ldm/util.py"
169
+ shared_py_path = "/bushu/ui/modules/shared.py"
170
 
171
  # 使用fileinput模块编辑launch.py文件
172
  with fileinput.FileInput(launch_py_path, inplace=True, backup=".bak") as file:
 
178
  # 在prepare_environment()函数后插入os.system命令
179
  elif "prepare_environment()" in line:
180
  print(line, end='')
181
+ print(' os.system(f"sed -i -e \'s/stable/dict()))/dict())).cuda()/g\' /bushu/ui/repositories/diffusion-stability-stable/ldm/util.py")')
182
  # 替换指定文本
183
  else:
184
  print(line, end='')
 
226
 
227
  # CONTROLNET
228
  if CONTROLNET_:
229
+ controlnet_directory = "/bushu/ui/extensions/control/models"
230
  create_directory(controlnet_directory)
231
 
232
  urls_and_outputs = [
 
240
 
241
  # T2I
242
  if T2I_:
243
+ t2i_directory = "/bushu/ui/extensions/control/models"
244
  create_directory(t2i_directory)
245
 
246
  urls_and_outputs = [
 
256
  import os
257
 
258
  # 定义要操作的文件路径
259
+ launch_py_path = "/bushu/ui/launch.py"
260
+ util_py_path = "/bushu/ui/repositories/stable-diffusion-stability-ai/ldm/util.py"
261
+ shared_py_path = "/bushu/ui/modules/shared.py"
262
 
263
  # 更新相关的sed命令
264
  sed_command_1 = 'import os'
 
297
  # 下载任务1
298
  CS_download_task1 = False
299
  CS_url1 = "https://civitai.com/api/download/models/17701"
300
+ CS_destination_folder1 = f"/bushu/ui/models/Stable-diffusion"
301
  CS_filename1 = "anypastelAnythingV45_anypastelAnythingV45.safetensors"
302
  CS_target1 = f"{CS_destination_folder1}/{CS_filename1}"
303
 
 
310
  # 下载任务2
311
  CS_download_task2 = False
312
  CS_url2 = "https://civitai.com/api/download/models/26633?type=Model&format=PickleTensor&size=full&fp=fp16"
313
+ CS_destination_folder2 = f"/bushu/ui/models/Stable-diffusion"
314
  CS_filename2 = "07CounterfeitV2503_10.ckpt"
315
  CS_target2 = f"{CS_destination_folder2}/{CS_filename2}"
316
 
 
323
  # 下载任务3
324
  CS_download_task3 = True
325
  CS_url3 = "https://civitai.com/api/download/models/90854"
326
+ CS_destination_folder3 = f"/bushu/ui/models/Stable-diffusion"
327
  CS_filename3 = "AnythingV5Ink.safetensors"
328
  CS_target3 = f"{CS_destination_folder3}/{CS_filename3}"
329
 
 
336
  # 下载任务4
337
  CS_download_task4 = False
338
  CS_url4 = "https://civitai.com/api/download/models/57618"
339
+ CS_destination_folder4 = f"/bushu/ui/models/Stable-diffusion"
340
  CS_filename4 = "CounterfeitV30_v30.safetensors"
341
  CS_target4 = f"{CS_destination_folder4}/{CS_filename4}"
342
 
 
349
  # 下载任务5
350
  CS_download_task5 = False
351
  CS_url5 = "https://civitai.com/api/download/models/1356"
352
+ CS_destination_folder5 = f"/bushu/ui/models/Stable-diffusion"
353
  CS_filename5 = "dreamlike10_10.ckpt"
354
  CS_target5 = f"{CS_destination_folder5}/{CS_filename5}"
355
 
 
362
  # 下载任务6
363
  CS_download_task6 = True
364
  CS_url6 = "https://civitai.com/api/download/models/17233"
365
+ CS_destination_folder6 = f"/bushu/ui/models/Stable-diffusion"
366
  CS_filename6 = "abyssorangemix3AOM3_aom3a1b.safetensors"
367
  CS_target6 = f"{CS_destination_folder6}/{CS_filename6}"
368
 
 
375
  # 下载任务7
376
  CS_download_task7 = False
377
  CS_url7 = ""
378
+ CS_destination_folder7 = f"/bushu/ui/models/Stable-diffusion"
379
  CS_filename7 = ""
380
  CS_target7 = f"{CS_destination_folder7}/{CS_filename7}"
381
 
 
388
  # 下载任务8
389
  CS_download_task8 = False
390
  CS_url8 = ""
391
+ CS_destination_folder8 = f"/bushu/ui/models/Stable-diffusion"
392
  CS_filename8 = ""
393
  CS_target8 = f"{CS_destination_folder8}/{CS_filename8}"
394
 
 
401
  # 下载任务9
402
  CS_download_task9 = False
403
  CS_url9 = ""
404
+ CS_destination_folder9 = f"/bushu/ui/models/Stable-diffusion"
405
  CS_filename9 = ""
406
  CS_target9 = f"{CS_destination_folder9}/{CS_filename9}"
407
 
 
414
  # 下载任务10
415
  CS_download_task10 = False
416
  CS_url10 = ""
417
+ CS_destination_folder10 = f"/bushu/ui/models/Stable-diffusion"
418
  CS_filename10 = ""
419
  CS_target10 = f"{CS_destination_folder10}/{CS_filename10}"
420
 
 
427
  # 下载任务11
428
  CS_download_task11 = False
429
  CS_url11 = ""
430
+ CS_destination_folder11 = f"/bushu/ui/models/Stable-diffusion"
431
  CS_filename11 = ""
432
  CS_target11 = f"{CS_destination_folder11}/{CS_filename11}"
433
 
 
440
  # 下载任务12
441
  CS_download_task12 = False
442
  CS_url12 = ""
443
+ CS_destination_folder12 = f"/bushu/ui/models/Stable-diffusion"
444
  CS_filename12 = ""
445
  CS_target12 = f"{CS_destination_folder12}/{CS_filename12}"
446
 
 
453
  # 下载任务13
454
  CS_download_task13 = False
455
  CS_url13 = ""
456
+ CS_destination_folder13 = f"/bushu/ui/models/Stable-diffusion"
457
  CS_filename13 = ""
458
  CS_target13 = f"{CS_destination_folder13}/{CS_filename13}"
459
 
 
469
  # Lora任务1
470
  Lora_download_task1 = True
471
  Lora_url1 = "https://civitai.com/api/download/models/64842"
472
+ Lora_destination_folder1 = "/bushu/ui/models/Lora"
473
  Lora_filename1 = "arona_puranalora_v1.safetensors"
474
  Lora_target1 = os.path.join(Lora_destination_folder1, Lora_filename1)
475
 
 
482
  # Lora任务2
483
  Lora_download_task2 = False
484
  Lora_url2 = "https://liblibai-online.liblibai.ai/web/model/25e9f1fa5137b2517b46c0a07f068e7328d5bd28744255d476c40e3ce61abed4.safetensors?attname=Xian-T%E6%89%8B%E9%83%A8%E4%BF%AE%E5%A4%8Dlora%EF%BC%88%E4%B8%8D%E7%94%A8controlnet%E4%B9%9F%E4%B8%8D%E5%9D%8F%E6%89%8B%E4%BA%86%EF%BC%89_v3.0.safetensors"
485
+ Lora_destination_folder2 = "/bushu/ui/models/Lora"
486
  Lora_filename2 = "Xian-T\u624B\u90E8\u4FEE\u590Dlora\uFF08\u4E0D%E7%94%A8controlnet%E4%B4%9B%E4%B8%8D%E5%9D%8F%E6%89%8B%E4%BA%86\uFF09_v3.0.safetensors"
487
  Lora_target2 = os.path.join(Lora_destination_folder2, Lora_filename2)
488
 
 
495
  # Lora任务3
496
  Lora_download_task3 = True
497
  Lora_url3 = "https://civitai.com/api/download/models/52900"
498
+ Lora_destination_folder3 = "/bushu/ui/models/Lora"
499
  Lora_filename3 = "cailaiarona-000007.safetensors"
500
  Lora_target3 = os.path.join(Lora_destination_folder3, Lora_filename3)
501
 
 
549
  # VAE任务1
550
  VAE_download_task1 = True
551
  VAE_url1 = "https://civitai.com/api/download/models/25986"
552
+ VAE_destination_folder1 = "/bushu/ui/models/VAE"
553
  VAE_filename1 = "anypastelAnythingV45_anypastelAnythingV45.zip"
554
  VAE_target1 = f"{VAE_destination_folder1}/{VAE_filename1}"
555
 
 
561
  # VAE任务2
562
  VAE_download_task2 = True
563
  VAE_url2 = "https://civitai.com/api/download/models/64133"
564
+ VAE_destination_folder2 = "/bushu/ui/models/VAE"
565
  VAE_filename2 = "counterfeit.pt"
566
  VAE_target2 = f"{VAE_destination_folder2}/{VAE_filename2}"
567
 
 
573
  # VAE任务3
574
  VAE_download_task3 = True
575
  VAE_url3 = "https://civitai.com/api/download/models/80869?type=Model&format=Other"
576
+ VAE_destination_folder3 = "/bushu/ui/models/VAE"
577
  VAE_filename3 = "vaeFtMse840000Ema_v100.safetensors"
578
  VAE_target3 = f"{VAE_destination_folder3}/{VAE_filename3}"
579
 
 
585
  # VAE任务4
586
  VAE_download_task4 = False
587
  VAE_url4 = "https://huggingface.co/admruul/anything-v3.0/resolve/main/Anything-V3.0.vae.pt"
588
+ VAE_destination_folder4 = "/bushu/ui/models/VAE"
589
  VAE_filename4 = "Anything-V3.0.pt"
590
  VAE_target4 = f"{VAE_destination_folder4}/{VAE_filename4}"
591
 
 
597
  # VAE任务5
598
  VAE_download_task5 = True
599
  VAE_url5 = "https://civitai.com/api/download/models/131654?type=Model&format=SafeTensor"
600
+ VAE_destination_folder5 = "/bushu/ui/models/VAE"
601
  VAE_filename5 = "anythingKlF8Anime2VaeFtMse840000_klF8Anime2.safetensors"
602
  VAE_target5 = f"{VAE_destination_folder5}/{VAE_filename5}"
603
 
 
609
  # VAE任务6
610
  VAE_download_task6 = True
611
  VAE_url6 = "https://civitai.com/api/download/models/88156?type=Model&format=Other"
612
+ VAE_destination_folder6 = "/bushu/ui/models/VAE"
613
  VAE_filename6 = "ClearVAE.2.3.pt"
614
  VAE_target6 = f"{VAE_destination_folder6}/{VAE_filename6}"
615
 
 
621
  # VAE任务7
622
  VAE_download_task7 = True
623
  VAE_url7 = "https://civitai.com/api/download/models/121354?type=Model&format=Other"
624
+ VAE_destination_folder7 = "/bushu/ui/models/VAE"
625
  VAE_filename7 = "orangemix_v1.pt"
626
  VAE_target7 = f"{VAE_destination_folder7}/{VAE_filename7}"
627
 
 
633
  # VAE任务8
634
  VAE_download_task8 = True
635
  VAE_url8 = "https://civitai.com/api/download/models/28569?type=Model&format=Other"
636
+ VAE_destination_folder8 = "/bushu/ui/models/VAE"
637
  VAE_filename8 = "klF8Anime2_klF8Anime2VAE.pt"
638
  VAE_target8 = f"{VAE_destination_folder8}/{VAE_filename8}"
639
 
 
645
  # VAE任务9
646
  VAE_download_task9 = False
647
  VAE_url9 = ""
648
+ VAE_destination_folder9 = "/bushu/ui/models/VAE"
649
  VAE_filename9 = ""
650
  VAE_target9 = f"{VAE_destination_folder9}/{VAE_filename9}"
651
 
 
657
  # VAE任务10
658
  VAE_download_task10 = False
659
  VAE_url10 = ""
660
+ VAE_destination_folder10 = "/bushu/ui/models/VAE"
661
  VAE_filename10 = ""
662
  VAE_target10 = f"{VAE_destination_folder10}/{VAE_filename10}"
663
 
 
669
  # VAE任务11
670
  VAE_download_task11 = False
671
  VAE_url11 = ""
672
+ VAE_destination_folder11 = "/bushu/ui/models/VAE"
673
  VAE_filename11 = ""
674
  VAE_target11 = f"{VAE_destination_folder11}/{VAE_filename11}"
675
 
 
681
  # VAE任务12
682
  VAE_download_task12 = False
683
  VAE_url12 = ""
684
+ VAE_destination_folder12 = "/bushu/ui/models/VAE"
685
  VAE_filename12 = ""
686
  VAE_target12 = f"{VAE_destination_folder12}/{VAE_filename12}"
687
 
 
693
  # VAE任务13
694
  VAE_download_task13 = False
695
  VAE_url13 = ""
696
+ VAE_destination_folder13 = "/bushu/ui/models/VAE"
697
  VAE_filename13 = ""
698
  VAE_target13 = f"{VAE_destination_folder13}/{VAE_filename13}"
699
 
 
715
  # _下载任务1_
716
  embeddings_download_task1 = True #@param {type:"boolean"}
717
  embeddings_url1 = "https://civitai.com/api/download/models/125849"
718
+ embeddings_destination_folder1 = "/bushu/ui/embeddings" #@ param {type:"string"}
719
  embeddings_filename1 = "bad-hands-5.pt"
720
  embeddings_target1 = f'{embeddings_destination_folder1}/{embeddings_filename1}'
721
 
 
725
  # _下载任务2_
726
  embeddings_download_task2 = False #@param {type:"boolean"}
727
  embeddings_url2 = ""
728
+ embeddings_destination_folder2 = "/bushu/ui/embeddings" #@ param {type:"string"}
729
  embeddings_filename2 = ""
730
  embeddings_target2 = f'{embeddings_destination_folder2}/{embeddings_filename2}'
731
 
 
735
  # _下载任务3_
736
  embeddings_download_task3 = False #@param {type:"boolean"}
737
  embeddings_url3 = ""
738
+ embeddings_destination_folder3 = "/bushu/ui/embeddings" #@ param {type:"string"}
739
  embeddings_filename3 = ""
740
  embeddings_target3 = f'{embeddings_destination_folder3}/{embeddings_filename3}'
741
 
 
745
  # _下载任务4_
746
  embeddings_download_task4 = False #@param {type:"boolean"}
747
  embeddings_url4 = ""
748
+ embeddings_destination_folder4 = "/bushu/ui/embeddings" #@ param {type:"string"}
749
  embeddings_filename4 = ""
750
  embeddings_target4 = f'{embeddings_destination_folder4}/{embeddings_filename4}'
751
 
 
755
  # _下载任务5_
756
  embeddings_download_task5 = False #@param {type:"boolean"}
757
  embeddings_url5 = ""
758
+ embeddings_destination_folder5 = "/bushu/ui/embeddings" #@ param {type:"string"}
759
  embeddings_filename5 = ""
760
  embeddings_target5 = f'{embeddings_destination_folder5}/{embeddings_filename5}'
761
 
 
792
  w = binascii.unhexlify("7765627569").decode("ascii")
793
 
794
 
795
+ # 切换到/bushu/ui目录
796
+ subprocess.run(["cd", "/bushu/ui"], shell=True)
797
 
798
+ # 安装requirements.txt中的依赖项
799
+ subprocess.run(["pip", "install", "-r", "/bushu/ui/requirements.txt"])
800
 
801
 
802