Upload palabranoelani_py_195.py
Browse files- palabranoelani_py_195.py +37 -0
palabranoelani_py_195.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""palabraNoelani.py.195
|
3 |
+
|
4 |
+
Automatically generated by Colab.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1uFgy02KIfS_uTu6vJc8P7kcEQ_jtSNGw
|
8 |
+
"""
|
9 |
+
|
10 |
+
import os
|
11 |
+
import sys
|
12 |
+
import requests
|
13 |
+
from tqdm import tqdm
|
14 |
+
|
15 |
+
if len(sys.argv) !=2:
|
16 |
+
print('Enter model parameter')
|
17 |
+
sys.exit(1)
|
18 |
+
|
19 |
+
model = sys.argv[1]
|
20 |
+
|
21 |
+
subdir = os.path.join('models', model)
|
22 |
+
if not os.path.exists(subdir):
|
23 |
+
os.makedirs(subdir)
|
24 |
+
subdir = subdir.replace('\\', '/')
|
25 |
+
|
26 |
+
for filename in ['checkpoint', 'encoder.json','hparams.json','model.ckpt'.data-00000-of-00001','model.ckpt.index','model.ckpt.meta', 'vocab.bpe']:
|
27 |
+
|
28 |
+
r = requests.get("https://openaipublic.blob.core.windows.net/gpt-2/" + subdir + "/" + filename, stream=True)
|
29 |
+
|
30 |
+
with open(os.path.join(subdir, filename), 'wb') as f:
|
31 |
+
file_size = int(r,headers["content-length"])
|
32 |
+
chunk_size = 1000
|
33 |
+
with tqdm(ncols=100)
|
34 |
+
|
35 |
+
for chunk in r.iter_content(chunk_size=chunk_size):
|
36 |
+
f.write(chunk)
|
37 |
+
pbar.update(chunk_size)
|