iamomtiwari commited on
Commit
02a0ca8
·
verified ·
1 Parent(s): c7bf4ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -5,10 +5,13 @@ from torchvision.models import resnet50
5
  from PIL import Image
6
 
7
  # Load the model
 
 
8
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
9
  model = resnet50(pretrained=False)
10
  model.fc = torch.nn.Linear(model.fc.in_features, 14) # Adjust for 14 classes
11
- model.load_state_dict(torch.load("resnet50_model_hf.pt", map_location=device))
 
12
  model.eval()
13
 
14
  # Define image transformations
 
5
  from PIL import Image
6
 
7
  # Load the model
8
+ from huggingface_hub import hf_hub_download
9
+
10
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
11
  model = resnet50(pretrained=False)
12
  model.fc = torch.nn.Linear(model.fc.in_features, 14) # Adjust for 14 classes
13
+ model_path = hf_hub_download(repo_id="iamomtiwari/resnet50-crop-disease", filename="resnet50_model_hf.pt")
14
+ model.load_state_dict(torch.load(model_path, map_location=device))
15
  model.eval()
16
 
17
  # Define image transformations