BBrother commited on
Commit
3b5d196
1 Parent(s): 7e4fff5

Update v2_3.py

Browse files
Files changed (1) hide show
  1. v2_3.py +83 -90
v2_3.py CHANGED
@@ -190,7 +190,6 @@ with open('/bushu/ui/modules/shared.py', 'w') as file:
190
 
191
 
192
 
193
-
194
  # 汉化
195
  run_git_clone(f"https://github.com/dtlnor/{st}-localization-zh_CN", f"{extensions_path}/{st}-localization-zh_CN-main")
196
 
@@ -272,22 +271,30 @@ if T2I_:
272
 
273
 
274
  print ("修改启动文件...")
275
- # 修改文件
276
- with fileinput.FileInput('/bushu/ui/launch.py', inplace=True, backup='.bak') as file:
277
- for line in file:
278
- print(line.replace('from modules import launch_utils', 'import os'), end='')
 
 
279
 
280
- with fileinput.FileInput('/bushu/ui/launch.py', inplace=True, backup='.bak') as file:
281
- for line in file:
282
- print(line.replace('prepare_environment()', 'os.system(f"""sed -i -e \'\'\'s/dict()))/dict())).cuda()/g\"\'\' /bushu/ui/repositories/stable-diffusion-stability-ai/ldm/util.py\"")'), end='')
283
 
284
- with fileinput.FileInput('/bushu/ui/modules/shared.py', inplace=True, backup='.bak') as file:
285
- for line in file:
286
- print(line.replace('["sd_model_checkpoint"]', '["sd_model_checkpoint","sd_vae","CLIP_stop_at_last_layers"]'), end='')
 
 
 
287
 
288
 
 
289
 
 
290
 
 
291
 
292
 
293
  """# 模型下载"""
@@ -295,169 +302,156 @@ with fileinput.FileInput('/bushu/ui/modules/shared.py', inplace=True, backup='.b
295
  print ("开始下载Checkpoints/safetensors等大模型")
296
  # Checkpoints/safetensors等大模型下载
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
 
304
- if CS_download_task1:
305
  os.makedirs(CS_destination_folder1, exist_ok=True)
306
  response = requests.get(CS_url1)
307
  with open(CS_target1, 'wb') as f:
308
  f.write(response.content)
309
 
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
 
317
- if CS_download_task2:
318
  os.makedirs(CS_destination_folder2, exist_ok=True)
319
  response = requests.get(CS_url2)
320
  with open(CS_target2, 'wb') as f:
321
  f.write(response.content)
322
 
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
 
330
- if CS_download_task3:
331
  os.makedirs(CS_destination_folder3, exist_ok=True)
332
  response = requests.get(CS_url3)
333
  with open(CS_target3, 'wb') as f:
334
  f.write(response.content)
335
 
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
 
343
- if CS_download_task4:
344
  os.makedirs(CS_destination_folder4, exist_ok=True)
345
  response = requests.get(CS_url4)
346
  with open(CS_target4, 'wb') as f:
347
  f.write(response.content)
348
 
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
 
356
- if CS_download_task5:
357
  os.makedirs(CS_destination_folder5, exist_ok=True)
358
  response = requests.get(CS_url5)
359
  with open(CS_target5, 'wb') as f:
360
  f.write(response.content)
361
 
362
  # 下载任务6
363
- CS_download_task6 = False
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
 
369
- if CS_download_task6:
370
  os.makedirs(CS_destination_folder6, exist_ok=True)
371
  response = requests.get(CS_url6)
372
  with open(CS_target6, 'wb') as f:
373
  f.write(response.content)
374
 
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
 
382
- if CS_download_task7:
383
  os.makedirs(CS_destination_folder7, exist_ok=True)
384
  response = requests.get(CS_url7)
385
  with open(CS_target7, 'wb') as f:
386
  f.write(response.content)
387
 
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
 
395
- if CS_download_task8:
396
  os.makedirs(CS_destination_folder8, exist_ok=True)
397
  response = requests.get(CS_url8)
398
  with open(CS_target8, 'wb') as f:
399
  f.write(response.content)
400
 
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
 
408
- if CS_download_task9:
409
  os.makedirs(CS_destination_folder9, exist_ok=True)
410
  response = requests.get(CS_url9)
411
  with open(CS_target9, 'wb') as f:
412
  f.write(response.content)
413
 
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
 
421
- if CS_download_task10:
422
  os.makedirs(CS_destination_folder10, exist_ok=True)
423
  response = requests.get(CS_url10)
424
  with open(CS_target10, 'wb') as f:
425
  f.write(response.content)
426
 
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
 
434
- if CS_download_task11:
435
  os.makedirs(CS_destination_folder11, exist_ok=True)
436
  response = requests.get(CS_url11)
437
  with open(CS_target11, 'wb') as f:
438
  f.write(response.content)
439
 
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
 
447
- if CS_download_task12:
448
  os.makedirs(CS_destination_folder12, exist_ok=True)
449
  response = requests.get(CS_url12)
450
  with open(CS_target12, 'wb') as f:
451
  f.write(response.content)
452
 
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
 
460
- if CS_download_task13:
461
  os.makedirs(CS_destination_folder13, exist_ok=True)
462
  response = requests.get(CS_url13)
463
  with open(CS_target13, 'wb') as f:
@@ -466,240 +460,237 @@ if CS_download_task13:
466
 
467
 
468
  #Lora模型下载
 
 
 
 
 
 
 
469
  print("开始下载Lora模型")
470
  # Lora任务1
471
- Lora_download_task1 = True
472
  Lora_url1 = "https://civitai.com/api/download/models/64842"
473
  Lora_destination_folder1 = "/bushu/ui/models/Lora"
474
  Lora_filename1 = "arona_puranalora_v1.safetensors"
475
  Lora_target1 = os.path.join(Lora_destination_folder1, Lora_filename1)
476
 
477
- if Lora_download_task1:
478
  response = requests.get(Lora_url1)
479
  if response.status_code == 200:
480
  with open(Lora_target1, 'wb') as f:
481
  f.write(response.content)
482
 
483
  # Lora任务2
484
- Lora_download_task2 = False
485
  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"
486
  Lora_destination_folder2 = "/bushu/ui/models/Lora"
487
  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"
488
  Lora_target2 = os.path.join(Lora_destination_folder2, Lora_filename2)
489
 
490
- if Lora_download_task2:
491
  response = requests.get(Lora_url2)
492
  if response.status_code == 200:
493
  with open(Lora_target2, 'wb') as f:
494
  f.write(response.content)
495
 
496
  # Lora任务3
497
- Lora_download_task3 = False
498
  Lora_url3 = "https://civitai.com/api/download/models/52900"
499
  Lora_destination_folder3 = "/bushu/ui/models/Lora"
500
  Lora_filename3 = "cailaiarona-000007.safetensors"
501
  Lora_target3 = os.path.join(Lora_destination_folder3, Lora_filename3)
502
 
503
- if Lora_download_task3:
504
  response = requests.get(Lora_url3)
505
  if response.status_code == 200:
506
  with open(Lora_target3, 'wb') as f:
507
  f.write(response.content)
508
 
509
  # Lora任务4
510
- Lora_download_task4 = False
511
  Lora_url4 = "https://civitai.com/api/download/models/9409"
512
  Lora_destination_folder4 = Lora_destination_folder3
513
  Lora_filename4 = "chara-arona-v1.safetensors"
514
  Lora_target4 = os.path.join(Lora_destination_folder4, Lora_filename4)
515
 
516
- if Lora_download_task4:
517
  response = requests.get(Lora_url4)
518
  if response.status_code == 200:
519
  with open(Lora_target4, 'wb') as f:
520
  f.write(response.content)
521
 
522
  # Lora任务5
523
- Lora_download_task5 = False
524
  Lora_url5 = ""
525
  Lora_destination_folder5 = Lora_destination_folder3
526
  Lora_filename5 = ""
527
  Lora_target5 = os.path.join(Lora_destination_folder5, Lora_filename5)
528
 
529
- if Lora_download_task5:
530
  response = requests.get(Lora_url5)
531
  if response.status_code == 200:
532
  with open(Lora_target5, 'wb') as f:
533
  f.write(response.content)
534
 
535
  # Lora任务6
536
- Lora_download_task6 = False
537
  Lora_url6 = ""
538
  Lora_destination_folder6 = Lora_destination_folder3
539
  Lora_filename6 = ""
540
  Lora_target6 = os.path.join(Lora_destination_folder6, Lora_filename6)
541
 
542
- if Lora_download_task6:
543
  response = requests.get(Lora_url6)
544
  if response.status_code == 200:
545
  with open(Lora_target6, 'wb') as f:
546
  f.write(response.content)
547
 
548
 
 
 
549
  # VAE下载
 
 
 
 
 
 
 
550
  print ("开始下载VAE模型")
551
  # VAE任务1
552
- VAE_download_task1 = True
553
  VAE_url1 = "https://civitai.com/api/download/models/25986"
554
  VAE_destination_folder1 = "/bushu/ui/models/VAE"
555
  VAE_filename1 = "anypastelAnythingV45_anypastelAnythingV45.zip"
556
  VAE_target1 = f"{VAE_destination_folder1}/{VAE_filename1}"
557
 
558
- if VAE_download_task1:
559
  response = requests.get(VAE_url1)
560
  with open(VAE_target1, 'wb') as file:
561
  file.write(response.content)
562
 
563
  # VAE任务2
564
- VAE_download_task2 = False
565
  VAE_url2 = "https://civitai.com/api/download/models/64133"
566
  VAE_destination_folder2 = "/bushu/ui/models/VAE"
567
  VAE_filename2 = "counterfeit.pt"
568
  VAE_target2 = f"{VAE_destination_folder2}/{VAE_filename2}"
569
 
570
- if VAE_download_task2:
571
  response = requests.get(VAE_url2)
572
  with open(VAE_target2, 'wb') as file:
573
  file.write(response.content)
574
 
575
  # VAE任务3
576
- VAE_download_task3 = False
577
  VAE_url3 = "https://civitai.com/api/download/models/80869?type=Model&format=Other"
578
  VAE_destination_folder3 = "/bushu/ui/models/VAE"
579
  VAE_filename3 = "vaeFtMse840000Ema_v100.safetensors"
580
  VAE_target3 = f"{VAE_destination_folder3}/{VAE_filename3}"
581
 
582
- if VAE_download_task3:
583
  response = requests.get(VAE_url3)
584
  with open(VAE_target3, 'wb') as file:
585
  file.write(response.content)
586
 
587
  # VAE任务4
588
- VAE_download_task4 = False
589
  VAE_url4 = "https://huggingface.co/admruul/anything-v3.0/resolve/main/Anything-V3.0.vae.pt"
590
  VAE_destination_folder4 = "/bushu/ui/models/VAE"
591
  VAE_filename4 = "Anything-V3.0.pt"
592
  VAE_target4 = f"{VAE_destination_folder4}/{VAE_filename4}"
593
 
594
- if VAE_download_task4:
595
  response = requests.get(VAE_url4)
596
  with open(VAE_target4, 'wb') as file:
597
  file.write(response.content)
598
 
599
  # VAE任务5
600
- VAE_download_task5 = False
601
  VAE_url5 = "https://civitai.com/api/download/models/131654?type=Model&format=SafeTensor"
602
  VAE_destination_folder5 = "/bushu/ui/models/VAE"
603
  VAE_filename5 = "anythingKlF8Anime2VaeFtMse840000_klF8Anime2.safetensors"
604
  VAE_target5 = f"{VAE_destination_folder5}/{VAE_filename5}"
605
 
606
- if VAE_download_task5:
607
  response = requests.get(VAE_url5)
608
  with open(VAE_target5, 'wb') as file:
609
  file.write(response.content)
610
 
611
  # VAE任务6
612
- VAE_download_task6 = False
613
  VAE_url6 = "https://civitai.com/api/download/models/88156?type=Model&format=Other"
614
  VAE_destination_folder6 = "/bushu/ui/models/VAE"
615
  VAE_filename6 = "ClearVAE.2.3.pt"
616
  VAE_target6 = f"{VAE_destination_folder6}/{VAE_filename6}"
617
 
618
- if VAE_download_task6:
619
  response = requests.get(VAE_url6)
620
  with open(VAE_target6, 'wb') as file:
621
  file.write(response.content)
622
 
623
  # VAE任务7
624
- VAE_download_task7 = False
625
  VAE_url7 = "https://civitai.com/api/download/models/121354?type=Model&format=Other"
626
  VAE_destination_folder7 = "/bushu/ui/models/VAE"
627
  VAE_filename7 = "orangemix_v1.pt"
628
  VAE_target7 = f"{VAE_destination_folder7}/{VAE_filename7}"
629
 
630
- if VAE_download_task7:
631
  response = requests.get(VAE_url7)
632
  with open(VAE_target7, 'wb') as file:
633
  file.write(response.content)
634
 
635
  # VAE任务8
636
- VAE_download_task8 = False
637
  VAE_url8 = "https://civitai.com/api/download/models/28569?type=Model&format=Other"
638
  VAE_destination_folder8 = "/bushu/ui/models/VAE"
639
  VAE_filename8 = "klF8Anime2_klF8Anime2VAE.pt"
640
  VAE_target8 = f"{VAE_destination_folder8}/{VAE_filename8}"
641
 
642
- if VAE_download_task8:
643
  response = requests.get(VAE_url8)
644
  with open(VAE_target8, 'wb') as file:
645
  file.write(response.content)
646
 
647
  # VAE任务9
648
- VAE_download_task9 = False
649
  VAE_url9 = ""
650
  VAE_destination_folder9 = "/bushu/ui/models/VAE"
651
  VAE_filename9 = ""
652
  VAE_target9 = f"{VAE_destination_folder9}/{VAE_filename9}"
653
 
654
- if VAE_download_task9:
655
  response = requests.get(VAE_url9)
656
  with open(VAE_target9, 'wb') as file:
657
  file.write(response.content)
658
 
659
  # VAE任务10
660
- VAE_download_task10 = False
661
  VAE_url10 = ""
662
  VAE_destination_folder10 = "/bushu/ui/models/VAE"
663
  VAE_filename10 = ""
664
  VAE_target10 = f"{VAE_destination_folder10}/{VAE_filename10}"
665
 
666
- if VAE_download_task10:
667
  response = requests.get(VAE_url10)
668
  with open(VAE_target10, 'wb') as file:
669
  file.write(response.content)
670
 
671
  # VAE任务11
672
- VAE_download_task11 = False
673
  VAE_url11 = ""
674
  VAE_destination_folder11 = "/bushu/ui/models/VAE"
675
  VAE_filename11 = ""
676
  VAE_target11 = f"{VAE_destination_folder11}/{VAE_filename11}"
677
 
678
- if VAE_download_task11:
679
  response = requests.get(VAE_url11)
680
  with open(VAE_target11, 'wb') as file:
681
  file.write(response.content)
682
 
683
  # VAE任务12
684
- VAE_download_task12 = False
685
  VAE_url12 = ""
686
  VAE_destination_folder12 = "/bushu/ui/models/VAE"
687
  VAE_filename12 = ""
688
  VAE_target12 = f"{VAE_destination_folder12}/{VAE_filename12}"
689
 
690
- if VAE_download_task12:
691
  response = requests.get(VAE_url12)
692
  with open(VAE_target12, 'wb') as file:
693
  file.write(response.content)
694
 
695
  # VAE任务13
696
- VAE_download_task13 = False
697
  VAE_url13 = ""
698
  VAE_destination_folder13 = "/bushu/ui/models/VAE"
699
  VAE_filename13 = ""
700
  VAE_target13 = f"{VAE_destination_folder13}/{VAE_filename13}"
701
 
702
- if VAE_download_task13:
703
  response = requests.get(VAE_url13)
704
  with open(VAE_target13, 'wb') as file:
705
  file.write(response.content)
@@ -707,6 +698,13 @@ if VAE_download_task13:
707
 
708
 
709
  # embeddings模型下载
 
 
 
 
 
 
 
710
  print ("开始下载embeddings模型")
711
  # 下载函数
712
  def download_file(url, destination_folder, filename):
@@ -716,53 +714,48 @@ def download_file(url, destination_folder, filename):
716
  file.write(response.content)
717
 
718
  # _下载任务1_
719
- embeddings_download_task1 = True #@param {type:"boolean"}
720
  embeddings_url1 = "https://civitai.com/api/download/models/125849"
721
- embeddings_destination_folder1 = "/bushu/ui/embeddings" #@ param {type:"string"}
722
  embeddings_filename1 = "bad-hands-5.pt"
723
  embeddings_target1 = f'{embeddings_destination_folder1}/{embeddings_filename1}'
724
 
725
- if embeddings_download_task1:
726
  download_file(embeddings_url1, embeddings_destination_folder1, embeddings_filename1)
727
 
728
  # _下载任务2_
729
- embeddings_download_task2 = False #@param {type:"boolean"}
730
  embeddings_url2 = ""
731
- embeddings_destination_folder2 = "/bushu/ui/embeddings" #@ param {type:"string"}
732
  embeddings_filename2 = ""
733
  embeddings_target2 = f'{embeddings_destination_folder2}/{embeddings_filename2}'
734
 
735
- if embeddings_download_task2:
736
  download_file(embeddings_url2, embeddings_destination_folder2, embeddings_filename2)
737
 
738
  # _下载任务3_
739
- embeddings_download_task3 = False #@param {type:"boolean"}
740
  embeddings_url3 = ""
741
- embeddings_destination_folder3 = "/bushu/ui/embeddings" #@ param {type:"string"}
742
  embeddings_filename3 = ""
743
  embeddings_target3 = f'{embeddings_destination_folder3}/{embeddings_filename3}'
744
 
745
- if embeddings_download_task3:
746
  download_file(embeddings_url3, embeddings_destination_folder3, embeddings_filename3)
747
 
748
  # _下载任务4_
749
- embeddings_download_task4 = False #@param {type:"boolean"}
750
  embeddings_url4 = ""
751
- embeddings_destination_folder4 = "/bushu/ui/embeddings" #@ param {type:"string"}
752
  embeddings_filename4 = ""
753
  embeddings_target4 = f'{embeddings_destination_folder4}/{embeddings_filename4}'
754
 
755
- if embeddings_download_task4:
756
  download_file(embeddings_url4, embeddings_destination_folder4, embeddings_filename4)
757
 
758
  # _下载任务5_
759
- embeddings_download_task5 = False #@param {type:"boolean"}
760
  embeddings_url5 = ""
761
- embeddings_destination_folder5 = "/bushu/ui/embeddings" #@ param {type:"string"}
762
  embeddings_filename5 = ""
763
  embeddings_target5 = f'{embeddings_destination_folder5}/{embeddings_filename5}'
764
 
765
- if embeddings_download_task5:
766
  download_file(embeddings_url5, embeddings_destination_folder5, embeddings_filename5)
767
 
768
 
 
190
 
191
 
192
 
 
193
  # 汉化
194
  run_git_clone(f"https://github.com/dtlnor/{st}-localization-zh_CN", f"{extensions_path}/{st}-localization-zh_CN-main")
195
 
 
271
 
272
 
273
  print ("修改启动文件...")
274
+ # 修改 launch.py 文件
275
+ launch_file_path = '/bushu/ui/launch.py'
276
+ if os.path.exists(launch_file_path):
277
+ with fileinput.FileInput(launch_file_path, inplace=True, backup='.bak') as file:
278
+ for line in file:
279
+ print(line.replace('from modules import launch_utils', 'import os'), end='')
280
 
281
+ with fileinput.FileInput(launch_file_path, inplace=True, backup='.bak') as file:
282
+ for line in file:
283
+ print(line.replace('prepare_environment()', 'os.system(f"""sed -i -e \'s/stable/dict()))/dict())).cuda()/g\' /bushu/ui/repositories/diffusion-stability-stable/ldm/util.py""")'), end='')
284
 
285
+ # 修改 shared.py 文件
286
+ shared_file_path = '/bushu/ui/modules/shared.py'
287
+ if os.path.exists(shared_file_path):
288
+ with fileinput.FileInput(shared_file_path, inplace=True, backup='.bak') as file:
289
+ for line in file:
290
+ print(line.replace('["sd_model_checkpoint"]', '["sd_model_checkpoint","sd_vae","CLIP_stop_at_last_layers"]'), end='')
291
 
292
 
293
+ 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
294
 
295
+ 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 = ""
296
 
297
+ 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 = ""
298
 
299
 
300
  """# 模型下载"""
 
302
  print ("开始下载Checkpoints/safetensors等大模型")
303
  # Checkpoints/safetensors等大模型下载
304
  # 下载任务1
 
305
  CS_url1 = "https://civitai.com/api/download/models/17701"
306
  CS_destination_folder1 = f"/bushu/ui/models/Stable-diffusion"
307
  CS_filename1 = "anypastelAnythingV45_anypastelAnythingV45.safetensors"
308
  CS_target1 = f"{CS_destination_folder1}/{CS_filename1}"
309
 
310
+ if CS_download1:
311
  os.makedirs(CS_destination_folder1, exist_ok=True)
312
  response = requests.get(CS_url1)
313
  with open(CS_target1, 'wb') as f:
314
  f.write(response.content)
315
 
316
  # 下载任务2
 
317
  CS_url2 = "https://civitai.com/api/download/models/26633?type=Model&format=PickleTensor&size=full&fp=fp16"
318
  CS_destination_folder2 = f"/bushu/ui/models/Stable-diffusion"
319
  CS_filename2 = "07CounterfeitV2503_10.ckpt"
320
  CS_target2 = f"{CS_destination_folder2}/{CS_filename2}"
321
 
322
+ if CS_download2:
323
  os.makedirs(CS_destination_folder2, exist_ok=True)
324
  response = requests.get(CS_url2)
325
  with open(CS_target2, 'wb') as f:
326
  f.write(response.content)
327
 
328
  # 下载任务3
 
329
  CS_url3 = "https://civitai.com/api/download/models/90854"
330
  CS_destination_folder3 = f"/bushu/ui/models/Stable-diffusion"
331
  CS_filename3 = "AnythingV5Ink.safetensors"
332
  CS_target3 = f"{CS_destination_folder3}/{CS_filename3}"
333
 
334
+ if CS_download3:
335
  os.makedirs(CS_destination_folder3, exist_ok=True)
336
  response = requests.get(CS_url3)
337
  with open(CS_target3, 'wb') as f:
338
  f.write(response.content)
339
 
340
  # 下载任务4
 
341
  CS_url4 = "https://civitai.com/api/download/models/57618"
342
  CS_destination_folder4 = f"/bushu/ui/models/Stable-diffusion"
343
  CS_filename4 = "CounterfeitV30_v30.safetensors"
344
  CS_target4 = f"{CS_destination_folder4}/{CS_filename4}"
345
 
346
+ if CS_download4:
347
  os.makedirs(CS_destination_folder4, exist_ok=True)
348
  response = requests.get(CS_url4)
349
  with open(CS_target4, 'wb') as f:
350
  f.write(response.content)
351
 
352
  # 下载任务5
 
353
  CS_url5 = "https://civitai.com/api/download/models/1356"
354
  CS_destination_folder5 = f"/bushu/ui/models/Stable-diffusion"
355
  CS_filename5 = "dreamlike10_10.ckpt"
356
  CS_target5 = f"{CS_destination_folder5}/{CS_filename5}"
357
 
358
+ if CS_download5:
359
  os.makedirs(CS_destination_folder5, exist_ok=True)
360
  response = requests.get(CS_url5)
361
  with open(CS_target5, 'wb') as f:
362
  f.write(response.content)
363
 
364
  # 下载任务6
 
365
  CS_url6 = "https://civitai.com/api/download/models/17233"
366
  CS_destination_folder6 = f"/bushu/ui/models/Stable-diffusion"
367
  CS_filename6 = "abyssorangemix3AOM3_aom3a1b.safetensors"
368
  CS_target6 = f"{CS_destination_folder6}/{CS_filename6}"
369
 
370
+ if CS_download6:
371
  os.makedirs(CS_destination_folder6, exist_ok=True)
372
  response = requests.get(CS_url6)
373
  with open(CS_target6, 'wb') as f:
374
  f.write(response.content)
375
 
376
  # 下载任务7
 
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
 
382
+ if CS_download7:
383
  os.makedirs(CS_destination_folder7, exist_ok=True)
384
  response = requests.get(CS_url7)
385
  with open(CS_target7, 'wb') as f:
386
  f.write(response.content)
387
 
388
  # 下载任务8
 
389
  CS_url8 = ""
390
  CS_destination_folder8 = f"/bushu/ui/models/Stable-diffusion"
391
  CS_filename8 = ""
392
  CS_target8 = f"{CS_destination_folder8}/{CS_filename8}"
393
 
394
+ if CS_download8:
395
  os.makedirs(CS_destination_folder8, exist_ok=True)
396
  response = requests.get(CS_url8)
397
  with open(CS_target8, 'wb') as f:
398
  f.write(response.content)
399
 
400
  # 下载任务9
 
401
  CS_url9 = ""
402
  CS_destination_folder9 = f"/bushu/ui/models/Stable-diffusion"
403
  CS_filename9 = ""
404
  CS_target9 = f"{CS_destination_folder9}/{CS_filename9}"
405
 
406
+ if CS_download9:
407
  os.makedirs(CS_destination_folder9, exist_ok=True)
408
  response = requests.get(CS_url9)
409
  with open(CS_target9, 'wb') as f:
410
  f.write(response.content)
411
 
412
  # 下载任务10
 
413
  CS_url10 = ""
414
  CS_destination_folder10 = f"/bushu/ui/models/Stable-diffusion"
415
  CS_filename10 = ""
416
  CS_target10 = f"{CS_destination_folder10}/{CS_filename10}"
417
 
418
+ if CS_download10:
419
  os.makedirs(CS_destination_folder10, exist_ok=True)
420
  response = requests.get(CS_url10)
421
  with open(CS_target10, 'wb') as f:
422
  f.write(response.content)
423
 
424
  # 下载任务11
 
425
  CS_url11 = ""
426
  CS_destination_folder11 = f"/bushu/ui/models/Stable-diffusion"
427
  CS_filename11 = ""
428
  CS_target11 = f"{CS_destination_folder11}/{CS_filename11}"
429
 
430
+ if CS_download11:
431
  os.makedirs(CS_destination_folder11, exist_ok=True)
432
  response = requests.get(CS_url11)
433
  with open(CS_target11, 'wb') as f:
434
  f.write(response.content)
435
 
436
  # 下载任务12
 
437
  CS_url12 = ""
438
  CS_destination_folder12 = f"/bushu/ui/models/Stable-diffusion"
439
  CS_filename12 = ""
440
  CS_target12 = f"{CS_destination_folder12}/{CS_filename12}"
441
 
442
+ if CS_download12:
443
  os.makedirs(CS_destination_folder12, exist_ok=True)
444
  response = requests.get(CS_url12)
445
  with open(CS_target12, 'wb') as f:
446
  f.write(response.content)
447
 
448
  # 下载任务13
 
449
  CS_url13 = ""
450
  CS_destination_folder13 = f"/bushu/ui/models/Stable-diffusion"
451
  CS_filename13 = ""
452
  CS_target13 = f"{CS_destination_folder13}/{CS_filename13}"
453
 
454
+ if CS_download13:
455
  os.makedirs(CS_destination_folder13, exist_ok=True)
456
  response = requests.get(CS_url13)
457
  with open(CS_target13, 'wb') as f:
 
460
 
461
 
462
  #Lora模型下载
463
+
464
+ Lora_download1 = Lora_download2 = Lora_download3 = Lora_download4 = Lora_download5 = Lora_download6 = False
465
+
466
+ Lora_url1 = Lora_url2 = Lora_url3 = Lora_url4 = Lora_url5 = Lora_url6 = ""
467
+
468
+ Lora_filename1 = Lora_filename2 = Lora_filename3 = Lora_filename4 = Lora_filename5 = Lora_filename6 = ""
469
+
470
  print("开始下载Lora模型")
471
  # Lora任务1
 
472
  Lora_url1 = "https://civitai.com/api/download/models/64842"
473
  Lora_destination_folder1 = "/bushu/ui/models/Lora"
474
  Lora_filename1 = "arona_puranalora_v1.safetensors"
475
  Lora_target1 = os.path.join(Lora_destination_folder1, Lora_filename1)
476
 
477
+ if Lora_download1:
478
  response = requests.get(Lora_url1)
479
  if response.status_code == 200:
480
  with open(Lora_target1, 'wb') as f:
481
  f.write(response.content)
482
 
483
  # Lora任务2
 
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
 
489
+ if Lora_download2:
490
  response = requests.get(Lora_url2)
491
  if response.status_code == 200:
492
  with open(Lora_target2, 'wb') as f:
493
  f.write(response.content)
494
 
495
  # Lora任务3
 
496
  Lora_url3 = "https://civitai.com/api/download/models/52900"
497
  Lora_destination_folder3 = "/bushu/ui/models/Lora"
498
  Lora_filename3 = "cailaiarona-000007.safetensors"
499
  Lora_target3 = os.path.join(Lora_destination_folder3, Lora_filename3)
500
 
501
+ if Lora_download3:
502
  response = requests.get(Lora_url3)
503
  if response.status_code == 200:
504
  with open(Lora_target3, 'wb') as f:
505
  f.write(response.content)
506
 
507
  # Lora任务4
 
508
  Lora_url4 = "https://civitai.com/api/download/models/9409"
509
  Lora_destination_folder4 = Lora_destination_folder3
510
  Lora_filename4 = "chara-arona-v1.safetensors"
511
  Lora_target4 = os.path.join(Lora_destination_folder4, Lora_filename4)
512
 
513
+ if Lora_download4:
514
  response = requests.get(Lora_url4)
515
  if response.status_code == 200:
516
  with open(Lora_target4, 'wb') as f:
517
  f.write(response.content)
518
 
519
  # Lora任务5
 
520
  Lora_url5 = ""
521
  Lora_destination_folder5 = Lora_destination_folder3
522
  Lora_filename5 = ""
523
  Lora_target5 = os.path.join(Lora_destination_folder5, Lora_filename5)
524
 
525
+ if Lora_download5:
526
  response = requests.get(Lora_url5)
527
  if response.status_code == 200:
528
  with open(Lora_target5, 'wb') as f:
529
  f.write(response.content)
530
 
531
  # Lora任务6
 
532
  Lora_url6 = ""
533
  Lora_destination_folder6 = Lora_destination_folder3
534
  Lora_filename6 = ""
535
  Lora_target6 = os.path.join(Lora_destination_folder6, Lora_filename6)
536
 
537
+ if Lora_download6:
538
  response = requests.get(Lora_url6)
539
  if response.status_code == 200:
540
  with open(Lora_target6, 'wb') as f:
541
  f.write(response.content)
542
 
543
 
544
+
545
+
546
  # VAE下载
547
+
548
+ 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
549
+
550
+ 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 = ""
551
+
552
+ 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 = ""
553
+
554
  print ("开始下载VAE模型")
555
  # VAE任务1
 
556
  VAE_url1 = "https://civitai.com/api/download/models/25986"
557
  VAE_destination_folder1 = "/bushu/ui/models/VAE"
558
  VAE_filename1 = "anypastelAnythingV45_anypastelAnythingV45.zip"
559
  VAE_target1 = f"{VAE_destination_folder1}/{VAE_filename1}"
560
 
561
+ if VAE_download1:
562
  response = requests.get(VAE_url1)
563
  with open(VAE_target1, 'wb') as file:
564
  file.write(response.content)
565
 
566
  # VAE任务2
 
567
  VAE_url2 = "https://civitai.com/api/download/models/64133"
568
  VAE_destination_folder2 = "/bushu/ui/models/VAE"
569
  VAE_filename2 = "counterfeit.pt"
570
  VAE_target2 = f"{VAE_destination_folder2}/{VAE_filename2}"
571
 
572
+ if VAE_download2:
573
  response = requests.get(VAE_url2)
574
  with open(VAE_target2, 'wb') as file:
575
  file.write(response.content)
576
 
577
  # VAE任务3
 
578
  VAE_url3 = "https://civitai.com/api/download/models/80869?type=Model&format=Other"
579
  VAE_destination_folder3 = "/bushu/ui/models/VAE"
580
  VAE_filename3 = "vaeFtMse840000Ema_v100.safetensors"
581
  VAE_target3 = f"{VAE_destination_folder3}/{VAE_filename3}"
582
 
583
+ if VAE_download3:
584
  response = requests.get(VAE_url3)
585
  with open(VAE_target3, 'wb') as file:
586
  file.write(response.content)
587
 
588
  # VAE任务4
 
589
  VAE_url4 = "https://huggingface.co/admruul/anything-v3.0/resolve/main/Anything-V3.0.vae.pt"
590
  VAE_destination_folder4 = "/bushu/ui/models/VAE"
591
  VAE_filename4 = "Anything-V3.0.pt"
592
  VAE_target4 = f"{VAE_destination_folder4}/{VAE_filename4}"
593
 
594
+ if VAE_download4:
595
  response = requests.get(VAE_url4)
596
  with open(VAE_target4, 'wb') as file:
597
  file.write(response.content)
598
 
599
  # VAE任务5
 
600
  VAE_url5 = "https://civitai.com/api/download/models/131654?type=Model&format=SafeTensor"
601
  VAE_destination_folder5 = "/bushu/ui/models/VAE"
602
  VAE_filename5 = "anythingKlF8Anime2VaeFtMse840000_klF8Anime2.safetensors"
603
  VAE_target5 = f"{VAE_destination_folder5}/{VAE_filename5}"
604
 
605
+ if VAE_download5:
606
  response = requests.get(VAE_url5)
607
  with open(VAE_target5, 'wb') as file:
608
  file.write(response.content)
609
 
610
  # VAE任务6
 
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
 
616
+ if VAE_download6:
617
  response = requests.get(VAE_url6)
618
  with open(VAE_target6, 'wb') as file:
619
  file.write(response.content)
620
 
621
  # VAE任务7
 
622
  VAE_url7 = "https://civitai.com/api/download/models/121354?type=Model&format=Other"
623
  VAE_destination_folder7 = "/bushu/ui/models/VAE"
624
  VAE_filename7 = "orangemix_v1.pt"
625
  VAE_target7 = f"{VAE_destination_folder7}/{VAE_filename7}"
626
 
627
+ if VAE_download7:
628
  response = requests.get(VAE_url7)
629
  with open(VAE_target7, 'wb') as file:
630
  file.write(response.content)
631
 
632
  # VAE任务8
 
633
  VAE_url8 = "https://civitai.com/api/download/models/28569?type=Model&format=Other"
634
  VAE_destination_folder8 = "/bushu/ui/models/VAE"
635
  VAE_filename8 = "klF8Anime2_klF8Anime2VAE.pt"
636
  VAE_target8 = f"{VAE_destination_folder8}/{VAE_filename8}"
637
 
638
+ if VAE_download8:
639
  response = requests.get(VAE_url8)
640
  with open(VAE_target8, 'wb') as file:
641
  file.write(response.content)
642
 
643
  # VAE任务9
 
644
  VAE_url9 = ""
645
  VAE_destination_folder9 = "/bushu/ui/models/VAE"
646
  VAE_filename9 = ""
647
  VAE_target9 = f"{VAE_destination_folder9}/{VAE_filename9}"
648
 
649
+ if VAE_download9:
650
  response = requests.get(VAE_url9)
651
  with open(VAE_target9, 'wb') as file:
652
  file.write(response.content)
653
 
654
  # VAE任务10
 
655
  VAE_url10 = ""
656
  VAE_destination_folder10 = "/bushu/ui/models/VAE"
657
  VAE_filename10 = ""
658
  VAE_target10 = f"{VAE_destination_folder10}/{VAE_filename10}"
659
 
660
+ if VAE_download10:
661
  response = requests.get(VAE_url10)
662
  with open(VAE_target10, 'wb') as file:
663
  file.write(response.content)
664
 
665
  # VAE任务11
 
666
  VAE_url11 = ""
667
  VAE_destination_folder11 = "/bushu/ui/models/VAE"
668
  VAE_filename11 = ""
669
  VAE_target11 = f"{VAE_destination_folder11}/{VAE_filename11}"
670
 
671
+ if VAE_download11:
672
  response = requests.get(VAE_url11)
673
  with open(VAE_target11, 'wb') as file:
674
  file.write(response.content)
675
 
676
  # VAE任务12
 
677
  VAE_url12 = ""
678
  VAE_destination_folder12 = "/bushu/ui/models/VAE"
679
  VAE_filename12 = ""
680
  VAE_target12 = f"{VAE_destination_folder12}/{VAE_filename12}"
681
 
682
+ if VAE_download12:
683
  response = requests.get(VAE_url12)
684
  with open(VAE_target12, 'wb') as file:
685
  file.write(response.content)
686
 
687
  # VAE任务13
 
688
  VAE_url13 = ""
689
  VAE_destination_folder13 = "/bushu/ui/models/VAE"
690
  VAE_filename13 = ""
691
  VAE_target13 = f"{VAE_destination_folder13}/{VAE_filename13}"
692
 
693
+ if VAE_download13:
694
  response = requests.get(VAE_url13)
695
  with open(VAE_target13, 'wb') as file:
696
  file.write(response.content)
 
698
 
699
 
700
  # embeddings模型下载
701
+
702
+ embeddings_download1 = embeddings_download2 = embeddings_download3 = embeddings_download4 = embeddings_download5 = False
703
+
704
+ embeddings_url1 = embeddings_url2 = embeddings_url3 = embeddings_url4 = embeddings_url5 = ""
705
+
706
+ embeddings_filename1 = embeddings_filename2 = embeddings_filename3 = embeddings_filename4 = embeddings_filename5 = ""
707
+
708
  print ("开始下载embeddings模型")
709
  # 下载函数
710
  def download_file(url, destination_folder, filename):
 
714
  file.write(response.content)
715
 
716
  # _下载任务1_
 
717
  embeddings_url1 = "https://civitai.com/api/download/models/125849"
718
+ embeddings_destination_folder1 = "/bushu/ui/embeddings"
719
  embeddings_filename1 = "bad-hands-5.pt"
720
  embeddings_target1 = f'{embeddings_destination_folder1}/{embeddings_filename1}'
721
 
722
+ if embeddings_download1:
723
  download_file(embeddings_url1, embeddings_destination_folder1, embeddings_filename1)
724
 
725
  # _下载任务2_
 
726
  embeddings_url2 = ""
727
+ embeddings_destination_folder2 = "/bushu/ui/embeddings"
728
  embeddings_filename2 = ""
729
  embeddings_target2 = f'{embeddings_destination_folder2}/{embeddings_filename2}'
730
 
731
+ if embeddings_download2:
732
  download_file(embeddings_url2, embeddings_destination_folder2, embeddings_filename2)
733
 
734
  # _下载任务3_
 
735
  embeddings_url3 = ""
736
+ embeddings_destination_folder3 = "/bushu/ui/embeddings"
737
  embeddings_filename3 = ""
738
  embeddings_target3 = f'{embeddings_destination_folder3}/{embeddings_filename3}'
739
 
740
+ if embeddings_download3:
741
  download_file(embeddings_url3, embeddings_destination_folder3, embeddings_filename3)
742
 
743
  # _下载任务4_
 
744
  embeddings_url4 = ""
745
+ embeddings_destination_folder4 = "/bushu/ui/embeddings"
746
  embeddings_filename4 = ""
747
  embeddings_target4 = f'{embeddings_destination_folder4}/{embeddings_filename4}'
748
 
749
+ if embeddings_download4:
750
  download_file(embeddings_url4, embeddings_destination_folder4, embeddings_filename4)
751
 
752
  # _下载任务5_
 
753
  embeddings_url5 = ""
754
+ embeddings_destination_folder5 = "/bushu/ui/embeddings"
755
  embeddings_filename5 = ""
756
  embeddings_target5 = f'{embeddings_destination_folder5}/{embeddings_filename5}'
757
 
758
+ if embeddings_download5:
759
  download_file(embeddings_url5, embeddings_destination_folder5, embeddings_filename5)
760
 
761