made changes made based on checkpoint model
Browse files
app.py
CHANGED
@@ -30,13 +30,13 @@ device = torch.device('cpu')
|
|
30 |
model = models.resnet50(pretrained=False) # Load the ResNet-50 architecture
|
31 |
model.fc = nn.Linear(model.fc.in_features, 1000)
|
32 |
|
33 |
-
model.load_state_dict(torch.load("model.pth", map_location=device)) # Load the trained weights (.pth)
|
34 |
model.to(device) # Move model to CPU (even if you have a GPU)
|
35 |
|
36 |
checkpoint = torch.load('model.pth', map_location='cpu')
|
37 |
|
38 |
# Load the model weights
|
39 |
-
model.load_state_dict(checkpoint['model_state_dict'], strict=False)
|
40 |
|
41 |
# If you need to resume training, load optimizer and scheduler states
|
42 |
optimizer.load_state_dict(checkpoint['optimizer_state_dict'])
|
|
|
30 |
model = models.resnet50(pretrained=False) # Load the ResNet-50 architecture
|
31 |
model.fc = nn.Linear(model.fc.in_features, 1000)
|
32 |
|
33 |
+
# model.load_state_dict(torch.load("model.pth", map_location=device)) # Load the trained weights (.pth)
|
34 |
model.to(device) # Move model to CPU (even if you have a GPU)
|
35 |
|
36 |
checkpoint = torch.load('model.pth', map_location='cpu')
|
37 |
|
38 |
# Load the model weights
|
39 |
+
model.load_state_dict(checkpoint['model_state_dict'], strict=False, map_location=device)
|
40 |
|
41 |
# If you need to resume training, load optimizer and scheduler states
|
42 |
optimizer.load_state_dict(checkpoint['optimizer_state_dict'])
|