Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,7 +36,17 @@ model = CheXNet(num_classes=14)
|
|
| 36 |
state = torch.load('best_chexnet_v2.pth',
|
| 37 |
map_location='cpu',
|
| 38 |
weights_only=False)
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
model.eval()
|
| 41 |
print("Model ready!")
|
| 42 |
|
|
|
|
| 36 |
state = torch.load('best_chexnet_v2.pth',
|
| 37 |
map_location='cpu',
|
| 38 |
weights_only=False)
|
| 39 |
+
|
| 40 |
+
# Fix DataParallel 'module.' prefix
|
| 41 |
+
state_dict = state['model_state_dict']
|
| 42 |
+
new_state_dict = {}
|
| 43 |
+
for k, v in state_dict.items():
|
| 44 |
+
new_key = k.replace('module.', '') # remove the 'module.' prefix
|
| 45 |
+
new_state_dict[new_key] = v
|
| 46 |
+
|
| 47 |
+
model.load_state_dict(new_state_dict)
|
| 48 |
+
model.eval()
|
| 49 |
+
print("Model ready!")
|
| 50 |
model.eval()
|
| 51 |
print("Model ready!")
|
| 52 |
|