Commit
·
70e80e3
1
Parent(s):
60481dc
Upload mainpaperspaceA1111.py
Browse files- Scripts/mainpaperspaceA1111.py +50 -52
Scripts/mainpaperspaceA1111.py
CHANGED
@@ -243,44 +243,46 @@ def mdls(Original_Model_Version, Path_to_MODEL, MODEL_LINK, Temporary_Storage):
|
|
243 |
|
244 |
def loradwn(LoRA_LINK):
|
245 |
|
246 |
-
|
247 |
-
|
248 |
-
src=getsrc(LoRA_LINK)
|
249 |
-
|
250 |
-
if src=='civitai':
|
251 |
-
modelname=get_name(LoRA_LINK, False)
|
252 |
-
loramodel=f'/notebooks/sd/stable-diffusion-webui/models/Lora/{modelname}'
|
253 |
-
if not os.path.exists(loramodel):
|
254 |
-
dwn(LoRA_LINK, loramodel, 'Downloading the LoRA model')
|
255 |
-
clear_output()
|
256 |
-
else:
|
257 |
-
print('[1;33mModel already exists')
|
258 |
-
elif src=='gdrive':
|
259 |
-
modelname=get_name(LoRA_LINK, True)
|
260 |
-
loramodel=f'/notebooks/sd/stable-diffusion-webui/models/Lora/{modelname}'
|
261 |
-
if not os.path.exists(loramodel):
|
262 |
-
gdown.download(url=LoRA_LINK, output=loramodel, quiet=False, fuzzy=True)
|
263 |
-
clear_output()
|
264 |
-
else:
|
265 |
-
print('[1;33mModel already exists')
|
266 |
else:
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
else:
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
|
|
|
|
|
|
|
|
|
|
280 |
|
281 |
|
282 |
|
283 |
-
def
|
284 |
|
285 |
def download(url, model_dir):
|
286 |
|
@@ -310,19 +312,15 @@ def CN(ControlNet_Model, ControlNet_v2_Model):
|
|
310 |
os.rename(os.path.join(mdldir, filename), os.path.join(mdldir, renamed))
|
311 |
|
312 |
call('wget -q -O CN_models.txt https://github.com/TheLastBen/fast-stable-diffusion/raw/main/AUTOMATIC1111_files/CN_models.txt', shell=True)
|
313 |
-
call('wget -q -O
|
314 |
-
|
315 |
with open("CN_models.txt", 'r') as f:
|
316 |
mdllnk = f.read().splitlines()
|
317 |
-
with open("
|
318 |
-
|
319 |
-
call('rm CN_models.txt
|
320 |
|
321 |
-
|
322 |
-
os.chdir('/notebooks/sd/stable-diffusion-webui/extensions/sd-webui-controlnet/models')
|
323 |
-
for name in cfgnames:
|
324 |
-
run(['cp', 'cldm_v21.yaml', name])
|
325 |
-
os.chdir('/notebooks')
|
326 |
|
327 |
if ControlNet_Model == "All" or ControlNet_Model == "all" :
|
328 |
for lnk in mdllnk:
|
@@ -349,28 +347,28 @@ def CN(ControlNet_Model, ControlNet_v2_Model):
|
|
349 |
print('[1;31mWrong ControlNet V1 choice, try again')
|
350 |
wrngv1=True
|
351 |
|
352 |
-
|
353 |
-
|
354 |
-
|
|
|
355 |
if not wrngv1:
|
356 |
clear_output()
|
357 |
done()
|
358 |
|
359 |
-
elif
|
360 |
-
download(
|
361 |
if not wrngv1:
|
362 |
clear_output()
|
363 |
done()
|
364 |
|
365 |
-
elif
|
366 |
pass
|
367 |
if not wrngv1:
|
368 |
-
|
369 |
done()
|
370 |
|
371 |
else:
|
372 |
-
print('[1;31mWrong ControlNet
|
373 |
-
|
374 |
|
375 |
|
376 |
|
|
|
243 |
|
244 |
def loradwn(LoRA_LINK):
|
245 |
|
246 |
+
if LoRA_LINK=='':
|
247 |
+
print('[1;33mNothing to do')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
else:
|
249 |
+
os.makedirs('/notebooks/sd/stable-diffusion-webui/models/Lora', exist_ok=True)
|
250 |
+
|
251 |
+
src=getsrc(LoRA_LINK)
|
252 |
+
|
253 |
+
if src=='civitai':
|
254 |
+
modelname=get_name(LoRA_LINK, False)
|
255 |
+
loramodel=f'/notebooks/sd/stable-diffusion-webui/models/Lora/{modelname}'
|
256 |
+
if not os.path.exists(loramodel):
|
257 |
+
dwn(LoRA_LINK, loramodel, 'Downloading the LoRA model')
|
258 |
+
clear_output()
|
259 |
+
else:
|
260 |
+
print('[1;33mModel already exists')
|
261 |
+
elif src=='gdrive':
|
262 |
+
modelname=get_name(LoRA_LINK, True)
|
263 |
+
loramodel=f'/notebooks/sd/stable-diffusion-webui/models/Lora/{modelname}'
|
264 |
+
if not os.path.exists(loramodel):
|
265 |
+
gdown.download(url=LoRA_LINK, output=loramodel, quiet=False, fuzzy=True)
|
266 |
+
clear_output()
|
267 |
+
else:
|
268 |
+
print('[1;33mModel already exists')
|
269 |
else:
|
270 |
+
modelname=os.path.basename(LoRA_LINK)
|
271 |
+
loramodel=f'/notebooks/sd/stable-diffusion-webui/models/Lora/{modelname}'
|
272 |
+
if not os.path.exists(loramodel):
|
273 |
+
gdown.download(url=LoRA_LINK, output=loramodel, quiet=False, fuzzy=True)
|
274 |
+
clear_output()
|
275 |
+
else:
|
276 |
+
print('[1;33mModel already exists')
|
277 |
+
|
278 |
+
if os.path.exists(loramodel) :
|
279 |
+
print('[1;32mLoRA downloaded')
|
280 |
+
else:
|
281 |
+
print('[1;31mWrong link, check that the link is valid')
|
282 |
|
283 |
|
284 |
|
285 |
+
def CNet(ControlNet_Model, ControlNet_XL_Model):
|
286 |
|
287 |
def download(url, model_dir):
|
288 |
|
|
|
312 |
os.rename(os.path.join(mdldir, filename), os.path.join(mdldir, renamed))
|
313 |
|
314 |
call('wget -q -O CN_models.txt https://github.com/TheLastBen/fast-stable-diffusion/raw/main/AUTOMATIC1111_files/CN_models.txt', shell=True)
|
315 |
+
call('wget -q -O CN_models_XL.txt https://github.com/TheLastBen/fast-stable-diffusion/raw/main/AUTOMATIC1111_files/CN_models_XL.txt', shell=True)
|
316 |
+
|
317 |
with open("CN_models.txt", 'r') as f:
|
318 |
mdllnk = f.read().splitlines()
|
319 |
+
with open("CN_models_XL.txt", 'r') as d:
|
320 |
+
mdllnk_XL = d.read().splitlines()
|
321 |
+
call('rm CN_models.txt CN_models_XL.txt', shell=True)
|
322 |
|
323 |
+
os.chdir('/notebooks')
|
|
|
|
|
|
|
|
|
324 |
|
325 |
if ControlNet_Model == "All" or ControlNet_Model == "all" :
|
326 |
for lnk in mdllnk:
|
|
|
347 |
print('[1;31mWrong ControlNet V1 choice, try again')
|
348 |
wrngv1=True
|
349 |
|
350 |
+
|
351 |
+
if ControlNet_XL_Model == "All" or ControlNet_XL_Model == "all" :
|
352 |
+
for lnk_XL in mdllnk_XL:
|
353 |
+
download(lnk_XL, mdldir)
|
354 |
if not wrngv1:
|
355 |
clear_output()
|
356 |
done()
|
357 |
|
358 |
+
elif ControlNet_XL_Model.isdigit() and int(ControlNet_XL_Model)-1<5:
|
359 |
+
download(mdllnk_XL[int(ControlNet_XL_Model)-1], mdldir)
|
360 |
if not wrngv1:
|
361 |
clear_output()
|
362 |
done()
|
363 |
|
364 |
+
elif ControlNet_XL_Model == "none":
|
365 |
pass
|
366 |
if not wrngv1:
|
367 |
+
clear_output()
|
368 |
done()
|
369 |
|
370 |
else:
|
371 |
+
print('[1;31mWrong ControlNet XL choice, try again')
|
|
|
372 |
|
373 |
|
374 |
|