mawairon commited on
Commit
306f08b
1 Parent(s): 2113eac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
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
- # Download the file
58
- file_path = hf_hub_download(repo_id="mawairon/noo_test", filename="/gena-blastln-bs33-lr4e-05-S168.pth")
59
-
60
- # Now you can use the file_path to load your .pth file
61
- weights = torch.load(file_path)
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'])