cfgpp commited on
Commit
348a42c
·
verified ·
1 Parent(s): fbffa4e

Update model_utils.py

Browse files
Files changed (1) hide show
  1. model_utils.py +7 -4
model_utils.py CHANGED
@@ -24,13 +24,16 @@ class CheXNet(nn.Module):
24
  x = torch.flatten(x, 1)
25
  return self.classifier(x)
26
 
27
- def load_model(url, device):
28
- model_path = "dannynet.pth"
29
- torch.hub.download_url_to_file(url,model_path)
30
- model = torch.load(model_path, map_location = device)
 
 
31
  model.eval()
32
  return model
33
 
 
34
  def predict(model, img_tensor, device):
35
  with torch.no_grad():
36
  output = model(img_tensor.unsqueeze(0).to(device))
 
24
  x = torch.flatten(x, 1)
25
  return self.classifier(x)
26
 
27
+ from huggingface_hub import hf_hub_download
28
+ import torch
29
+
30
+ def load_model(repo_id, filename, device):
31
+ model_path = hf_hub_download(repo_id=repo_id, filename=filename)
32
+ model = torch.load(model_path, map_location=device)
33
  model.eval()
34
  return model
35
 
36
+
37
  def predict(model, img_tensor, device):
38
  with torch.no_grad():
39
  output = model(img_tensor.unsqueeze(0).to(device))