SakibRumu commited on
Commit
cab70c8
·
verified ·
1 Parent(s): 80ae37c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -7,13 +7,17 @@ from PIL import Image
7
  import sys
8
  import os
9
 
10
- import sys
11
- sys.path.append('/home/user/app/yolov10') # Add your local YOLOv10 repo path
 
 
12
 
13
- from ultralytics import YOLO # This now refers to your local repo, not pip
 
14
 
15
- model = YOLO('/home/user/app/best.pt') # Load the model
16
- model.eval()
 
17
 
18
  # Frame processing function
19
  def process_frame(frame):
 
7
  import sys
8
  import os
9
 
10
+ import torch
11
+ import torch.serialization
12
+ from ultralytics import YOLO
13
+ from ultralytics.nn.tasks import YOLOv10DetectionModel
14
 
15
+ # Register the custom class for safe loading
16
+ torch.serialization.add_safe_globals({'YOLOv10DetectionModel': YOLOv10DetectionModel})
17
 
18
+ # Load the model inside a safe context
19
+ with torch.serialization.safe_globals({'YOLOv10DetectionModel': YOLOv10DetectionModel}):
20
+ model = YOLO('/home/user/app/best.pt') # Load your YOLOv10 model
21
 
22
  # Frame processing function
23
  def process_frame(frame):