TheLastBen
commited on
Commit
•
29ddb9a
1
Parent(s):
db435ca
Update Scripts/mainpaperspaceA1111.py
Browse files
Scripts/mainpaperspaceA1111.py
CHANGED
@@ -84,6 +84,32 @@ def depsinst(url, dst):
|
|
84 |
f.close()
|
85 |
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
def ntbk():
|
88 |
|
89 |
os.chdir('/notebooks')
|
|
|
84 |
f.close()
|
85 |
|
86 |
|
87 |
+
|
88 |
+
def dwn(url, dst, msg):
|
89 |
+
file_size = None
|
90 |
+
req = Request(url, headers={"User-Agent": "torch.hub"})
|
91 |
+
u = urlopen(req)
|
92 |
+
meta = u.info()
|
93 |
+
if hasattr(meta, 'getheaders'):
|
94 |
+
content_length = meta.getheaders("Content-Length")
|
95 |
+
else:
|
96 |
+
content_length = meta.get_all("Content-Length")
|
97 |
+
if content_length is not None and len(content_length) > 0:
|
98 |
+
file_size = int(content_length[0])
|
99 |
+
|
100 |
+
with tqdm(total=file_size, disable=False, mininterval=0.5,
|
101 |
+
bar_format=msg+' |{bar:20}| {percentage:3.0f}%') as pbar:
|
102 |
+
with open(dst, "wb") as f:
|
103 |
+
while True:
|
104 |
+
buffer = u.read(8192)
|
105 |
+
if len(buffer) == 0:
|
106 |
+
break
|
107 |
+
f.write(buffer)
|
108 |
+
pbar.update(len(buffer))
|
109 |
+
f.close()
|
110 |
+
|
111 |
+
|
112 |
+
|
113 |
def ntbk():
|
114 |
|
115 |
os.chdir('/notebooks')
|