TheLastBen commited on
Commit
aa4d014
1 Parent(s): d4d4eef

Upload 2 files

Browse files
Scripts/mainpaperspacev1.py CHANGED
@@ -704,110 +704,10 @@ def dbtrain(Resume_Training, UNet_Training_Steps, UNet_Learning_Rate, Text_Encod
704
  return resume
705
 
706
 
707
- def test(Custom_Path, Previous_Session_Name, Session_Name, User, Password, Use_localtunnel):
708
 
709
-
710
- if Previous_Session_Name!="":
711
- print("Loading a previous session model")
712
- mdldir='/notebooks/Fast-Dreambooth/Sessions/'+Previous_Session_Name
713
- path_to_trained_model=mdldir+"/"+Previous_Session_Name+'.ckpt'
714
-
715
-
716
- while not os.path.exists(path_to_trained_model):
717
- print("There is no trained model in the previous session")
718
- time.sleep(5)
719
-
720
- elif Custom_Path!="":
721
- print("Loading model from a custom path")
722
- path_to_trained_model=Custom_Path
723
-
724
-
725
- while not os.path.exists(path_to_trained_model):
726
- print("Wrong Path")
727
- time.sleep(5)
728
-
729
- else:
730
- print("Loading the trained model")
731
- mdldir='/notebooks/Fast-Dreambooth/Sessions/'+Session_Name
732
- path_to_trained_model=mdldir+"/"+Session_Name+'.ckpt'
733
 
734
 
735
- while not os.path.exists(path_to_trained_model):
736
- print("There is no trained model in this session")
737
- time.sleep(5)
738
-
739
- auth=f"--gradio-auth {User}:{Password}"
740
- if User =="" or Password=="":
741
- auth=""
742
-
743
- os.chdir('/notebooks')
744
- if not os.path.exists('/notebooks/sd/stablediffusion'):
745
- call('wget -q -O sd_rep.tar.zst https://huggingface.co/TheLastBen/dependencies/resolve/main/sd_rep.tar.zst', shell=True)
746
- call('tar --zstd -xf sd_rep.tar.zst', shell=True)
747
- call('rm sd_rep.tar.zst', shell=True)
748
-
749
- os.chdir('/notebooks/sd')
750
- if not os.path.exists('stable-diffusion-webui'):
751
- call('git clone -q --depth 1 --branch master https://github.com/AUTOMATIC1111/stable-diffusion-webui', shell=True)
752
-
753
- os.chdir('/notebooks/sd/stable-diffusion-webui/')
754
- call('git reset --hard', shell=True, stdout=open('/dev/null', 'w'))
755
- print('')
756
- call('git pull', shell=True, stdout=open('/dev/null', 'w'))
757
- os.chdir('/notebooks')
758
- clear_output()
759
-
760
- if not os.path.exists('/usr/lib/node_modules/localtunnel'):
761
- call('npm install -g localtunnel --silent', shell=True, stdout=open('/dev/null', 'w'))
762
-
763
- share=''
764
- call('wget -q -O /usr/local/lib/python3.9/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/blocks.py', shell=True)
765
-
766
- if not Use_localtunnel:
767
- share='--share'
768
-
769
- else:
770
- share=''
771
- os.chdir('/notebooks')
772
- call('nohup lt --port 7860 > srv.txt 2>&1 &', shell=True)
773
- time.sleep(2)
774
- call("grep -o 'https[^ ]*' srv.txt >srvr.txt", shell=True)
775
- time.sleep(2)
776
- srv= getoutput('cat srvr.txt')
777
-
778
- for line in fileinput.input('/usr/local/lib/python3.9/dist-packages/gradio/blocks.py', inplace=True):
779
- if line.strip().startswith('self.server_name ='):
780
- line = f' self.server_name = "{srv[8:]}"\n'
781
- if line.strip().startswith('self.server_port ='):
782
- line = ' self.server_port = 443\n'
783
- if line.strip().startswith('self.protocol = "https"'):
784
- line = ' self.protocol = "https"\n'
785
- if line.strip().startswith('if self.local_url.startswith("https") or self.is_colab'):
786
- line = ''
787
- if line.strip().startswith('else "http"'):
788
- line = ''
789
- sys.stdout.write(line)
790
-
791
- call('rm srv.txt srvr.txt', shell=True)
792
-
793
- os.chdir('/notebooks/sd/stable-diffusion-webui/modules')
794
- call('wget -q -O paths.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/paths.py', shell=True)
795
- call("sed -i 's@ui.create_ui().*@ui.create_ui();shared.demo.queue(concurrency_count=999999,status_update_rate=0.1)@' /notebooks/sd/stable-diffusion-webui/webui.py", shell=True)
796
- call("sed -i 's@/content/gdrive/MyDrive/sd/stablediffusion@/notebooks/sd/stablediffusion@' /notebooks/sd/stable-diffusion-webui/modules/paths.py", shell=True)
797
- call("sed -i 's@\"quicksettings\": OptionInfo(.*@\"quicksettings\": OptionInfo(\"sd_model_checkpoint, sd_vae, CLIP_stop_at_last_layers, inpainting_mask_weight, initial_noise_multiplier\", \"Quicksettings list\"),@' /notebooks/sd/stable-diffusion-webui/modules/shared.py", shell=True)
798
- os.chdir('/notebooks/sd/stable-diffusion-webui')
799
- clear_output()
800
-
801
- configf="--disable-console-progressbars --no-half-vae --disable-safe-unpickle --api --no-download-sd-model --xformers --enable-insecure-extension-access --skip-version-check --ckpt "+path_to_trained_model+" "+auth+" "+share
802
-
803
- return configf
804
-
805
-
806
-
807
- def testui(Custom_Path, Previous_Session_Name, Session_Name, User, Password, Ngrok_token):
808
-
809
- from pyngrok import ngrok, conf
810
-
811
  if Previous_Session_Name!="":
812
  print("Loading a previous session model")
813
  mdldir='/notebooks/Fast-Dreambooth/Sessions/'+Previous_Session_Name
@@ -861,26 +761,21 @@ def testui(Custom_Path, Previous_Session_Name, Session_Name, User, Password, Ngr
861
  if not os.path.exists('/usr/lib/node_modules/localtunnel'):
862
  call('npm install -g localtunnel --silent', shell=True, stdout=open('/dev/null', 'w'))
863
 
864
- share=''
865
  call('wget -q -O /usr/local/lib/python3.9/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/blocks.py', shell=True)
866
 
867
- if Ngrok_token!="":
868
- ngrok.kill()
869
- srv=ngrok.connect(7860, pyngrok_config=conf.PyngrokConfig(auth_token=Ngrok_token) , bind_tls=True).public_url
870
-
871
- for line in fileinput.input('/usr/local/lib/python3.9/dist-packages/gradio/blocks.py', inplace=True):
872
- if line.strip().startswith('self.server_name ='):
873
- line = f' self.server_name = "{srv[8:]}"\n'
874
- if line.strip().startswith('self.protocol = "https"'):
875
- line = ' self.protocol = "https"\n'
876
- if line.strip().startswith('if self.local_url.startswith("https") or self.is_colab'):
877
- line = ''
878
- if line.strip().startswith('else "http"'):
879
- line = ''
880
- sys.stdout.write(line)
881
 
882
- else:
883
- share='--share'
884
 
885
  os.chdir('/notebooks/sd/stable-diffusion-webui/modules')
886
  call('wget -q -O paths.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/paths.py', shell=True)
@@ -890,7 +785,7 @@ def testui(Custom_Path, Previous_Session_Name, Session_Name, User, Password, Ngr
890
  os.chdir('/notebooks/sd/stable-diffusion-webui')
891
  clear_output()
892
 
893
- configf="--disable-console-progressbars --no-half-vae --disable-safe-unpickle --api --no-download-sd-model --xformers --enable-insecure-extension-access --skip-version-check --ckpt "+path_to_trained_model+" "+auth+" "+share
894
 
895
  return configf
896
 
 
704
  return resume
705
 
706
 
 
707
 
708
+ def testui(Custom_Path, Previous_Session_Name, Session_Name, User, Password):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
709
 
710
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
711
  if Previous_Session_Name!="":
712
  print("Loading a previous session model")
713
  mdldir='/notebooks/Fast-Dreambooth/Sessions/'+Previous_Session_Name
 
761
  if not os.path.exists('/usr/lib/node_modules/localtunnel'):
762
  call('npm install -g localtunnel --silent', shell=True, stdout=open('/dev/null', 'w'))
763
 
 
764
  call('wget -q -O /usr/local/lib/python3.9/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/blocks.py', shell=True)
765
 
766
+ localurl="tensorboard-"+os.environ.get('PAPERSPACE_FQDN')
767
+
768
+ for line in fileinput.input('/usr/local/lib/python3.9/dist-packages/gradio/blocks.py', inplace=True):
769
+ if line.strip().startswith('self.server_name ='):
770
+ line = f' self.server_name = "{localurl}"\n'
771
+ if line.strip().startswith('self.protocol = "https"'):
772
+ line = ' self.protocol = "https"\n'
773
+ if line.strip().startswith('if self.local_url.startswith("https") or self.is_colab'):
774
+ line = ''
775
+ if line.strip().startswith('else "http"'):
776
+ line = ''
777
+ sys.stdout.write(line)
 
 
778
 
 
 
779
 
780
  os.chdir('/notebooks/sd/stable-diffusion-webui/modules')
781
  call('wget -q -O paths.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/paths.py', shell=True)
 
785
  os.chdir('/notebooks/sd/stable-diffusion-webui')
786
  clear_output()
787
 
788
+ configf="--disable-console-progressbars --no-half-vae --disable-safe-unpickle --api --no-download-sd-model --xformers --enable-insecure-extension-access --port 6006 --listen --skip-version-check --ckpt "+path_to_trained_model+" "+auth
789
 
790
  return configf
791
 
Scripts/mainpaperspacev2.py CHANGED
@@ -750,110 +750,11 @@ def dbtrainv2(Resume_Training, UNet_Training_Steps, UNet_Learning_Rate, Text_Enc
750
 
751
  return resumev2
752
 
753
-
754
- def test(Custom_Path, Previous_Session_Name, Session_Name, User, Password, Use_localtunnel):
755
-
756
-
757
- if Previous_Session_Name!="":
758
- print("Loading a previous session model")
759
- mdldir='/notebooks/Fast-Dreambooth/Sessions/'+Previous_Session_Name
760
- path_to_trained_model=mdldir+"/"+Previous_Session_Name+'.ckpt'
761
-
762
-
763
- while not os.path.exists(path_to_trained_model):
764
- print("There is no trained model in the previous session")
765
- time.sleep(5)
766
-
767
- elif Custom_Path!="":
768
- print("Loading model from a custom path")
769
- path_to_trained_model=Custom_Path
770
-
771
-
772
- while not os.path.exists(path_to_trained_model):
773
- print("Wrong Path")
774
- time.sleep(5)
775
-
776
- else:
777
- print("Loading the trained model")
778
- mdldir='/notebooks/Fast-Dreambooth/Sessions/'+Session_Name
779
- path_to_trained_model=mdldir+"/"+Session_Name+'.ckpt'
780
-
781
-
782
- while not os.path.exists(path_to_trained_model):
783
- print("There is no trained model in this session")
784
- time.sleep(5)
785
-
786
- auth=f"--gradio-auth {User}:{Password}"
787
- if User =="" or Password=="":
788
- auth=""
789
-
790
- os.chdir('/notebooks')
791
- if not os.path.exists('/notebooks/sd/stablediffusion'):
792
- call('wget -q -O sd_rep.tar.zst https://huggingface.co/TheLastBen/dependencies/resolve/main/sd_rep.tar.zst', shell=True)
793
- call('tar --zstd -xf sd_rep.tar.zst', shell=True)
794
- call('rm sd_rep.tar.zst', shell=True)
795
-
796
- os.chdir('/notebooks/sd')
797
- if not os.path.exists('stable-diffusion-webui'):
798
- call('git clone -q --depth 1 --branch master https://github.com/AUTOMATIC1111/stable-diffusion-webui', shell=True)
799
-
800
- os.chdir('/notebooks/sd/stable-diffusion-webui/')
801
- call('git reset --hard', shell=True, stdout=open('/dev/null', 'w'))
802
- print('')
803
- call('git pull', shell=True, stdout=open('/dev/null', 'w'))
804
- os.chdir('/notebooks')
805
- clear_output()
806
-
807
- if not os.path.exists('/usr/lib/node_modules/localtunnel'):
808
- call('npm install -g localtunnel --silent', shell=True, stdout=open('/dev/null', 'w'))
809
-
810
- share=''
811
- call('wget -q -O /usr/local/lib/python3.9/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/blocks.py', shell=True)
812
 
813
- if not Use_localtunnel:
814
- share='--share'
815
 
816
- else:
817
- share=''
818
- os.chdir('/notebooks')
819
- call('nohup lt --port 7860 > srv.txt 2>&1 &', shell=True)
820
- time.sleep(2)
821
- call("grep -o 'https[^ ]*' srv.txt >srvr.txt", shell=True)
822
- time.sleep(2)
823
- srv= getoutput('cat srvr.txt')
824
-
825
- for line in fileinput.input('/usr/local/lib/python3.9/dist-packages/gradio/blocks.py', inplace=True):
826
- if line.strip().startswith('self.server_name ='):
827
- line = f' self.server_name = "{srv[8:]}"\n'
828
- if line.strip().startswith('self.server_port ='):
829
- line = ' self.server_port = 443\n'
830
- if line.strip().startswith('self.protocol = "https"'):
831
- line = ' self.protocol = "https"\n'
832
- if line.strip().startswith('if self.local_url.startswith("https") or self.is_colab'):
833
- line = ''
834
- if line.strip().startswith('else "http"'):
835
- line = ''
836
- sys.stdout.write(line)
837
-
838
- call('rm srv.txt srvr.txt', shell=True)
839
 
840
- os.chdir('/notebooks/sd/stable-diffusion-webui/modules')
841
- call('wget -q -O paths.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/paths.py', shell=True)
842
- call("sed -i 's@ui.create_ui().*@ui.create_ui();shared.demo.queue(concurrency_count=999999,status_update_rate=0.1)@' /notebooks/sd/stable-diffusion-webui/webui.py", shell=True)
843
- call("sed -i 's@/content/gdrive/MyDrive/sd/stablediffusion@/notebooks/sd/stablediffusion@' /notebooks/sd/stable-diffusion-webui/modules/paths.py", shell=True)
844
- call("sed -i 's@\"quicksettings\": OptionInfo(.*@\"quicksettings\": OptionInfo(\"sd_model_checkpoint, sd_vae, CLIP_stop_at_last_layers, inpainting_mask_weight, initial_noise_multiplier\", \"Quicksettings list\"),@' /notebooks/sd/stable-diffusion-webui/modules/shared.py", shell=True)
845
- os.chdir('/notebooks/sd/stable-diffusion-webui')
846
- clear_output()
847
 
848
- configf="--disable-console-progressbars --no-half-vae --disable-safe-unpickle --api --no-download-sd-model --xformers --enable-insecure-extension-access --skip-version-check --ckpt "+path_to_trained_model+" "+auth+" "+share
849
-
850
- return configf
851
-
852
-
853
-
854
- def testui(Custom_Path, Previous_Session_Name, Session_Name, User, Password, Ngrok_token):
855
-
856
- from pyngrok import ngrok, conf
857
 
858
  if Previous_Session_Name!="":
859
  print("Loading a previous session model")
@@ -908,26 +809,21 @@ def testui(Custom_Path, Previous_Session_Name, Session_Name, User, Password, Ngr
908
  if not os.path.exists('/usr/lib/node_modules/localtunnel'):
909
  call('npm install -g localtunnel --silent', shell=True, stdout=open('/dev/null', 'w'))
910
 
911
- share=''
912
  call('wget -q -O /usr/local/lib/python3.9/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/blocks.py', shell=True)
913
 
914
- if Ngrok_token!="":
915
- ngrok.kill()
916
- srv=ngrok.connect(7860, pyngrok_config=conf.PyngrokConfig(auth_token=Ngrok_token) , bind_tls=True).public_url
917
-
918
- for line in fileinput.input('/usr/local/lib/python3.9/dist-packages/gradio/blocks.py', inplace=True):
919
- if line.strip().startswith('self.server_name ='):
920
- line = f' self.server_name = "{srv[8:]}"\n'
921
- if line.strip().startswith('self.protocol = "https"'):
922
- line = ' self.protocol = "https"\n'
923
- if line.strip().startswith('if self.local_url.startswith("https") or self.is_colab'):
924
- line = ''
925
- if line.strip().startswith('else "http"'):
926
- line = ''
927
- sys.stdout.write(line)
928
 
929
- else:
930
- share='--share'
931
 
932
  os.chdir('/notebooks/sd/stable-diffusion-webui/modules')
933
  call('wget -q -O paths.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/paths.py', shell=True)
@@ -937,13 +833,14 @@ def testui(Custom_Path, Previous_Session_Name, Session_Name, User, Password, Ngr
937
  os.chdir('/notebooks/sd/stable-diffusion-webui')
938
  clear_output()
939
 
940
- configf="--disable-console-progressbars --no-half-vae --disable-safe-unpickle --api --no-download-sd-model --xformers --enable-insecure-extension-access --skip-version-check --ckpt "+path_to_trained_model+" "+auth+" "+share
941
 
942
  return configf
943
 
944
 
945
 
946
 
 
947
  def clean():
948
 
949
  Sessions=os.listdir("/notebooks/Fast-Dreambooth/Sessions")
 
750
 
751
  return resumev2
752
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
753
 
 
 
754
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
755
 
756
+ def testui(Custom_Path, Previous_Session_Name, Session_Name, User, Password):
 
 
 
 
 
 
757
 
 
 
 
 
 
 
 
 
 
758
 
759
  if Previous_Session_Name!="":
760
  print("Loading a previous session model")
 
809
  if not os.path.exists('/usr/lib/node_modules/localtunnel'):
810
  call('npm install -g localtunnel --silent', shell=True, stdout=open('/dev/null', 'w'))
811
 
 
812
  call('wget -q -O /usr/local/lib/python3.9/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/blocks.py', shell=True)
813
 
814
+ localurl="tensorboard-"+os.environ.get('PAPERSPACE_FQDN')
815
+
816
+ for line in fileinput.input('/usr/local/lib/python3.9/dist-packages/gradio/blocks.py', inplace=True):
817
+ if line.strip().startswith('self.server_name ='):
818
+ line = f' self.server_name = "{localurl}"\n'
819
+ if line.strip().startswith('self.protocol = "https"'):
820
+ line = ' self.protocol = "https"\n'
821
+ if line.strip().startswith('if self.local_url.startswith("https") or self.is_colab'):
822
+ line = ''
823
+ if line.strip().startswith('else "http"'):
824
+ line = ''
825
+ sys.stdout.write(line)
 
 
826
 
 
 
827
 
828
  os.chdir('/notebooks/sd/stable-diffusion-webui/modules')
829
  call('wget -q -O paths.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/paths.py', shell=True)
 
833
  os.chdir('/notebooks/sd/stable-diffusion-webui')
834
  clear_output()
835
 
836
+ configf="--disable-console-progressbars --no-half-vae --disable-safe-unpickle --api --no-download-sd-model --xformers --enable-insecure-extension-access --port 6006 --listen --skip-version-check --ckpt "+path_to_trained_model+" "+auth
837
 
838
  return configf
839
 
840
 
841
 
842
 
843
+
844
  def clean():
845
 
846
  Sessions=os.listdir("/notebooks/Fast-Dreambooth/Sessions")