stlaurentjr commited on
Commit
47518fb
·
1 Parent(s): a84ae7c

Update scripts/mainrunpodA1111.py

Browse files
Files changed (1) hide show
  1. scripts/mainrunpodA1111.py +39 -78
scripts/mainrunpodA1111.py CHANGED
@@ -679,93 +679,54 @@ def CNet(ControlNet_Model, ControlNet_XL_Model):
679
  print("[1;31mWrong ControlNet XL choice, try again")
680
 
681
 
682
- def sd(User, Password, model):
683
 
684
  import gradio
685
-
686
  gradio.close_all()
687
-
688
- auth = f"--gradio-auth {User}:{Password}"
689
- if User == "" or Password == "":
690
- auth = ""
691
-
692
- call(
693
- "wget -q -O /usr/local/lib/python3.10/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/blocks.py",
694
- shell=True,
695
- )
696
-
697
- os.chdir("/workspace/sd/stable-diffusion-webui/modules")
698
-
699
- call(
700
- "sed -i 's@possible_sd_paths =.*@possible_sd_paths = [\"/workspace/sd/stablediffusion\"]@' /workspace/sd/stable-diffusion-webui/modules/paths.py",
701
- shell=True,
702
- )
703
- call(
704
- "sed -i 's@\.\.\/@src/@g' /workspace/sd/stable-diffusion-webui/modules/paths.py",
705
- shell=True,
706
- )
707
- call(
708
- "sed -i 's@src\/generative-models@generative-models@g' /workspace/sd/stable-diffusion-webui/modules/paths.py",
709
- shell=True,
710
- )
711
-
712
- call(
713
- 'sed -i \'s@\["sd_model_checkpoint"\]@\["sd_model_checkpoint", "sd_vae", "CLIP_stop_at_last_layers", "inpainting_mask_weight", "initial_noise_multiplier"\]@g\' /workspace/sd/stable-diffusion-webui/modules/shared.py',
714
- shell=True,
715
- )
716
-
717
- call(
718
- 'sed -i \'s@\["sd_model_checkpoint"\]@\["sd_model_checkpoint", "sd_vae", "CLIP_stop_at_last_layers", "inpainting_mask_weight", "initial_noise_multiplier"\]@g\' /workspace/sd/stable-diffusion-webui/modules/shared.py',
719
- shell=True,
720
- )
721
-
722
- call(
723
- 'sed -i \'s/"CLIP_stop_at_last_layers": 1/"CLIP_stop_at_last_layers": 2/g\' /workspace/sd/stable-diffusion-webui/config.json',
724
- shell=True,
725
- )
726
-
727
- call(
728
- "sed -i 's@print(\"No module.*@@' /workspace/sd/stablediffusion/ldm/modules/diffusionmodules/model.py",
729
- shell=True,
730
- )
731
-
732
- os.chdir("/workspace/sd/stable-diffusion-webui")
733
  clear_output()
734
 
735
- podid = os.environ.get("RUNPOD_POD_ID")
736
- localurl = f"{podid}-3001.proxy.runpod.net"
737
-
738
- for line in fileinput.input(
739
- "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", inplace=True
740
- ):
741
- if line.strip().startswith("self.server_name ="):
742
- line = f' self.server_name = "{localurl}"\n'
743
- if line.strip().startswith('self.protocol = "https"'):
744
- line = ' self.protocol = "https"\n'
745
- if line.strip().startswith(
746
- 'if self.local_url.startswith("https") or self.is_colab'
747
- ):
748
- line = ""
749
- if line.strip().startswith('else "http"'):
750
- line = ""
751
- sys.stdout.write(line)
752
-
753
- if model == "":
754
- mdlpth = ""
755
  else:
756
  if os.path.isfile(model):
757
- mdlpth = "--ckpt " + model
758
  else:
759
- mdlpth = "--ckpt-dir " + model
 
760
  vae_path = "--vae-path /workspace/sd/stable-diffusion-webui/models/VAE/vae-ft-mse-840000-ema-pruned.safetensors"
761
- configf = (
762
- "--disable-console-progressbars --no-half-vae --disable-safe-unpickle --api --no-download-sd-model --opt-sdp-attention --enable-insecure-extension-access --skip-version-check --listen --port 3000 "
763
- + auth
764
- + " "
765
- + mdlpth
766
- + " "
767
- + vae_path
768
- )
769
 
770
  return configf
771
 
 
679
  print("[1;31mWrong ControlNet XL choice, try again")
680
 
681
 
682
+ ef sd(User, Password, model):
683
 
684
  import gradio
685
+
686
  gradio.close_all()
687
+
688
+ auth=f"--gradio-auth {User}:{Password}"
689
+ if User =="" or Password=="":
690
+ auth=""
691
+
692
+ call('wget -q -O /usr/local/lib/python3.10/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/blocks.py', shell=True)
693
+
694
+ os.chdir('/workspace/sd/stable-diffusion-webui/modules')
695
+
696
+ call("sed -i 's@possible_sd_paths =.*@possible_sd_paths = [\"/workspace/sd/stablediffusion\"]@' /workspace/sd/stable-diffusion-webui/modules/paths.py", shell=True)
697
+ call("sed -i 's@\.\.\/@src/@g' /workspace/sd/stable-diffusion-webui/modules/paths.py", shell=True)
698
+ call("sed -i 's@src\/generative-models@generative-models@g' /workspace/sd/stable-diffusion-webui/modules/paths.py", shell=True)
699
+
700
+ call("sed -i 's@\[\"sd_model_checkpoint\"\]@\[\"sd_model_checkpoint\", \"sd_vae\", \"CLIP_stop_at_last_layers\", \"inpainting_mask_weight\", \"initial_noise_multiplier\"\]@g' /workspace/sd/stable-diffusion-webui/modules/shared.py", shell=True)
701
+
702
+ call("sed -i 's@print(\"No module.*@@' /workspace/sd/stablediffusion/ldm/modules/diffusionmodules/model.py", shell=True)
703
+ os.chdir('/workspace/sd/stable-diffusion-webui')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
704
  clear_output()
705
 
706
+ podid=os.environ.get('RUNPOD_POD_ID')
707
+ localurl=f"{podid}-3001.proxy.runpod.net"
708
+
709
+ for line in fileinput.input('/usr/local/lib/python3.10/dist-packages/gradio/blocks.py', inplace=True):
710
+ if line.strip().startswith('self.server_name ='):
711
+ line = f' self.server_name = "{localurl}"\n'
712
+ if line.strip().startswith('self.protocol = "https"'):
713
+ line = ' self.protocol = "https"\n'
714
+ if line.strip().startswith('if self.local_url.startswith("https") or self.is_colab'):
715
+ line = ''
716
+ if line.strip().startswith('else "http"'):
717
+ line = ''
718
+ sys.stdout.write(line)
719
+
720
+ if model=="":
721
+ mdlpth=""
 
 
 
 
722
  else:
723
  if os.path.isfile(model):
724
+ mdlpth="--ckpt "+model
725
  else:
726
+ mdlpth="--ckpt-dir "+model
727
+
728
  vae_path = "--vae-path /workspace/sd/stable-diffusion-webui/models/VAE/vae-ft-mse-840000-ema-pruned.safetensors"
729
+ configf="--disable-console-progressbars --no-half-vae --disable-safe-unpickle --api --no-download-sd-model --opt-sdp-attention --enable-insecure-extension-access --skip-version-check --listen --port 3000 "+auth+" "+mdlpth+" "+vae_path
 
 
 
 
 
 
 
730
 
731
  return configf
732