Pavan2k4 commited on
Commit
c4400ac
·
verified ·
1 Parent(s): 1520190

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -24,11 +24,13 @@ from huggingface_hub import HfApi, login
24
  import os
25
 
26
  # Set up Hugging Face authentication
 
27
  HF_TOKEN = os.environ.get("HF_TOKEN")
28
  if not HF_TOKEN:
29
  raise ValueError("HF_TOKEN environment variable is not set")
30
 
31
- login(token=HF_TOKEN)
 
32
  hf_api = HfApi()
33
 
34
  REPO_ID = "Pavan2k4/Building_area"
@@ -37,7 +39,7 @@ REPO_TYPE = "space"
37
  @st.cache_resource
38
  def load_model():
39
  model = reunet_cbam()
40
- model.load_state_dict(torch.load('latest.pth', map_location='cpu')['model_state_dict'])
41
  model.eval()
42
  return model
43
 
@@ -46,6 +48,7 @@ def load_model():
46
 
47
 
48
 
 
49
  # save to dir func
50
  def save_to_hf_repo(local_path, repo_path):
51
  try:
 
24
  import os
25
 
26
  # Set up Hugging Face authentication
27
+ @st.cache_resource
28
  HF_TOKEN = os.environ.get("HF_TOKEN")
29
  if not HF_TOKEN:
30
  raise ValueError("HF_TOKEN environment variable is not set")
31
 
32
+ login(token=HF_TOKEN, add_to_git_credential=True)
33
+
34
  hf_api = HfApi()
35
 
36
  REPO_ID = "Pavan2k4/Building_area"
 
39
  @st.cache_resource
40
  def load_model():
41
  model = reunet_cbam()
42
+ model.load_state_dict(torch.load('latest.pth', map_location='cpu', weights_only = True)['model_state_dict'])
43
  model.eval()
44
  return model
45
 
 
48
 
49
 
50
 
51
+
52
  # save to dir func
53
  def save_to_hf_repo(local_path, repo_path):
54
  try: