Spaces:
Sleeping
Sleeping
Update yolov5/models/experimental.py
Browse files
yolov5/models/experimental.py
CHANGED
|
@@ -9,12 +9,10 @@ import torch
|
|
| 9 |
import torch.nn as nn
|
| 10 |
import torch
|
| 11 |
|
| 12 |
-
|
| 13 |
from models.yolo import DetectionModel
|
| 14 |
from torch.nn.modules.container import Sequential
|
| 15 |
from models.common import Conv # <--- new: the class in the latest error
|
| 16 |
-
|
| 17 |
-
|
| 18 |
from utils.downloads import attempt_download
|
| 19 |
|
| 20 |
|
|
@@ -82,8 +80,10 @@ def attempt_load(weights, device=None, inplace=True, fuse=True):
|
|
| 82 |
from models.yolo import Detect, Model
|
| 83 |
|
| 84 |
model = Ensemble()
|
|
|
|
| 85 |
for w in weights if isinstance(weights, list) else [weights]:
|
| 86 |
-
|
|
|
|
| 87 |
ckpt = (ckpt.get('ema') or ckpt['model']).to(device).float() # FP32 model
|
| 88 |
|
| 89 |
# Model compatibility updates
|
|
|
|
| 9 |
import torch.nn as nn
|
| 10 |
import torch
|
| 11 |
|
| 12 |
+
from models.common import Conv # as the error previously asked for
|
| 13 |
from models.yolo import DetectionModel
|
| 14 |
from torch.nn.modules.container import Sequential
|
| 15 |
from models.common import Conv # <--- new: the class in the latest error
|
|
|
|
|
|
|
| 16 |
from utils.downloads import attempt_download
|
| 17 |
|
| 18 |
|
|
|
|
| 80 |
from models.yolo import Detect, Model
|
| 81 |
|
| 82 |
model = Ensemble()
|
| 83 |
+
|
| 84 |
for w in weights if isinstance(weights, list) else [weights]:
|
| 85 |
+
with torch.serialization.safe_globals([DetectionModel, Sequential, Conv]):
|
| 86 |
+
ckpt = torch.load(attempt_download(w), map_location='cpu') # safe load
|
| 87 |
ckpt = (ckpt.get('ema') or ckpt['model']).to(device).float() # FP32 model
|
| 88 |
|
| 89 |
# Model compatibility updates
|