kendrickfff commited on
Commit
2ddee8d
·
verified ·
1 Parent(s): cf6d9c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -0
app.py CHANGED
@@ -55,6 +55,18 @@ else:
55
  # Model training and testing in separate directory at ipynb file (Copy of ai-portfolio Kendrick.ipynb)
56
 
57
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  # Load the model
59
  model = load_model()
60
 
 
55
  # Model training and testing in separate directory at ipynb file (Copy of ai-portfolio Kendrick.ipynb)
56
 
57
 
58
+ # Load model
59
+ def load_model():
60
+ model = models.resnet50(weights='DEFAULT') # Using default weights for initialization
61
+ num_ftrs = model.fc.in_features
62
+ model.fc = nn.Linear(num_ftrs, 12) # Adjust to the number of classes you have
63
+
64
+ # Load the state dict
65
+ model.load_state_dict(torch.load('resnet50_garbage_classificationv1.2.pth', map_location=torch.device('cpu')))
66
+
67
+ model.eval() # Set to evaluation mode
68
+ return model
69
+
70
  # Load the model
71
  model = load_model()
72