HilmiZr commited on
Commit
def8fe0
·
1 Parent(s): 282d5c2

try: state_dict

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -32,9 +32,17 @@ for i, url in enumerate(file_urls):
32
  f"image_{i}.jpg"
33
  )
34
 
35
- model = Model('models/custom_yolov5s.yaml')
36
- model.load_state_dict(torch.load('ppe-yolov5.pt'))
37
- model.eval()
 
 
 
 
 
 
 
 
38
  path = [['image_0.jpg'], ['image_1.jpg']]
39
  video_path = [['video.mp4']]
40
 
 
32
  f"image_{i}.jpg"
33
  )
34
 
35
+ # Load the checkpoint
36
+ checkpoint = torch.load('ppe-yolov5.pt')
37
+
38
+ # Ensure 'model' is a key in the checkpoint before attempting to load the state_dict
39
+ if 'model' in checkpoint:
40
+ model = Model('models/custom_yolov5s.yaml')
41
+ model.load_state_dict(checkpoint['model']) # Assuming the key for state_dict is 'model'
42
+ model.eval()
43
+ else:
44
+ raise KeyError("The checkpoint file does not contain the key 'model'. Please check the file.")
45
+
46
  path = [['image_0.jpg'], ['image_1.jpg']]
47
  video_path = [['video.mp4']]
48