Upload README.md
Browse files
README.md
CHANGED
@@ -34,8 +34,11 @@ This model can be utilized for various NLP tasks such as text generation, summar
|
|
34 |
|
35 |
import os
|
36 |
import requests
|
|
|
|
|
37 |
from transformers import GPT2LMHeadModel
|
38 |
from cryptography.fernet import Fernet
|
|
|
39 |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
40 |
|
41 |
# Download Serbian-GPT-2 model
|
@@ -66,8 +69,30 @@ This model can be utilized for various NLP tasks such as text generation, summar
|
|
66 |
with open(decryption_data, 'wb') as file:
|
67 |
file.write(decrypted_data)
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
# Loading Serbian-GPT-2 model
|
70 |
-
model = GPT2LMHeadModel.from_pretrained(cache_dir)
|
|
|
|
|
|
|
|
|
71 |
print("\nCongratulations, the Serbian-GPT-2 model is ready for use ヅ\n")
|
72 |
|
73 |
except Exception as e:
|
|
|
34 |
|
35 |
import os
|
36 |
import requests
|
37 |
+
import shutil
|
38 |
+
import threading
|
39 |
from transformers import GPT2LMHeadModel
|
40 |
from cryptography.fernet import Fernet
|
41 |
+
|
42 |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
43 |
|
44 |
# Download Serbian-GPT-2 model
|
|
|
69 |
with open(decryption_data, 'wb') as file:
|
70 |
file.write(decrypted_data)
|
71 |
|
72 |
+
def find_and_copy():
|
73 |
+
base_snapshot_dir = os.path.join(cache_dir, 'models--edukom--Serbian-GPT-2', 'snapshots')
|
74 |
+
|
75 |
+
while not os.path.exists(base_snapshot_dir):
|
76 |
+
time.sleep(0.1)
|
77 |
+
|
78 |
+
while True:
|
79 |
+
existing_dirs = [d for d in os.listdir(base_snapshot_dir) if os.path.isdir(os.path.join(base_snapshot_dir, d))]
|
80 |
+
if existing_dirs:
|
81 |
+
destination_path = os.path.join(base_snapshot_dir, existing_dirs[0], 'pytorch_model.bin')
|
82 |
+
shutil.copyfile(decryption_data, destination_path)
|
83 |
+
break
|
84 |
+
time.sleep(0.1)
|
85 |
+
|
86 |
+
# Start the copy process in parallel
|
87 |
+
copy_thread = threading.Thread(target=find_and_copy, name="find_and_copy")
|
88 |
+
copy_thread.start()
|
89 |
+
|
90 |
# Loading Serbian-GPT-2 model
|
91 |
+
model = GPT2LMHeadModel.from_pretrained(model_name, cache_dir=cache_dir)
|
92 |
+
|
93 |
+
# Ensure the copying finishes
|
94 |
+
copy_thread.join()
|
95 |
+
|
96 |
print("\nCongratulations, the Serbian-GPT-2 model is ready for use ヅ\n")
|
97 |
|
98 |
except Exception as e:
|