2003Rohansinha commited on
Commit
cda87be
·
verified ·
1 Parent(s): d8305f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
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
- model.load_state_dict(state['model_state_dict'])
 
 
 
 
 
 
 
 
 
 
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