@@ -279,7 +279,7 @@ class DetectMultiBackend(nn.Module):
279
279
def __init__ (self , weights = 'yolov5s.pt' , device = None , dnn = True ):
280
280
# Usage:
281
281
# PyTorch: weights = *.pt
282
- # TorchScript: *.torchscript.pt
282
+ # TorchScript: *.torchscript
283
283
# CoreML: *.mlmodel
284
284
# TensorFlow: *_saved_model
285
285
# TensorFlow: *.pb
@@ -289,10 +289,10 @@ def __init__(self, weights='yolov5s.pt', device=None, dnn=True):
289
289
# TensorRT: *.engine
290
290
super ().__init__ ()
291
291
w = str (weights [0 ] if isinstance (weights , list ) else weights )
292
- suffix , suffixes = Path (w ).suffix .lower (), ['.pt' , '.onnx' , '.engine' , '.tflite' , '.pb' , '' , '.mlmodel' ]
292
+ suffix = Path (w ).suffix .lower ()
293
+ suffixes = ['.pt' , '.torchscript' , '.onnx' , '.engine' , '.tflite' , '.pb' , '' , '.mlmodel' ]
293
294
check_suffix (w , suffixes ) # check weights have acceptable suffix
294
- pt , onnx , engine , tflite , pb , saved_model , coreml = (suffix == x for x in suffixes ) # backend booleans
295
- jit = pt and 'torchscript' in w .lower ()
295
+ pt , jit , onnx , engine , tflite , pb , saved_model , coreml = (suffix == x for x in suffixes ) # backend booleans
296
296
stride , names = 64 , [f'class{ i } ' for i in range (1000 )] # assign defaults
297
297
298
298
if jit : # TorchScript
@@ -304,10 +304,10 @@ def __init__(self, weights='yolov5s.pt', device=None, dnn=True):
304
304
stride , names = int (d ['stride' ]), d ['names' ]
305
305
elif pt : # PyTorch
306
306
from models .experimental import attempt_load # scoped to avoid circular import
307
- model = torch . jit . load ( w ) if 'torchscript' in w else attempt_load (weights , map_location = device )
307
+ model = attempt_load (weights , map_location = device )
308
308
stride = int (model .stride .max ()) # model stride
309
309
names = model .module .names if hasattr (model , 'module' ) else model .names # get class names
310
- elif coreml : # CoreML *.mlmodel
310
+ elif coreml : # CoreML
311
311
import coremltools as ct
312
312
model = ct .models .MLModel (w )
313
313
elif dnn : # ONNX OpenCV DNN
0 commit comments