TheLastBen commited on
Commit
8d31d21
1 Parent(s): 66e9b74

Update Scripts/mainpaperspacev1.py

Browse files
Files changed (1) hide show
  1. Scripts/mainpaperspacev1.py +52 -81
Scripts/mainpaperspacev1.py CHANGED
@@ -25,16 +25,7 @@ import numpy as np
25
  def Deps(force_reinstall):
26
 
27
  if not force_reinstall and os.path.exists('/usr/local/lib/python3.9/dist-packages/safetensors'):
28
- os.chdir('/notebooks')
29
- if not os.path.exists('Latest_Notebooks'):
30
- call('mkdir Latest_Notebooks', shell=True)
31
- else:
32
- call('rm -r Latest_Notebooks', shell=True)
33
- call('mkdir Latest_Notebooks', shell=True)
34
- os.chdir('/notebooks/Latest_Notebooks')
35
- call('wget -q -i https://huggingface.co/datasets/TheLastBen/PPS/raw/main/Notebooks.txt', shell=True)
36
- call('rm Notebooks.txt', shell=True)
37
- os.chdir('/notebooks')
38
  print('Modules and notebooks updated, dependencies already installed')
39
 
40
  else:
@@ -43,18 +34,7 @@ def Deps(force_reinstall):
43
  if not os.path.exists('/usr/local/lib/python3.9/dist-packages/safetensors'):
44
  os.chdir('/usr/local/lib/python3.9/dist-packages')
45
  call("rm -r torch torch-1.12.0+cu116.dist-info torchaudio* torchvision* PIL Pillow* transformers* numpy* gdown*", shell=True, stdout=open('/dev/null', 'w'))
46
-
47
- os.chdir('/notebooks')
48
- if not os.path.exists('Latest_Notebooks'):
49
- call('mkdir Latest_Notebooks', shell=True)
50
- else:
51
- call('rm -r Latest_Notebooks', shell=True)
52
- call('mkdir Latest_Notebooks', shell=True)
53
- os.chdir('/notebooks/Latest_Notebooks')
54
- call('wget -q -i https://huggingface.co/datasets/TheLastBen/PPS/raw/main/Notebooks.txt', shell=True)
55
- call('rm Notebooks.txt', shell=True)
56
- os.chdir('/notebooks')
57
-
58
  if not os.path.exists('/models'):
59
  call('mkdir /models', shell=True)
60
  if not os.path.exists('/notebooks/models'):
@@ -79,6 +59,20 @@ def Deps(force_reinstall):
79
  clear_output()
80
 
81
  done()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
 
84
  def downloadmodel_hf(Path_to_HuggingFace):
@@ -104,21 +98,20 @@ def downloadmodel_hf(Path_to_HuggingFace):
104
  call("git config core.sparsecheckout true", shell=True)
105
  call('echo -e "\nscheduler\ntext_encoder\ntokenizer\nunet\nvae\nmodel_index.json\n!*.safetensors" > .git/info/sparse-checkout', shell=True)
106
  call("git pull origin main", shell=True)
107
- if os.path.exists('/models/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
108
- call("rm -r /models/stable-diffusion-custom/.git", shell=True)
109
- call("rm -r /models/stable-diffusion-custom/model_index.json", shell=True)
110
  wget.download('https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dreambooth/model_index.json')
111
  os.chdir('/notebooks')
112
  clear_output()
113
  done()
114
-
115
  while not os.path.exists('/models/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
116
  print('Check the link you provided')
117
  os.chdir('/notebooks')
118
  time.sleep(5)
119
 
120
 
121
-
122
  def downloadmodel_pth(CKPT_Path):
123
  import wget
124
  os.chdir('/notebooks')
@@ -129,16 +122,15 @@ def downloadmodel_pth(CKPT_Path):
129
  call('rm -f refmdlz', shell=True)
130
  wget.download('https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dreambooth/convertodiffv1.py')
131
  clear_output()
132
- call('python /notebooks/convertodiffv1.py '+CKPT_Path+' /models/stable-diffusion-custom --v1', shell=True)
133
- call('rm /notebooks/convertodiffv1.py', shell=True)
134
- call('rm -r /notebooks/refmdl', shell=True)
135
  if os.path.exists('/models/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
136
  clear_output()
137
  done()
138
  while not os.path.exists('/models/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
139
  print('Conversion error')
140
  time.sleep(5)
141
-
142
  else:
143
  while not os.path.exists(str(CKPT_Path)):
144
  print('Wrong path, use the file explorer to copy the path')
@@ -157,11 +149,11 @@ def downloadmodel_lnk(CKPT_Link):
157
  call('rm -f refmdlz', shell=True)
158
  wget.download('https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dreambooth/convertodiffv1.py')
159
  clear_output()
160
- call('python /notebooks/convertodiffv1.py /models/model.ckpt /models/stable-diffusion-custom --v1', shell=True)
161
- call('rm /notebooks/convertodiffv1.py', shell=True)
162
- call('rm -r /notebooks/refmdl', shell=True)
163
  if os.path.exists('/models/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
164
- call('rm -r /models/model.ckpt', shell=True)
165
  clear_output()
166
  done()
167
  else:
@@ -188,7 +180,8 @@ def dl(Path_to_HuggingFace, CKPT_Path, CKPT_Link):
188
  else:
189
  MODEL_NAME="/datasets/stable-diffusion-diffusers/stable-diffusion-v1-5"
190
  print('Using the original V1.5 model')
191
-
 
192
  return MODEL_NAME
193
 
194
 
@@ -255,7 +248,7 @@ def sess(Session_Name, Session_Link_optional, MODEL_NAME):
255
  if n!="000":
256
  f(int(n))
257
  print('Using the model '+ mdls[int(n)]+" ...")
258
- time.sleep(8)
259
  clear_output()
260
  else:
261
  print('Skipping the intermediary checkpoints.')
@@ -274,18 +267,16 @@ def sess(Session_Name, Session_Link_optional, MODEL_NAME):
274
  call('unzip -o -q refmdlz', shell=True, stdout=open('/dev/null', 'w'))
275
  call('rm -f refmdlz', shell=True, stdout=open('/dev/null', 'w'))
276
  wget.download('https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dreambooth/convertodiffv1.py')
277
- call('python /notebooks/convertodiffv1.py '+MDLPTH+' '+OUTPUT_DIR+' --v1', shell=True)
278
- call('rm /notebooks/convertodiffv1.py', shell=True)
279
- call('rm -r /notebooks/refmdl', shell=True)
280
 
281
-
282
  if os.path.exists(OUTPUT_DIR+'/unet/diffusion_pytorch_model.bin'):
283
  resume=True
284
  clear_output()
285
  print('Session loaded.')
286
  else:
287
- if not os.path.exists(OUTPUT_DIR+'/unet/diffusion_pytorch_model.bin'):
288
- print('Conversion error, if the error persists, remove the CKPT file from the current session folder')
289
 
290
  elif not os.path.exists(str(SESSION_DIR)):
291
  call('mkdir -p '+INSTANCE_DIR, shell=True)
@@ -384,8 +375,6 @@ def upld(Remove_existing_instance_images, Crop_images, Crop_size, IMAGES_FOLDER_
384
  for filename in tqdm(os.listdir(IMAGES_FOLDER_OPTIONAL), bar_format=' |{bar:15}| {n_fmt}/{total_fmt} Uploaded'):
385
  call("cp -r " +IMAGES_FOLDER_OPTIONAL+"/. " +INSTANCE_DIR, shell=True)
386
 
387
-
388
-
389
  elif IMAGES_FOLDER_OPTIONAL =="":
390
  up=""
391
  for filename, file in uploader.value.items():
@@ -619,7 +608,6 @@ def dbtrain(Resume_Training, UNet_Training_Steps, UNet_Learning_Rate, Text_Encod
619
  call('accelerate launch /notebooks/diffusers/examples/dreambooth/train_dreambooth_pps.py \
620
  '+Style+' \
621
  '+extrnlcptn+' \
622
- --stop_text_encoder_training='+str(Text_Encoder_Training_Steps)+' \
623
  --image_captions_filename \
624
  --train_only_unet \
625
  --Session_dir='+SESSION_DIR+' \
@@ -758,9 +746,9 @@ def test(Custom_Path, Previous_Session_Name, Session_Name, User, Password, Use_l
758
  os.chdir('/notebooks')
759
  call('nohup lt --port 7860 > srv.txt 2>&1 &', shell=True)
760
  time.sleep(2)
761
- call("grep -o 'https[^ ]*' /notebooks/srv.txt >srvr.txt", shell=True)
762
  time.sleep(2)
763
- srv= getoutput('cat /notebooks/srvr.txt')
764
 
765
  for line in fileinput.input('/usr/local/lib/python3.9/dist-packages/gradio/blocks.py', inplace=True):
766
  if line.strip().startswith('self.server_name ='):
@@ -775,18 +763,15 @@ def test(Custom_Path, Previous_Session_Name, Session_Name, User, Password, Use_l
775
  line = ''
776
  sys.stdout.write(line)
777
 
778
- call('rm /notebooks/srv.txt', shell=True)
779
- call('rm /notebooks/srvr.txt', shell=True)
780
-
781
-
782
-
783
  os.chdir('/notebooks/sd/stable-diffusion-webui/modules')
784
  call('wget -q -O paths.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/paths.py', shell=True)
785
  call("sed -i 's@/content/gdrive/MyDrive/sd/stablediffusion@/notebooks/sd/stablediffusion@' /notebooks/sd/stable-diffusion-webui/modules/paths.py", shell=True)
786
  os.chdir('/notebooks/sd/stable-diffusion-webui')
787
  clear_output()
788
 
789
- configf="--disable-console-progressbars --no-half-vae --disable-safe-unpickle --api --xformers --enable-insecure-extension-access --medvram --skip-version-check --ckpt "+path_to_trained_model+" "+auth+" "+share
790
 
791
  return configf
792
 
@@ -838,7 +823,7 @@ def clean():
838
 
839
 
840
 
841
- def hf(Name_of_your_concept, Save_concept_to, hf_token_write, INSTANCE_NAME, OUTPUT_DIR, Session_Name, MDLPTH):
842
 
843
  from slugify import slugify
844
  from huggingface_hub import HfApi, HfFolder, CommitOperationAdd
@@ -849,7 +834,7 @@ def hf(Name_of_your_concept, Save_concept_to, hf_token_write, INSTANCE_NAME, OUT
849
  if(Name_of_your_concept == ""):
850
  Name_of_your_concept = Session_Name
851
  Name_of_your_concept=Name_of_your_concept.replace(" ","-")
852
-
853
 
854
 
855
  if hf_token_write =="":
@@ -861,33 +846,27 @@ def hf(Name_of_your_concept, Save_concept_to, hf_token_write, INSTANCE_NAME, OUT
861
  api = HfApi()
862
  your_username = api.whoami(token=hf_token)["name"]
863
 
864
- if(Save_concept_to == "Public_Library"):
865
- repo_id = f"sd-dreambooth-library/{slugify(Name_of_your_concept)}"
866
- #Join the Concepts Library organization if you aren't part of it already
867
- call("curl -X POST -H 'Authorization: Bearer '"+hf_token+" -H 'Content-Type: application/json' https://huggingface.co/organizations/sd-dreambooth-library/share/SSeOwppVCscfTEzFGQaqpfcjukVeNrKNHX", shell=True)
868
- else:
869
- repo_id = f"{your_username}/{slugify(Name_of_your_concept)}"
870
  output_dir = f'/notebooks/models/'+INSTANCE_NAME
871
 
872
  def bar(prg):
 
873
  br="Uploading to HuggingFace : " '|'+'█' * prg + ' ' * (25-prg)+'| ' +str(prg*4)+ "%"
874
  return br
875
 
876
  print("Loading...")
877
 
878
-
879
  os.chdir(OUTPUT_DIR)
880
- call('rm -r safety_checker feature_extractor .git', shell=True)
881
  call('rm model_index.json', shell=True)
882
- call('git init', shell=True)
883
- call('git lfs install --system --skip-repo', shell=True)
884
- call('git remote add -f origin https://huggingface.co/runwayml/stable-diffusion-v1-5', shell=True)
885
- call('git config core.sparsecheckout true', shell=True)
886
- call('echo -e "\nfeature_extractor\nsafety_checker\nmodel_index.json" > .git/info/sparse-checkout', shell=True)
887
- call('git pull origin main', shell=True)
888
- call('rm -r .git', shell=True)
889
- os.chdir('/notebooks')
890
-
891
 
892
  print(bar(1))
893
 
@@ -926,7 +905,6 @@ def hf(Name_of_your_concept, Save_concept_to, hf_token_write, INSTANCE_NAME, OUT
926
  token=hf_token
927
  )
928
 
929
- clear_output()
930
  print(bar(4))
931
 
932
  api.upload_folder(
@@ -936,7 +914,6 @@ def hf(Name_of_your_concept, Save_concept_to, hf_token_write, INSTANCE_NAME, OUT
936
  token=hf_token
937
  )
938
 
939
- clear_output()
940
  print(bar(8))
941
 
942
  api.upload_folder(
@@ -946,7 +923,6 @@ def hf(Name_of_your_concept, Save_concept_to, hf_token_write, INSTANCE_NAME, OUT
946
  token=hf_token
947
  )
948
 
949
- clear_output()
950
  print(bar(9))
951
 
952
  api.upload_folder(
@@ -956,7 +932,6 @@ def hf(Name_of_your_concept, Save_concept_to, hf_token_write, INSTANCE_NAME, OUT
956
  token=hf_token
957
  )
958
 
959
- clear_output()
960
  print(bar(12))
961
 
962
  api.upload_folder(
@@ -966,7 +941,6 @@ def hf(Name_of_your_concept, Save_concept_to, hf_token_write, INSTANCE_NAME, OUT
966
  token=hf_token
967
  )
968
 
969
- clear_output()
970
  print(bar(13))
971
 
972
  api.upload_folder(
@@ -976,7 +950,6 @@ def hf(Name_of_your_concept, Save_concept_to, hf_token_write, INSTANCE_NAME, OUT
976
  token=hf_token
977
  )
978
 
979
- clear_output()
980
  print(bar(21))
981
 
982
  api.upload_folder(
@@ -986,7 +959,6 @@ def hf(Name_of_your_concept, Save_concept_to, hf_token_write, INSTANCE_NAME, OUT
986
  token=hf_token
987
  )
988
 
989
- clear_output()
990
  print(bar(23))
991
 
992
  api.upload_file(
@@ -996,7 +968,6 @@ def hf(Name_of_your_concept, Save_concept_to, hf_token_write, INSTANCE_NAME, OUT
996
  token=hf_token
997
  )
998
 
999
- clear_output()
1000
  print(bar(25))
1001
 
1002
  print("Your concept was saved successfully at https://huggingface.co/"+repo_id)
 
25
  def Deps(force_reinstall):
26
 
27
  if not force_reinstall and os.path.exists('/usr/local/lib/python3.9/dist-packages/safetensors'):
28
+ ntbk()
 
 
 
 
 
 
 
 
 
29
  print('Modules and notebooks updated, dependencies already installed')
30
 
31
  else:
 
34
  if not os.path.exists('/usr/local/lib/python3.9/dist-packages/safetensors'):
35
  os.chdir('/usr/local/lib/python3.9/dist-packages')
36
  call("rm -r torch torch-1.12.0+cu116.dist-info torchaudio* torchvision* PIL Pillow* transformers* numpy* gdown*", shell=True, stdout=open('/dev/null', 'w'))
37
+ ntbk()
 
 
 
 
 
 
 
 
 
 
 
38
  if not os.path.exists('/models'):
39
  call('mkdir /models', shell=True)
40
  if not os.path.exists('/notebooks/models'):
 
59
  clear_output()
60
 
61
  done()
62
+
63
+
64
+ def ntbk():
65
+
66
+ os.chdir('/notebooks')
67
+ if not os.path.exists('Latest_Notebooks'):
68
+ call('mkdir Latest_Notebooks', shell=True)
69
+ else:
70
+ call('rm -r Latest_Notebooks', shell=True)
71
+ call('mkdir Latest_Notebooks', shell=True)
72
+ os.chdir('/notebooks/Latest_Notebooks')
73
+ call('wget -q -i https://huggingface.co/datasets/TheLastBen/PPS/raw/main/Notebooks.txt', shell=True)
74
+ call('rm Notebooks.txt', shell=True)
75
+ os.chdir('/notebooks')
76
 
77
 
78
  def downloadmodel_hf(Path_to_HuggingFace):
 
98
  call("git config core.sparsecheckout true", shell=True)
99
  call('echo -e "\nscheduler\ntext_encoder\ntokenizer\nunet\nvae\nmodel_index.json\n!*.safetensors" > .git/info/sparse-checkout', shell=True)
100
  call("git pull origin main", shell=True)
101
+ if os.path.exists('unet/diffusion_pytorch_model.bin'):
102
+ call("rm -r .git", shell=True)
103
+ call("rm -r model_index.json", shell=True)
104
  wget.download('https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dreambooth/model_index.json')
105
  os.chdir('/notebooks')
106
  clear_output()
107
  done()
 
108
  while not os.path.exists('/models/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
109
  print('Check the link you provided')
110
  os.chdir('/notebooks')
111
  time.sleep(5)
112
 
113
 
114
+
115
  def downloadmodel_pth(CKPT_Path):
116
  import wget
117
  os.chdir('/notebooks')
 
122
  call('rm -f refmdlz', shell=True)
123
  wget.download('https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dreambooth/convertodiffv1.py')
124
  clear_output()
125
+ call('python convertodiffv1.py '+CKPT_Path+' /models/stable-diffusion-custom --v1', shell=True)
126
+ call('rm convertodiffv1.py', shell=True)
127
+ call('rm -r refmdl', shell=True)
128
  if os.path.exists('/models/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
129
  clear_output()
130
  done()
131
  while not os.path.exists('/models/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
132
  print('Conversion error')
133
  time.sleep(5)
 
134
  else:
135
  while not os.path.exists(str(CKPT_Path)):
136
  print('Wrong path, use the file explorer to copy the path')
 
149
  call('rm -f refmdlz', shell=True)
150
  wget.download('https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dreambooth/convertodiffv1.py')
151
  clear_output()
152
+ call('python convertodiffv1.py /models/model.ckpt /models/stable-diffusion-custom --v1', shell=True)
153
+ call('rm convertodiffv1.py', shell=True)
154
+ call('rm -r refmdl', shell=True)
155
  if os.path.exists('/models/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
156
+ call('rm /models/model.ckpt', shell=True)
157
  clear_output()
158
  done()
159
  else:
 
180
  else:
181
  MODEL_NAME="/datasets/stable-diffusion-diffusers/stable-diffusion-v1-5"
182
  print('Using the original V1.5 model')
183
+
184
+ call("sed -i 's@\"sample_size\": 256,@\"sample_size\": 512,@g' "+MODEL_NAME+"/vae/config.json", shell=True)
185
  return MODEL_NAME
186
 
187
 
 
248
  if n!="000":
249
  f(int(n))
250
  print('Using the model '+ mdls[int(n)]+" ...")
251
+ time.sleep(4)
252
  clear_output()
253
  else:
254
  print('Skipping the intermediary checkpoints.')
 
267
  call('unzip -o -q refmdlz', shell=True, stdout=open('/dev/null', 'w'))
268
  call('rm -f refmdlz', shell=True, stdout=open('/dev/null', 'w'))
269
  wget.download('https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dreambooth/convertodiffv1.py')
270
+ call('python convertodiffv1.py '+MDLPTH+' '+OUTPUT_DIR+' --v1', shell=True)
271
+ call('rm convertodiffv1.py', shell=True)
272
+ call('rm -r refmdl', shell=True)
273
 
 
274
  if os.path.exists(OUTPUT_DIR+'/unet/diffusion_pytorch_model.bin'):
275
  resume=True
276
  clear_output()
277
  print('Session loaded.')
278
  else:
279
+ print('Conversion error, if the error persists, remove the CKPT file from the current session folder')
 
280
 
281
  elif not os.path.exists(str(SESSION_DIR)):
282
  call('mkdir -p '+INSTANCE_DIR, shell=True)
 
375
  for filename in tqdm(os.listdir(IMAGES_FOLDER_OPTIONAL), bar_format=' |{bar:15}| {n_fmt}/{total_fmt} Uploaded'):
376
  call("cp -r " +IMAGES_FOLDER_OPTIONAL+"/. " +INSTANCE_DIR, shell=True)
377
 
 
 
378
  elif IMAGES_FOLDER_OPTIONAL =="":
379
  up=""
380
  for filename, file in uploader.value.items():
 
608
  call('accelerate launch /notebooks/diffusers/examples/dreambooth/train_dreambooth_pps.py \
609
  '+Style+' \
610
  '+extrnlcptn+' \
 
611
  --image_captions_filename \
612
  --train_only_unet \
613
  --Session_dir='+SESSION_DIR+' \
 
746
  os.chdir('/notebooks')
747
  call('nohup lt --port 7860 > srv.txt 2>&1 &', shell=True)
748
  time.sleep(2)
749
+ call("grep -o 'https[^ ]*' srv.txt >srvr.txt", shell=True)
750
  time.sleep(2)
751
+ srv= getoutput('cat srvr.txt')
752
 
753
  for line in fileinput.input('/usr/local/lib/python3.9/dist-packages/gradio/blocks.py', inplace=True):
754
  if line.strip().startswith('self.server_name ='):
 
763
  line = ''
764
  sys.stdout.write(line)
765
 
766
+ call('rm srv.txt srvr.txt', shell=True)
767
+
 
 
 
768
  os.chdir('/notebooks/sd/stable-diffusion-webui/modules')
769
  call('wget -q -O paths.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/paths.py', shell=True)
770
  call("sed -i 's@/content/gdrive/MyDrive/sd/stablediffusion@/notebooks/sd/stablediffusion@' /notebooks/sd/stable-diffusion-webui/modules/paths.py", shell=True)
771
  os.chdir('/notebooks/sd/stable-diffusion-webui')
772
  clear_output()
773
 
774
+ configf="--disable-console-progressbars --no-half-vae --disable-safe-unpickle --api --xformers --enable-insecure-extension-access --skip-version-check --ckpt "+path_to_trained_model+" "+auth+" "+share
775
 
776
  return configf
777
 
 
823
 
824
 
825
 
826
+ def hf(Name_of_your_concept, hf_token_write, INSTANCE_NAME, OUTPUT_DIR, Session_Name, MDLPTH):
827
 
828
  from slugify import slugify
829
  from huggingface_hub import HfApi, HfFolder, CommitOperationAdd
 
834
  if(Name_of_your_concept == ""):
835
  Name_of_your_concept = Session_Name
836
  Name_of_your_concept=Name_of_your_concept.replace(" ","-")
837
+
838
 
839
 
840
  if hf_token_write =="":
 
846
  api = HfApi()
847
  your_username = api.whoami(token=hf_token)["name"]
848
 
849
+ repo_id = f"{your_username}/{slugify(Name_of_your_concept)}"
 
 
 
 
 
850
  output_dir = f'/notebooks/models/'+INSTANCE_NAME
851
 
852
  def bar(prg):
853
+ clear_output()
854
  br="Uploading to HuggingFace : " '|'+'█' * prg + ' ' * (25-prg)+'| ' +str(prg*4)+ "%"
855
  return br
856
 
857
  print("Loading...")
858
 
 
859
  os.chdir(OUTPUT_DIR)
860
+ call('rm -r safety_checker feature_extractor .git', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
861
  call('rm model_index.json', shell=True)
862
+ call('git init', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
863
+ call('git lfs install --system --skip-repo', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
864
+ call('git remote add -f origin https://huggingface.co/runwayml/stable-diffusion-v1-5', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
865
+ call('git config core.sparsecheckout true', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
866
+ call('echo -e "\nfeature_extractor\nsafety_checker\nmodel_index.json\n!*.safetensors" > .git/info/sparse-checkout', shell=True)
867
+ call('git pull origin main', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
868
+ call('rm -r .git', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
869
+ os.chdir('/notebooks')
 
870
 
871
  print(bar(1))
872
 
 
905
  token=hf_token
906
  )
907
 
 
908
  print(bar(4))
909
 
910
  api.upload_folder(
 
914
  token=hf_token
915
  )
916
 
 
917
  print(bar(8))
918
 
919
  api.upload_folder(
 
923
  token=hf_token
924
  )
925
 
 
926
  print(bar(9))
927
 
928
  api.upload_folder(
 
932
  token=hf_token
933
  )
934
 
 
935
  print(bar(12))
936
 
937
  api.upload_folder(
 
941
  token=hf_token
942
  )
943
 
 
944
  print(bar(13))
945
 
946
  api.upload_folder(
 
950
  token=hf_token
951
  )
952
 
 
953
  print(bar(21))
954
 
955
  api.upload_folder(
 
959
  token=hf_token
960
  )
961
 
 
962
  print(bar(23))
963
 
964
  api.upload_file(
 
968
  token=hf_token
969
  )
970
 
 
971
  print(bar(25))
972
 
973
  print("Your concept was saved successfully at https://huggingface.co/"+repo_id)