TheLastBen commited on
Commit
8ab58cb
1 Parent(s): 2aa3c54

Update mainpaperspacev2.py

Browse files
Files changed (1) hide show
  1. mainpaperspacev2.py +27 -32
mainpaperspacev2.py CHANGED
@@ -696,7 +696,7 @@ def dbtrainv2(Resume_Training, UNet_Training_Steps, UNet_Learning_Rate, Text_Enc
696
  return resumev2
697
 
698
 
699
- def testv2(Custom_Path, Previous_Session_Name, Session_Name, Model_Version, User, Password, Use_localtunnel):
700
 
701
 
702
  if Previous_Session_Name!="":
@@ -727,39 +727,38 @@ def testv2(Custom_Path, Previous_Session_Name, Session_Name, Model_Version, User
727
  while not os.path.exists(path_to_trained_model):
728
  print("There is no trained model in this session")
729
  time.sleep(5)
730
-
731
-
732
  auth=f"--gradio-auth {User}:{Password}"
733
  if User =="" or Password=="":
734
  auth=""
735
 
736
  os.chdir('/notebooks')
737
- if not os.path.exists('sd_db'):
738
- call('mkdir sd_db', shell=True)
739
- os.chdir('/notebooks/sd_db')
740
- call('git clone --depth 1 --branch main https://github.com/Stability-AI/stablediffusion', shell=True)
741
- call('git clone --depth 1 --branch Paperspacedb https://github.com/TheLastBen/stable-diffusion-webui', shell=True)
742
- clear_output()
 
 
743
 
744
- if not os.path.exists('/notebooks/sd_db/stablediffusion/src/k-diffusion/k_diffusion'):
745
- call('mkdir /notebooks/sd_db/stablediffusion/src', shell=True)
746
- os.chdir('/notebooks/sd_db/stablediffusion/src')
747
- call('git clone -q --depth 1 --no-tags https://github.com/TheLastBen/taming-transformers.git', shell=True)
748
- call('git clone -q --depth 1 https://github.com/salesforce/BLIP', shell=True)
749
- call('git clone -q --depth 1 https://github.com/sczhou/CodeFormer', shell=True)
750
- call('git clone -q --depth 1 --branch master https://github.com/crowsonkb/k-diffusion', shell=True)
751
-
752
 
753
  if not os.path.exists('/usr/lib/node_modules/localtunnel'):
754
  call('npm install -g localtunnel --silent', shell=True, stdout=open('/dev/null', 'w'))
755
 
756
  share=''
 
 
757
  if not Use_localtunnel:
758
- share='--share'
759
- call('wget -q -O /usr/local/lib/python3.9/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dreambooth/blocks.py', shell=True)
760
 
761
  else:
762
-
763
  share=''
764
  os.chdir('/notebooks')
765
  call('nohup lt --port 7860 > srv.txt 2>&1 &', shell=True)
@@ -784,21 +783,17 @@ def testv2(Custom_Path, Previous_Session_Name, Session_Name, Model_Version, User
784
  call('rm /notebooks/srv.txt', shell=True)
785
  call('rm /notebooks/srvr.txt', shell=True)
786
 
787
-
788
 
789
- os.chdir('/notebooks/sd_db/stable-diffusion-webui')
790
- print('')
791
- call('git pull', shell=True)
 
792
  clear_output()
793
 
794
- if Model_Version == "768":
795
- configf="--config /notebooks/sd_db/stablediffusion/configs/stable-diffusion/v2-inference-v.yaml --no-half"
796
- elif Model_Version == "512":
797
- configf="--config /notebooks/sd_db/stablediffusion/configs/stable-diffusion/v2-inference.yaml --no-half"
798
- else:
799
- configf="--config /notebooks/sd_db/stablediffusion/configs/stable-diffusion/v2-inference-v.yaml --no-half"
800
-
801
- return path_to_trained_model, configf, auth
802
 
803
 
804
 
 
696
  return resumev2
697
 
698
 
699
+ def test(Custom_Path, Previous_Session_Name, Session_Name, User, Password, Use_localtunnel):
700
 
701
 
702
  if Previous_Session_Name!="":
 
727
  while not os.path.exists(path_to_trained_model):
728
  print("There is no trained model in this session")
729
  time.sleep(5)
730
+
 
731
  auth=f"--gradio-auth {User}:{Password}"
732
  if User =="" or Password=="":
733
  auth=""
734
 
735
  os.chdir('/notebooks')
736
+ if not os.path.exists('/notebooks/sd/stablediffusion'):
737
+ call('wget -q -O sd_kg.tar.zst https://huggingface.co/TheLastBen/dependencies/resolve/main/sd_kg.tar.zst', shell=True)
738
+ call('tar --zstd -xf sd_kg.tar.zst', shell=True)
739
+ call('rm sd_kg.tar.zst', shell=True)
740
+
741
+ os.chdir('/notebooks/sd')
742
+ if not os.path.exists('stable-diffusion-webui'):
743
+ call('git clone -q --depth 1 --branch master https://github.com/AUTOMATIC1111/stable-diffusion-webui', shell=True)
744
 
745
+ os.chdir('/notebooks/sd/stable-diffusion-webui/')
746
+ call('git reset --hard', shell=True, stdout=open('/dev/null', 'w'))
747
+ print('')
748
+ call('git pull', shell=True, stdout=open('/dev/null', 'w'))
749
+ os.chdir('/notebooks')
750
+ clear_output()
 
 
751
 
752
  if not os.path.exists('/usr/lib/node_modules/localtunnel'):
753
  call('npm install -g localtunnel --silent', shell=True, stdout=open('/dev/null', 'w'))
754
 
755
  share=''
756
+ 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)
757
+
758
  if not Use_localtunnel:
759
+ share='--share'
 
760
 
761
  else:
 
762
  share=''
763
  os.chdir('/notebooks')
764
  call('nohup lt --port 7860 > srv.txt 2>&1 &', shell=True)
 
783
  call('rm /notebooks/srv.txt', shell=True)
784
  call('rm /notebooks/srvr.txt', shell=True)
785
 
786
+
787
 
788
+ os.chdir('/notebooks/sd/stable-diffusion-webui/modules')
789
+ call('wget -q -O paths.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/paths.py', shell=True)
790
+ call("sed -i 's@/content/gdrive/MyDrive/sd/stablediffusion@/notebooks/sd/stablediffusion@' /notebooks/sd/stable-diffusion-webui/modules/paths.py", shell=True)
791
+ os.chdir('/notebooks/sd/stable-diffusion-webui')
792
  clear_output()
793
 
794
+ configf="--disable-console-progressbars --no-half-vae --disable-safe-unpickle --api --xformers --medvram --skip-version-check --ckpt "+path_to_trained_model+" "+auth+" "+share
795
+
796
+ return configf
 
 
 
 
 
797
 
798
 
799