SakibRumu
commited on
Update app.py
Browse files
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 |
-
#
|
17 |
sys.path.append(str(Path(__file__).resolve().parent / "yolov10"))
|
18 |
|
19 |
-
# Import
|
20 |
from ultralytics.nn.tasks import YOLOv10DetectionModel
|
21 |
from ultralytics import YOLO
|
22 |
|
23 |
-
#
|
24 |
-
add_safe_globals([YOLOv10DetectionModel, dill._dill._load_type])
|
25 |
|
26 |
-
#
|
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):
|