TheLastBen commited on
Commit
13040f6
1 Parent(s): 65d37bf

Update mainpaperspacev1.py

Browse files
Files changed (1) hide show
  1. mainpaperspacev1.py +30 -31
mainpaperspacev1.py CHANGED
@@ -61,8 +61,8 @@ def Deps(force_reinstall):
61
  def downloadmodel_hf(Path_to_HuggingFace):
62
  import wget
63
 
64
- if os.path.exists('/notebooks/stable-diffusion-custom'):
65
- call("rm -r /notebooks/stable-diffusion-custom", shell=True)
66
  clear_output()
67
 
68
  if os.path.exists('/notebooks/Fast-Dreambooth/token.txt'):
@@ -72,27 +72,27 @@ def downloadmodel_hf(Path_to_HuggingFace):
72
  else:
73
  authe="https://"
74
 
75
- os.chdir('/notebooks')
76
  clear_output()
77
- call("mkdir /notebooks/stable-diffusion-custom", shell=True)
78
- os.chdir("/notebooks/stable-diffusion-custom")
79
  call("git init", shell=True)
80
  call("git lfs install --system --skip-repo", shell=True)
81
  call('git remote add -f origin '+authe+'huggingface.co/'+Path_to_HuggingFace, shell=True)
82
  call("git config core.sparsecheckout true", shell=True)
83
  call('echo -e "\nscheduler\ntext_encoder\ntokenizer\nunet\nvae\nmodel_index.json\n!*.safetensors" > .git/info/sparse-checkout', shell=True)
84
  call("git pull origin main", shell=True)
85
- if os.path.exists('/notebooks/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
86
- call("rm -r /notebooks/stable-diffusion-custom/.git", shell=True)
87
- call("rm -r /notebooks/stable-diffusion-custom/model_index.json", shell=True)
88
  wget.download('https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dreambooth/model_index.json')
89
  os.chdir('/notebooks')
90
  clear_output()
91
  done()
92
- else:
93
- while not os.path.exists('/notebooks/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
94
- print('Check the link you provided')
95
- time.sleep(5)
 
96
 
97
 
98
 
@@ -109,18 +109,17 @@ def downloadmodel_pth(CKPT_Path):
109
  call('python /notebooks/convertodiffv1.py '+CKPT_Path+' /models/stable-diffusion-custom --v1', shell=True)
110
  call('rm /notebooks/convertodiffv1.py', shell=True)
111
  call('rm -r /notebooks/refmdl', shell=True)
112
- if os.path.exists('/notebooks/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
113
  clear_output()
114
  done()
115
- else:
116
- call('rm -r /notebooks/stable-diffusion-custom', shell=True)
117
- while not os.path.exists('/notebooks/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
118
- print('Conversion error')
119
- time.sleep(5)
120
  else:
121
  while not os.path.exists(str(CKPT_Path)):
122
  print('Wrong path, use the colab file explorer to copy the path')
123
- time.sleep(5)
124
 
125
 
126
  def downloadmodel_lnk(CKPT_Link):
@@ -128,43 +127,43 @@ def downloadmodel_lnk(CKPT_Link):
128
  os.chdir('/notebooks')
129
  gdown.download(url=CKPT_Link, output="model.ckpt", quiet=False, fuzzy=True)
130
 
131
- if os.path.exists('/notebooks/model.ckpt'):
132
- if os.path.getsize("/notebooks/model.ckpt") > 1810671599:
133
  wget.download('https://github.com/TheLastBen/fast-stable-diffusion/raw/main/Dreambooth/refmdlz')
134
  call('unzip -o -q refmdlz', shell=True)
135
  call('rm -f refmdlz', shell=True)
136
  wget.download('https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dreambooth/convertodiffv1.py')
137
  clear_output()
138
- call('python /notebooks/convertodiffv1.py '+CKPT_Path+' /models/stable-diffusion-custom --v1', shell=True)
139
  call('rm /notebooks/convertodiffv1.py', shell=True)
140
  call('rm -r /notebooks/refmdl', shell=True)
141
- if os.path.exists('/notebooks/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
142
  clear_output()
143
  done()
144
  else:
145
- call('rm -r /notebooks/stable-diffusion-custom', shell=True)
146
- while not os.path.exists('/notebooks/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
147
  print('Conversion error')
148
  time.sleep(5)
149
  else:
150
- while os.path.getsize('/notebooks/model.ckpt') < 1810671599:
151
  print('Wrong link, check that the link is valid')
152
  time.sleep(5)
153
-
154
 
155
  def dl(Path_to_HuggingFace, CKPT_Path, CKPT_Link):
156
 
157
  if Path_to_HuggingFace != "":
158
  downloadmodel_hf(Path_to_HuggingFace)
159
- MODEL_NAME="/notebooks/stable-diffusion-custom"
160
  elif CKPT_Path !="":
161
  downloadmodel_pth(CKPT_Path)
162
- MODEL_NAME="/notebooks/stable-diffusion-custom"
163
  elif CKPT_Link !="":
164
  downloadmodel_lnk(CKPT_Link)
165
- MODEL_NAME="/notebooks/stable-diffusion-custom"
166
  else:
167
- MODEL_NAME="dataset"
168
  print('Using the original V1.5 model')
169
 
170
  return MODEL_NAME
 
61
  def downloadmodel_hf(Path_to_HuggingFace):
62
  import wget
63
 
64
+ if os.path.exists('/models/stable-diffusion-custom'):
65
+ call("rm -r /models/stable-diffusion-custom", shell=True)
66
  clear_output()
67
 
68
  if os.path.exists('/notebooks/Fast-Dreambooth/token.txt'):
 
72
  else:
73
  authe="https://"
74
 
 
75
  clear_output()
76
+ call("mkdir /models/stable-diffusion-custom", shell=True)
77
+ os.chdir("/models/stable-diffusion-custom")
78
  call("git init", shell=True)
79
  call("git lfs install --system --skip-repo", shell=True)
80
  call('git remote add -f origin '+authe+'huggingface.co/'+Path_to_HuggingFace, shell=True)
81
  call("git config core.sparsecheckout true", shell=True)
82
  call('echo -e "\nscheduler\ntext_encoder\ntokenizer\nunet\nvae\nmodel_index.json\n!*.safetensors" > .git/info/sparse-checkout', shell=True)
83
  call("git pull origin main", shell=True)
84
+ if os.path.exists('/models/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
85
+ call("rm -r /models/stable-diffusion-custom/.git", shell=True)
86
+ call("rm -r /models/stable-diffusion-custom/model_index.json", shell=True)
87
  wget.download('https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dreambooth/model_index.json')
88
  os.chdir('/notebooks')
89
  clear_output()
90
  done()
91
+
92
+ while not os.path.exists('/models/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
93
+ print('Check the link you provided')
94
+ os.chdir('/notebooks')
95
+ time.sleep(5)
96
 
97
 
98
 
 
109
  call('python /notebooks/convertodiffv1.py '+CKPT_Path+' /models/stable-diffusion-custom --v1', shell=True)
110
  call('rm /notebooks/convertodiffv1.py', shell=True)
111
  call('rm -r /notebooks/refmdl', shell=True)
112
+ if os.path.exists('/models/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
113
  clear_output()
114
  done()
115
+ while not os.path.exists('/models/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
116
+ print('Conversion error')
117
+ time.sleep(5)
118
+
 
119
  else:
120
  while not os.path.exists(str(CKPT_Path)):
121
  print('Wrong path, use the colab file explorer to copy the path')
122
+ time.sleep(5)
123
 
124
 
125
  def downloadmodel_lnk(CKPT_Link):
 
127
  os.chdir('/notebooks')
128
  gdown.download(url=CKPT_Link, output="model.ckpt", quiet=False, fuzzy=True)
129
 
130
+ if os.path.exists('/models/model.ckpt'):
131
+ if os.path.getsize("/models/model.ckpt") > 1810671599:
132
  wget.download('https://github.com/TheLastBen/fast-stable-diffusion/raw/main/Dreambooth/refmdlz')
133
  call('unzip -o -q refmdlz', shell=True)
134
  call('rm -f refmdlz', shell=True)
135
  wget.download('https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dreambooth/convertodiffv1.py')
136
  clear_output()
137
+ call('python /notebooks/convertodiffv1.py /models/model.ckpt /models/stable-diffusion-custom --v1', shell=True)
138
  call('rm /notebooks/convertodiffv1.py', shell=True)
139
  call('rm -r /notebooks/refmdl', shell=True)
140
+ if os.path.exists('/models/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
141
  clear_output()
142
  done()
143
  else:
144
+ call('rm -r /models/stable-diffusion-custom', shell=True)
145
+ while not os.path.exists('/models/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
146
  print('Conversion error')
147
  time.sleep(5)
148
  else:
149
+ while os.path.getsize('/models/model.ckpt') < 1810671599:
150
  print('Wrong link, check that the link is valid')
151
  time.sleep(5)
152
+ call('rm -r /models/model.ckpt', shell=True)
153
 
154
  def dl(Path_to_HuggingFace, CKPT_Path, CKPT_Link):
155
 
156
  if Path_to_HuggingFace != "":
157
  downloadmodel_hf(Path_to_HuggingFace)
158
+ MODEL_NAME="/models/stable-diffusion-custom"
159
  elif CKPT_Path !="":
160
  downloadmodel_pth(CKPT_Path)
161
+ MODEL_NAME="/models/stable-diffusion-custom"
162
  elif CKPT_Link !="":
163
  downloadmodel_lnk(CKPT_Link)
164
+ MODEL_NAME="/models/stable-diffusion-custom"
165
  else:
166
+ MODEL_NAME="/datasets/stable-diffusion-diffusers/stable-diffusion-v1-5"
167
  print('Using the original V1.5 model')
168
 
169
  return MODEL_NAME