SakibRumu commited on
Commit
7c3dda1
·
verified ·
1 Parent(s): 3996fa9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -10,21 +10,22 @@ import os
10
  import sys
11
  from pathlib import Path
12
  import torch
 
13
  from torch.serialization import add_safe_globals, safe_globals
14
 
15
  # Add yolov10 directory to Python path
16
  sys.path.append(str(Path(__file__).resolve().parent / "yolov10"))
17
 
18
- # Now import from yolov10
19
- from ultralytics import YOLO
20
  from ultralytics.nn.tasks import YOLOv10DetectionModel
 
21
 
22
- # Register the actual YOLOv10DetectionModel class for safe loading
23
- add_safe_globals([YOLOv10DetectionModel])
24
 
25
- # Load the model safely using context manager
26
- with safe_globals([YOLOv10DetectionModel]):
27
- model = YOLO('/home/user/app/best.pt') # Make sure this file exists
28
 
29
 
30
  # Frame processing function
 
10
  import sys
11
  from pathlib import Path
12
  import torch
13
+ import dill._dill
14
  from torch.serialization import add_safe_globals, safe_globals
15
 
16
  # Add yolov10 directory to Python path
17
  sys.path.append(str(Path(__file__).resolve().parent / "yolov10"))
18
 
19
+ # Import your custom YOLOv10 model
 
20
  from ultralytics.nn.tasks import YOLOv10DetectionModel
21
+ from ultralytics import YOLO
22
 
23
+ # Register the required classes/functions
24
+ add_safe_globals([YOLOv10DetectionModel, dill._dill._load_type])
25
 
26
+ # Load your trained YOLOv10 model
27
+ with safe_globals([YOLOv10DetectionModel, dill._dill._load_type]):
28
+ model = YOLO('/home/user/app/best.pt')
29
 
30
 
31
  # Frame processing function