TheLastBen
commited on
Commit
•
dc5f674
1
Parent(s):
456ff14
Update Scripts/mainpaperspacev2.py
Browse files- Scripts/mainpaperspacev2.py +13 -13
Scripts/mainpaperspacev2.py
CHANGED
@@ -32,7 +32,7 @@ def Deps(force_reinstall):
|
|
32 |
call("pip install --root-user-action=ignore --no-deps -q accelerate==0.12.0", shell=True, stdout=open('/dev/null', 'w'))
|
33 |
if not os.path.exists('/usr/local/lib/python3.9/dist-packages/safetensors'):
|
34 |
os.chdir('/usr/local/lib/python3.9/dist-packages')
|
35 |
-
call("rm -r torch torch-1.12.
|
36 |
ntbk()
|
37 |
if not os.path.exists('/models'):
|
38 |
call('mkdir /models', shell=True)
|
@@ -110,7 +110,7 @@ def downloadmodel_hfv2(Path_to_HuggingFace):
|
|
110 |
|
111 |
|
112 |
|
113 |
-
def downloadmodel_pthv2(
|
114 |
|
115 |
sftnsr=""
|
116 |
if safetensors:
|
@@ -119,13 +119,13 @@ def downloadmodel_pthv2(CKPT_Path, Custom_Model_Version, safetensors):
|
|
119 |
import wget
|
120 |
os.chdir('/models')
|
121 |
clear_output()
|
122 |
-
if os.path.exists(str(
|
123 |
if Custom_Model_Version=='512':
|
124 |
call('wget -q -O convertodiffv2.py https://github.com/TheLastBen/fast-stable-diffusion/raw/main/Dreambooth/convertodiffv2.py', shell=True)
|
125 |
-
call('python convertodiffv2.py '+
|
126 |
elif Custom_Model_Version=='768':
|
127 |
call('wget -q -O convertodiffv2.py https://github.com/TheLastBen/fast-stable-diffusion/raw/main/Dreambooth/convertodiffv2-768.py', shell=True)
|
128 |
-
call('python convertodiffv2.py '+
|
129 |
|
130 |
call('rm convertodiffv2.py', shell=True)
|
131 |
if os.path.exists('stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
|
@@ -137,14 +137,14 @@ def downloadmodel_pthv2(CKPT_Path, Custom_Model_Version, safetensors):
|
|
137 |
os.chdir('/notebooks')
|
138 |
time.sleep(5)
|
139 |
else:
|
140 |
-
while not os.path.exists(str(
|
141 |
print('[1;31mWrong path, use the file explorer to copy the path')
|
142 |
os.chdir('/notebooks')
|
143 |
time.sleep(5)
|
144 |
|
145 |
|
146 |
|
147 |
-
def downloadmodel_lnkv2(
|
148 |
|
149 |
sftnsr=""
|
150 |
if not safetensors:
|
@@ -155,7 +155,7 @@ def downloadmodel_lnkv2(CKPT_Link, Custom_Model_Version, safetensors):
|
|
155 |
|
156 |
import wget
|
157 |
os.chdir('/models')
|
158 |
-
call("gdown --fuzzy " +
|
159 |
|
160 |
if os.path.exists("/models/"+modelnm):
|
161 |
if os.path.getsize("/models/"+modelnm) > 1810671599:
|
@@ -186,16 +186,16 @@ def downloadmodel_lnkv2(CKPT_Link, Custom_Model_Version, safetensors):
|
|
186 |
|
187 |
|
188 |
|
189 |
-
def dlv2(Path_to_HuggingFace,
|
190 |
|
191 |
if Path_to_HuggingFace != "":
|
192 |
downloadmodel_hfv2(Path_to_HuggingFace)
|
193 |
MODEL_NAMEv2="/models/stable-diffusion-custom"
|
194 |
-
elif
|
195 |
-
downloadmodel_pthv2(
|
196 |
MODEL_NAMEv2="/models/stable-diffusion-custom"
|
197 |
-
elif
|
198 |
-
downloadmodel_lnkv2(
|
199 |
MODEL_NAMEv2="/models/stable-diffusion-custom"
|
200 |
else:
|
201 |
if Model_Version=="512":
|
|
|
32 |
call("pip install --root-user-action=ignore --no-deps -q accelerate==0.12.0", shell=True, stdout=open('/dev/null', 'w'))
|
33 |
if not os.path.exists('/usr/local/lib/python3.9/dist-packages/safetensors'):
|
34 |
os.chdir('/usr/local/lib/python3.9/dist-packages')
|
35 |
+
call("rm -r torch torch-1.12.1+cu116.dist-info torchaudio* torchvision* PIL Pillow* transformers* numpy* gdown*", shell=True, stdout=open('/dev/null', 'w'))
|
36 |
ntbk()
|
37 |
if not os.path.exists('/models'):
|
38 |
call('mkdir /models', shell=True)
|
|
|
110 |
|
111 |
|
112 |
|
113 |
+
def downloadmodel_pthv2(Model_Path, Custom_Model_Version, safetensors):
|
114 |
|
115 |
sftnsr=""
|
116 |
if safetensors:
|
|
|
119 |
import wget
|
120 |
os.chdir('/models')
|
121 |
clear_output()
|
122 |
+
if os.path.exists(str(Model_Path)):
|
123 |
if Custom_Model_Version=='512':
|
124 |
call('wget -q -O convertodiffv2.py https://github.com/TheLastBen/fast-stable-diffusion/raw/main/Dreambooth/convertodiffv2.py', shell=True)
|
125 |
+
call('python convertodiffv2.py '+Model_Path+' stable-diffusion-custom --v2 --reference_model stabilityai/stable-diffusion-2-1-base '+sftnsr, shell=True)
|
126 |
elif Custom_Model_Version=='768':
|
127 |
call('wget -q -O convertodiffv2.py https://github.com/TheLastBen/fast-stable-diffusion/raw/main/Dreambooth/convertodiffv2-768.py', shell=True)
|
128 |
+
call('python convertodiffv2.py '+Model_Path+' stable-diffusion-custom --v2 --reference_model stabilityai/stable-diffusion-2-1 '+sftnsr, shell=True)
|
129 |
|
130 |
call('rm convertodiffv2.py', shell=True)
|
131 |
if os.path.exists('stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):
|
|
|
137 |
os.chdir('/notebooks')
|
138 |
time.sleep(5)
|
139 |
else:
|
140 |
+
while not os.path.exists(str(Model_Path)):
|
141 |
print('[1;31mWrong path, use the file explorer to copy the path')
|
142 |
os.chdir('/notebooks')
|
143 |
time.sleep(5)
|
144 |
|
145 |
|
146 |
|
147 |
+
def downloadmodel_lnkv2(Model_Link, Custom_Model_Version, safetensors):
|
148 |
|
149 |
sftnsr=""
|
150 |
if not safetensors:
|
|
|
155 |
|
156 |
import wget
|
157 |
os.chdir('/models')
|
158 |
+
call("gdown --fuzzy " +Model_Link+ " -O /models/"+modelnm, shell=True)
|
159 |
|
160 |
if os.path.exists("/models/"+modelnm):
|
161 |
if os.path.getsize("/models/"+modelnm) > 1810671599:
|
|
|
186 |
|
187 |
|
188 |
|
189 |
+
def dlv2(Path_to_HuggingFace, Model_Path, Model_Link, Model_Version, Custom_Model_Version, safetensors):
|
190 |
|
191 |
if Path_to_HuggingFace != "":
|
192 |
downloadmodel_hfv2(Path_to_HuggingFace)
|
193 |
MODEL_NAMEv2="/models/stable-diffusion-custom"
|
194 |
+
elif Model_Path !="":
|
195 |
+
downloadmodel_pthv2(Model_Path, Custom_Model_Version, safetensors)
|
196 |
MODEL_NAMEv2="/models/stable-diffusion-custom"
|
197 |
+
elif Model_Link !="":
|
198 |
+
downloadmodel_lnkv2(Model_Link, Custom_Model_Version, safetensors)
|
199 |
MODEL_NAMEv2="/models/stable-diffusion-custom"
|
200 |
else:
|
201 |
if Model_Version=="512":
|