TheLastBen
commited on
Commit
•
0d2c9ea
1
Parent(s):
96e1d4d
Update Scripts/mainpaperspaceA1111.py
Browse files- Scripts/mainpaperspaceA1111.py +48 -10
Scripts/mainpaperspaceA1111.py
CHANGED
@@ -130,9 +130,7 @@ def mdl(Original_Model_Version, Path_to_MODEL, MODEL_LINK, safetensors, Temporar
|
|
130 |
return model
|
131 |
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
def CN(ControlNet_Model):
|
136 |
|
137 |
def download(url, model_dir):
|
138 |
|
@@ -154,25 +152,65 @@ def CN(ControlNet_Model):
|
|
154 |
call('git reset --hard', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
155 |
call('git pull', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
156 |
os.chdir('/notebooks')
|
157 |
-
|
158 |
-
call('cp /notebooks/sd/stable-diffusion-webui/extensions/sd-webui-controlnet/models/*.yaml /notebooks/sd/stable-diffusion-webui/models', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
159 |
mdldir="/notebooks/sd/stable-diffusion-webui/extensions/sd-webui-controlnet/models"
|
|
|
|
|
|
|
|
|
160 |
|
161 |
call('wget -q -O CN_models.txt https://github.com/TheLastBen/fast-stable-diffusion/raw/main/AUTOMATIC1111_files/CN_models.txt', shell=True)
|
|
|
|
|
162 |
with open("CN_models.txt", 'r') as f:
|
163 |
mdllnk = f.read().splitlines()
|
164 |
-
|
|
|
|
|
165 |
|
166 |
-
if ControlNet_Model == "All":
|
167 |
for lnk in mdllnk:
|
168 |
-
download(
|
169 |
clear_output()
|
170 |
-
|
171 |
|
172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
download(mdllnk[int(ControlNet_Model)-1], mdldir)
|
174 |
clear_output()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
done()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
|
177 |
|
178 |
|
|
|
130 |
return model
|
131 |
|
132 |
|
133 |
+
def CN(ControlNet_Model, ControlNet_v2_Model):
|
|
|
|
|
134 |
|
135 |
def download(url, model_dir):
|
136 |
|
|
|
152 |
call('git reset --hard', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
153 |
call('git pull', shell=True, stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
|
154 |
os.chdir('/notebooks')
|
155 |
+
|
|
|
156 |
mdldir="/notebooks/sd/stable-diffusion-webui/extensions/sd-webui-controlnet/models"
|
157 |
+
for filename in os.listdir(mdldir):
|
158 |
+
if "_sd14v1" in filename:
|
159 |
+
renamed = re.sub("_sd14v1", "-fp16", filename)
|
160 |
+
os.rename(os.path.join(mdldir, filename), os.path.join(mdldir, renamed))
|
161 |
|
162 |
call('wget -q -O CN_models.txt https://github.com/TheLastBen/fast-stable-diffusion/raw/main/AUTOMATIC1111_files/CN_models.txt', shell=True)
|
163 |
+
call('wget -q -O CN_models_v2.txt https://github.com/TheLastBen/fast-stable-diffusion/raw/main/AUTOMATIC1111_files/CN_models_v2.txt', shell=True)
|
164 |
+
|
165 |
with open("CN_models.txt", 'r') as f:
|
166 |
mdllnk = f.read().splitlines()
|
167 |
+
with open("CN_models_v2.txt", 'r') as d:
|
168 |
+
mdllnk_v2 = d.read().splitlines()
|
169 |
+
call('rm CN_models.txt CN_models_v2.txt', shell=True)
|
170 |
|
171 |
+
if ControlNet_Model == "All" or ControlNet_Model == "all" :
|
172 |
for lnk in mdllnk:
|
173 |
+
download(lnk, mdldir)
|
174 |
clear_output()
|
175 |
+
|
176 |
|
177 |
+
elif ControlNet_Model == "9":
|
178 |
+
mdllnk=list(filter(lambda x: 't2i' in x, mdllnk))
|
179 |
+
for lnk in mdllnk:
|
180 |
+
download(lnk, mdldir)
|
181 |
+
clear_output()
|
182 |
+
|
183 |
+
|
184 |
+
elif ControlNet_Model.isdigit() and int(ControlNet_Model)-1<8:
|
185 |
download(mdllnk[int(ControlNet_Model)-1], mdldir)
|
186 |
clear_output()
|
187 |
+
|
188 |
+
elif ControlNet_Model == "none":
|
189 |
+
pass
|
190 |
+
clear_output()
|
191 |
+
|
192 |
+
else:
|
193 |
+
print('[1;31mWrong ControlNet V1 choice, try again')
|
194 |
+
|
195 |
+
|
196 |
+
if ControlNet_v2_Model == "All" or ControlNet_v2_Model == "all" :
|
197 |
+
for lnk_v2 in mdllnk_v2:
|
198 |
+
download(lnk_v2, mdldir)
|
199 |
+
clear_output()
|
200 |
+
done()
|
201 |
+
|
202 |
+
elif ControlNet_v2_Model.isdigit() and int(ControlNet_v2_Model)-1<5:
|
203 |
+
download(mdllnk_v2[int(ControlNet_v2_Model)-1], mdldir)
|
204 |
+
clear_output()
|
205 |
done()
|
206 |
+
|
207 |
+
elif ControlNet_v2_Model == "none":
|
208 |
+
pass
|
209 |
+
clear_output()
|
210 |
+
done()
|
211 |
+
|
212 |
+
else:
|
213 |
+
print('[1;31mWrong ControlNet V2 choice, try again')
|
214 |
|
215 |
|
216 |
|