Spaces:
Runtime error
Runtime error
Boris Ustyugov
commited on
Commit
·
bbfb591
1
Parent(s):
e01c3a8
Clean up temporary files
Browse files- upload_model.py +0 -50
upload_model.py
DELETED
|
@@ -1,50 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
"""
|
| 3 |
-
Script to upload the finetuned FinBERT model to Hugging Face Hub.
|
| 4 |
-
"""
|
| 5 |
-
|
| 6 |
-
import os
|
| 7 |
-
from huggingface_hub import HfApi, create_repo, Repository
|
| 8 |
-
|
| 9 |
-
def upload_model():
|
| 10 |
-
"""Upload the finetuned model to Hugging Face Hub."""
|
| 11 |
-
|
| 12 |
-
# Repository name (using the same name as the Space)
|
| 13 |
-
repo_name = "utyug1/finbert-finetuned-model"
|
| 14 |
-
|
| 15 |
-
try:
|
| 16 |
-
# Create repository if it doesn't exist
|
| 17 |
-
print(f"Creating repository: {repo_name}")
|
| 18 |
-
create_repo(repo_name, exist_ok=True, private=False)
|
| 19 |
-
|
| 20 |
-
# Clone the repository locally
|
| 21 |
-
print("Cloning repository...")
|
| 22 |
-
repo = Repository(repo_name, clone_from=repo_name)
|
| 23 |
-
|
| 24 |
-
# Copy model files to the repository
|
| 25 |
-
print("Copying model files...")
|
| 26 |
-
model_dir = "model_chekpoint"
|
| 27 |
-
|
| 28 |
-
for filename in os.listdir(model_dir):
|
| 29 |
-
file_path = os.path.join(model_dir, filename)
|
| 30 |
-
if os.path.isfile(file_path):
|
| 31 |
-
print(f"Copying {filename}...")
|
| 32 |
-
import shutil
|
| 33 |
-
shutil.copy2(file_path, filename)
|
| 34 |
-
|
| 35 |
-
# Commit and push
|
| 36 |
-
print("Committing and pushing...")
|
| 37 |
-
repo.git_add()
|
| 38 |
-
repo.git_commit("Upload finetuned FinBERT model")
|
| 39 |
-
repo.git_push()
|
| 40 |
-
|
| 41 |
-
print(f"Model successfully uploaded to: https://huggingface.co/{repo_name}")
|
| 42 |
-
|
| 43 |
-
except Exception as e:
|
| 44 |
-
print(f"Error uploading model: {str(e)}")
|
| 45 |
-
return False
|
| 46 |
-
|
| 47 |
-
return True
|
| 48 |
-
|
| 49 |
-
if __name__ == "__main__":
|
| 50 |
-
upload_model()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|