Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,6 +19,8 @@ import torch.nn.functional as F
|
|
| 19 |
import matplotlib.pyplot as plt
|
| 20 |
import json
|
| 21 |
import gradio as gr
|
|
|
|
|
|
|
| 22 |
|
| 23 |
# Load configuration file
|
| 24 |
with open('config.json', 'r') as config_file:
|
|
@@ -171,8 +173,31 @@ if (runModel=='1'):
|
|
| 171 |
#model.save_pretrained('./' + modelNameToUse + '_model')
|
| 172 |
#tokenizer.save_pretrained('./' + modelNameToUse + '_tokenizer')
|
| 173 |
|
| 174 |
-
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
|
| 177 |
else:
|
| 178 |
print('Load Pre-trained')
|
|
|
|
| 19 |
import matplotlib.pyplot as plt
|
| 20 |
import json
|
| 21 |
import gradio as gr
|
| 22 |
+
from huggingface_hub import HfApi, upload_folder, create_repo
|
| 23 |
+
import os
|
| 24 |
|
| 25 |
# Load configuration file
|
| 26 |
with open('config.json', 'r') as config_file:
|
|
|
|
| 173 |
#model.save_pretrained('./' + modelNameToUse + '_model')
|
| 174 |
#tokenizer.save_pretrained('./' + modelNameToUse + '_tokenizer')
|
| 175 |
|
| 176 |
+
repo_name = "Reyad-Ahmmed/hf-data-timeframe" # Replace with your repository name
|
| 177 |
+
api_token = os.getenv("HF_API_TOKEN") # Replace with your actual API token
|
| 178 |
+
|
| 179 |
+
print("app token: ", api_token)
|
| 180 |
+
|
| 181 |
+
api = HfApi()
|
| 182 |
+
create_repo(repo_id=repo_name, token=api_token, exist_ok=True)
|
| 183 |
+
|
| 184 |
+
model.save_pretrained("/data-timeframe_model")
|
| 185 |
+
tokenizer.save_pretrained("/data-timeframe_tokenizer")
|
| 186 |
+
|
| 187 |
+
# Upload the model and tokenizer to the Hugging Face repository
|
| 188 |
+
upload_folder(
|
| 189 |
+
folder_path="/data-timeframe_model",
|
| 190 |
+
repo_id=repo_name,
|
| 191 |
+
token=api_token,
|
| 192 |
+
commit_message="Add fine-tuned model"
|
| 193 |
+
)
|
| 194 |
+
|
| 195 |
+
upload_folder(
|
| 196 |
+
folder_path="/data-timeframe_tokenizer",
|
| 197 |
+
repo_id=repo_name,
|
| 198 |
+
token=api_token,
|
| 199 |
+
commit_message="Add fine-tuned tokenizer"
|
| 200 |
+
)
|
| 201 |
|
| 202 |
else:
|
| 203 |
print('Load Pre-trained')
|