SakibRumu commited on
Commit
1dd705c
·
verified ·
1 Parent(s): 9c21752

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -9,24 +9,26 @@ import os
9
 
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
32
  def process_frame(frame):
 
9
 
10
  import sys
11
  from pathlib import Path
 
12
  import dill._dill
13
+ import torch
14
  from torch.serialization import add_safe_globals, safe_globals
15
+ from torch.nn import Sequential # 🔥 এই লাইনে Sequential কে allow করব
16
 
17
+ # Yolov10 import path add
18
  sys.path.append(str(Path(__file__).resolve().parent / "yolov10"))
19
 
20
+ # Import YOLOv10 detection model class
21
  from ultralytics.nn.tasks import YOLOv10DetectionModel
22
  from ultralytics import YOLO
23
 
24
+ # Add trusted globals
25
+ add_safe_globals([YOLOv10DetectionModel, dill._dill._load_type, Sequential])
26
 
27
+ # Safely load the model
28
+ with safe_globals([YOLOv10DetectionModel, dill._dill._load_type, Sequential]):
29
  model = YOLO('/home/user/app/best.pt')
30
 
31
+
32
 
33
  # Frame processing function
34
  def process_frame(frame):