Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,8 @@ import base64
|
|
10 |
import os
|
11 |
import huggingface_hub
|
12 |
from huggingface_hub import hf_hub_download
|
|
|
|
|
13 |
|
14 |
|
15 |
# Load label mapping
|
@@ -52,14 +54,20 @@ def load_model():
|
|
52 |
|
53 |
#model_weights_path = os.getenv('MODEL_PATH')
|
54 |
#weights = torch.load(model_weights_path, map_location=torch.device('cpu'))
|
55 |
-
|
56 |
-
|
57 |
-
#
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
base_model.load_state_dict(weights['model_state_dict'])
|
65 |
log_reg.load_state_dict(weights['log_reg_state_dict'])
|
|
|
10 |
import os
|
11 |
import huggingface_hub
|
12 |
from huggingface_hub import hf_hub_download
|
13 |
+
from huggingface_hub import login
|
14 |
+
|
15 |
|
16 |
|
17 |
# Load label mapping
|
|
|
54 |
|
55 |
#model_weights_path = os.getenv('MODEL_PATH')
|
56 |
#weights = torch.load(model_weights_path, map_location=torch.device('cpu'))
|
57 |
+
|
58 |
+
|
59 |
+
# Ensure you are authenticated if the repository is private
|
60 |
+
token = os.getenv('HUGGINGFACE_TOKEN')
|
61 |
+
if token is None:
|
62 |
+
raise ValueError("HUGGINGFACE_TOKEN environment variable is not set")
|
63 |
+
|
64 |
+
login(token=token)
|
65 |
+
file_path = hf_hub_download(
|
66 |
+
repo_id="mawairon/noo_test",
|
67 |
+
filename="gena-blastln-bs33-lr4e-05-S168.pth",
|
68 |
+
use_auth_token=token
|
69 |
+
)
|
70 |
+
weights = torch.load(file_path, map_location=torch.device('cpu'))
|
71 |
|
72 |
base_model.load_state_dict(weights['model_state_dict'])
|
73 |
log_reg.load_state_dict(weights['log_reg_state_dict'])
|