TheLastBen commited on
Commit
1ac8906
1 Parent(s): 94a3f7f

Upload 3 files

Browse files
Scripts/mainpaperspaceA1111.py CHANGED
@@ -9,6 +9,10 @@ from torch.hub import download_url_to_file
9
  from urllib.parse import urlparse
10
  import re
11
 
 
 
 
 
12
 
13
 
14
  def Deps(force_reinstall):
@@ -18,7 +22,6 @@ def Deps(force_reinstall):
18
  print('Modules and notebooks updated, dependencies already installed')
19
 
20
  else:
21
- print('Installing the dependencies...')
22
  call("pip install --root-user-action=ignore --no-deps -q accelerate==0.12.0", shell=True, stdout=open('/dev/null', 'w'))
23
  if not os.path.exists('/usr/local/lib/python3.9/dist-packages/safetensors'):
24
  os.chdir('/usr/local/lib/python3.9/dist-packages')
@@ -36,7 +39,7 @@ def Deps(force_reinstall):
36
  os.chdir('/deps')
37
  call('wget -q -i https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dependencies/aptdeps.txt', shell=True)
38
  call('dpkg -i *.deb', shell=True, stdout=open('/dev/null', 'w'))
39
- call('wget -q https://huggingface.co/TheLastBen/dependencies/resolve/main/ppsdeps.tar.zst', shell=True, stdout=open('/dev/null', 'w'))
40
  call('tar -C / --zstd -xf ppsdeps.tar.zst', shell=True, stdout=open('/dev/null', 'w'))
41
  call("sed -i 's@~/.cache@/notebooks/cache@' /usr/local/lib/python3.9/dist-packages/transformers/utils/hub.py", shell=True)
42
  os.chdir('/notebooks')
@@ -51,6 +54,30 @@ def Deps(force_reinstall):
51
  done()
52
 
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  def ntbk():
55
 
56
  os.chdir('/notebooks')
@@ -267,7 +294,7 @@ def sdui(User, Password, model):
267
  mdlpth="--ckpt-dir "+model
268
 
269
 
270
- configf="--disable-console-progressbars --no-gradio-queue --no-half-vae --disable-safe-unpickle --api --no-download-sd-model --xformers --enable-insecure-extension-access --port 6006 --listen --skip-version-check "+auth+" "+mdlpth
271
 
272
  return configf
273
 
 
9
  from urllib.parse import urlparse
10
  import re
11
 
12
+ from urllib.request import urlopen, Request
13
+ import tempfile
14
+ from tqdm import tqdm
15
+
16
 
17
 
18
  def Deps(force_reinstall):
 
22
  print('Modules and notebooks updated, dependencies already installed')
23
 
24
  else:
 
25
  call("pip install --root-user-action=ignore --no-deps -q accelerate==0.12.0", shell=True, stdout=open('/dev/null', 'w'))
26
  if not os.path.exists('/usr/local/lib/python3.9/dist-packages/safetensors'):
27
  os.chdir('/usr/local/lib/python3.9/dist-packages')
 
39
  os.chdir('/deps')
40
  call('wget -q -i https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dependencies/aptdeps.txt', shell=True)
41
  call('dpkg -i *.deb', shell=True, stdout=open('/dev/null', 'w'))
42
+ depsinst("https://huggingface.co/TheLastBen/dependencies/resolve/main/ppsdeps.tar.zst", "/deps/ppsdeps.tar.zst", hash_prefix=None, progress=True)
43
  call('tar -C / --zstd -xf ppsdeps.tar.zst', shell=True, stdout=open('/dev/null', 'w'))
44
  call("sed -i 's@~/.cache@/notebooks/cache@' /usr/local/lib/python3.9/dist-packages/transformers/utils/hub.py", shell=True)
45
  os.chdir('/notebooks')
 
54
  done()
55
 
56
 
57
+ def depsinst(url, dst, hash_prefix=None, progress=True):
58
+ file_size = None
59
+ req = Request(url, headers={"User-Agent": "torch.hub"})
60
+ u = urlopen(req)
61
+ meta = u.info()
62
+ if hasattr(meta, 'getheaders'):
63
+ content_length = meta.getheaders("Content-Length")
64
+ else:
65
+ content_length = meta.get_all("Content-Length")
66
+ if content_length is not None and len(content_length) > 0:
67
+ file_size = int(content_length[0])
68
+
69
+ with tqdm(total=file_size, disable=not progress, mininterval=0.5,
70
+ bar_format='Installing dependencies |{bar:20}| {percentage:3.0f}%') as pbar:
71
+ with open(dst, "wb") as f:
72
+ while True:
73
+ buffer = u.read(8192)
74
+ if len(buffer) == 0:
75
+ break
76
+ f.write(buffer)
77
+ pbar.update(len(buffer))
78
+ f.close()
79
+
80
+
81
  def ntbk():
82
 
83
  os.chdir('/notebooks')
 
294
  mdlpth="--ckpt-dir "+model
295
 
296
 
297
+ configf="--disable-console-progressbars --no-half-vae --disable-safe-unpickle --api --no-download-sd-model --xformers --enable-insecure-extension-access --port 6006 --listen --skip-version-check "+auth+" "+mdlpth
298
 
299
  return configf
300
 
Scripts/mainpaperspacev1.py CHANGED
@@ -20,6 +20,11 @@ from collections import defaultdict
20
  from math import log, sqrt
21
  import numpy as np
22
 
 
 
 
 
 
23
 
24
 
25
  def Deps(force_reinstall):
@@ -29,7 +34,6 @@ def Deps(force_reinstall):
29
  print('Modules and notebooks updated, dependencies already installed')
30
 
31
  else:
32
- print('Installing the dependencies...')
33
  call("pip install --root-user-action=ignore --no-deps -q accelerate==0.12.0", shell=True, stdout=open('/dev/null', 'w'))
34
  if not os.path.exists('/usr/local/lib/python3.9/dist-packages/safetensors'):
35
  os.chdir('/usr/local/lib/python3.9/dist-packages')
@@ -47,7 +51,7 @@ def Deps(force_reinstall):
47
  os.chdir('/deps')
48
  call('wget -q -i https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dependencies/aptdeps.txt', shell=True)
49
  call('dpkg -i *.deb', shell=True, stdout=open('/dev/null', 'w'))
50
- call('wget -q https://huggingface.co/TheLastBen/dependencies/resolve/main/ppsdeps.tar.zst', shell=True, stdout=open('/dev/null', 'w'))
51
  call('tar -C / --zstd -xf ppsdeps.tar.zst', shell=True, stdout=open('/dev/null', 'w'))
52
  call("sed -i 's@~/.cache@/notebooks/cache@' /usr/local/lib/python3.9/dist-packages/transformers/utils/hub.py", shell=True)
53
  os.chdir('/notebooks')
@@ -60,6 +64,31 @@ def Deps(force_reinstall):
60
  clear_output()
61
 
62
  done()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
 
65
  def ntbk():
@@ -784,7 +813,7 @@ def testui(Custom_Path, Previous_Session_Name, Session_Name, User, Password):
784
  os.chdir('/notebooks/sd/stable-diffusion-webui')
785
  clear_output()
786
 
787
- configf="--disable-console-progressbars --no-gradio-queue --no-half-vae --disable-safe-unpickle --api --no-download-sd-model --xformers --enable-insecure-extension-access --port 6006 --listen --skip-version-check --ckpt "+path_to_trained_model+" "+auth
788
 
789
  return configf
790
 
 
20
  from math import log, sqrt
21
  import numpy as np
22
 
23
+ from urllib.request import urlopen, Request
24
+ import tempfile
25
+ from tqdm import tqdm
26
+
27
+
28
 
29
 
30
  def Deps(force_reinstall):
 
34
  print('Modules and notebooks updated, dependencies already installed')
35
 
36
  else:
 
37
  call("pip install --root-user-action=ignore --no-deps -q accelerate==0.12.0", shell=True, stdout=open('/dev/null', 'w'))
38
  if not os.path.exists('/usr/local/lib/python3.9/dist-packages/safetensors'):
39
  os.chdir('/usr/local/lib/python3.9/dist-packages')
 
51
  os.chdir('/deps')
52
  call('wget -q -i https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dependencies/aptdeps.txt', shell=True)
53
  call('dpkg -i *.deb', shell=True, stdout=open('/dev/null', 'w'))
54
+ depsinst("https://huggingface.co/TheLastBen/dependencies/resolve/main/ppsdeps.tar.zst", "/deps/ppsdeps.tar.zst", hash_prefix=None, progress=True)
55
  call('tar -C / --zstd -xf ppsdeps.tar.zst', shell=True, stdout=open('/dev/null', 'w'))
56
  call("sed -i 's@~/.cache@/notebooks/cache@' /usr/local/lib/python3.9/dist-packages/transformers/utils/hub.py", shell=True)
57
  os.chdir('/notebooks')
 
64
  clear_output()
65
 
66
  done()
67
+
68
+
69
+
70
+ def depsinst(url, dst, hash_prefix=None, progress=True):
71
+ file_size = None
72
+ req = Request(url, headers={"User-Agent": "torch.hub"})
73
+ u = urlopen(req)
74
+ meta = u.info()
75
+ if hasattr(meta, 'getheaders'):
76
+ content_length = meta.getheaders("Content-Length")
77
+ else:
78
+ content_length = meta.get_all("Content-Length")
79
+ if content_length is not None and len(content_length) > 0:
80
+ file_size = int(content_length[0])
81
+
82
+ with tqdm(total=file_size, disable=not progress, mininterval=0.5,
83
+ bar_format='Installing dependencies |{bar:20}| {percentage:3.0f}%') as pbar:
84
+ with open(dst, "wb") as f:
85
+ while True:
86
+ buffer = u.read(8192)
87
+ if len(buffer) == 0:
88
+ break
89
+ f.write(buffer)
90
+ pbar.update(len(buffer))
91
+ f.close()
92
 
93
 
94
  def ntbk():
 
813
  os.chdir('/notebooks/sd/stable-diffusion-webui')
814
  clear_output()
815
 
816
+ configf="--disable-console-progressbars --no-half-vae --disable-safe-unpickle --api --no-download-sd-model --xformers --enable-insecure-extension-access --port 6006 --listen --skip-version-check --ckpt "+path_to_trained_model+" "+auth
817
 
818
  return configf
819
 
Scripts/mainpaperspacev2.py CHANGED
@@ -21,6 +21,11 @@ from math import log, sqrt
21
  import numpy as np
22
  from subprocess import check_output
23
 
 
 
 
 
 
24
 
25
 
26
  def Deps(force_reinstall):
@@ -30,7 +35,6 @@ def Deps(force_reinstall):
30
  print('Modules and notebooks updated, dependencies already installed')
31
 
32
  else:
33
- print('Installing the dependencies...')
34
  call("pip install --root-user-action=ignore --no-deps -q accelerate==0.12.0", shell=True, stdout=open('/dev/null', 'w'))
35
  if not os.path.exists('/usr/local/lib/python3.9/dist-packages/safetensors'):
36
  os.chdir('/usr/local/lib/python3.9/dist-packages')
@@ -48,7 +52,7 @@ def Deps(force_reinstall):
48
  os.chdir('/deps')
49
  call('wget -q -i https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dependencies/aptdeps.txt', shell=True)
50
  call('dpkg -i *.deb', shell=True, stdout=open('/dev/null', 'w'))
51
- call('wget -q https://huggingface.co/TheLastBen/dependencies/resolve/main/ppsdeps.tar.zst', shell=True, stdout=open('/dev/null', 'w'))
52
  call('tar -C / --zstd -xf ppsdeps.tar.zst', shell=True, stdout=open('/dev/null', 'w'))
53
  call("sed -i 's@~/.cache@/notebooks/cache@' /usr/local/lib/python3.9/dist-packages/transformers/utils/hub.py", shell=True)
54
  os.chdir('/notebooks')
@@ -63,6 +67,30 @@ def Deps(force_reinstall):
63
  done()
64
 
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  def ntbk():
67
 
68
  os.chdir('/notebooks')
@@ -832,14 +860,13 @@ def testui(Custom_Path, Previous_Session_Name, Session_Name, User, Password):
832
  os.chdir('/notebooks/sd/stable-diffusion-webui')
833
  clear_output()
834
 
835
- configf="--disable-console-progressbars --no-gradio-queue --no-half-vae --disable-safe-unpickle --api --no-download-sd-model --xformers --enable-insecure-extension-access --port 6006 --listen --skip-version-check --ckpt "+path_to_trained_model+" "+auth
836
 
837
  return configf
838
 
839
 
840
 
841
 
842
-
843
  def clean():
844
 
845
  Sessions=os.listdir("/notebooks/Fast-Dreambooth/Sessions")
 
21
  import numpy as np
22
  from subprocess import check_output
23
 
24
+ from urllib.request import urlopen, Request
25
+ import tempfile
26
+ from tqdm import tqdm
27
+
28
+
29
 
30
 
31
  def Deps(force_reinstall):
 
35
  print('Modules and notebooks updated, dependencies already installed')
36
 
37
  else:
 
38
  call("pip install --root-user-action=ignore --no-deps -q accelerate==0.12.0", shell=True, stdout=open('/dev/null', 'w'))
39
  if not os.path.exists('/usr/local/lib/python3.9/dist-packages/safetensors'):
40
  os.chdir('/usr/local/lib/python3.9/dist-packages')
 
52
  os.chdir('/deps')
53
  call('wget -q -i https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dependencies/aptdeps.txt', shell=True)
54
  call('dpkg -i *.deb', shell=True, stdout=open('/dev/null', 'w'))
55
+ depsinst("https://huggingface.co/TheLastBen/dependencies/resolve/main/ppsdeps.tar.zst", "/deps/ppsdeps.tar.zst", hash_prefix=None, progress=True)
56
  call('tar -C / --zstd -xf ppsdeps.tar.zst', shell=True, stdout=open('/dev/null', 'w'))
57
  call("sed -i 's@~/.cache@/notebooks/cache@' /usr/local/lib/python3.9/dist-packages/transformers/utils/hub.py", shell=True)
58
  os.chdir('/notebooks')
 
67
  done()
68
 
69
 
70
+ def depsinst(url, dst, hash_prefix=None, progress=True):
71
+ file_size = None
72
+ req = Request(url, headers={"User-Agent": "torch.hub"})
73
+ u = urlopen(req)
74
+ meta = u.info()
75
+ if hasattr(meta, 'getheaders'):
76
+ content_length = meta.getheaders("Content-Length")
77
+ else:
78
+ content_length = meta.get_all("Content-Length")
79
+ if content_length is not None and len(content_length) > 0:
80
+ file_size = int(content_length[0])
81
+
82
+ with tqdm(total=file_size, disable=not progress, mininterval=0.5,
83
+ bar_format='Installing dependencies |{bar:20}| {percentage:3.0f}%') as pbar:
84
+ with open(dst, "wb") as f:
85
+ while True:
86
+ buffer = u.read(8192)
87
+ if len(buffer) == 0:
88
+ break
89
+ f.write(buffer)
90
+ pbar.update(len(buffer))
91
+ f.close()
92
+
93
+
94
  def ntbk():
95
 
96
  os.chdir('/notebooks')
 
860
  os.chdir('/notebooks/sd/stable-diffusion-webui')
861
  clear_output()
862
 
863
+ configf="--disable-console-progressbars --no-half-vae --disable-safe-unpickle --api --no-download-sd-model --xformers --enable-insecure-extension-access --port 6006 --listen --skip-version-check --ckpt "+path_to_trained_model+" "+auth
864
 
865
  return configf
866
 
867
 
868
 
869
 
 
870
  def clean():
871
 
872
  Sessions=os.listdir("/notebooks/Fast-Dreambooth/Sessions")