You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature: support native YOLO .pt models while ensuring compatibility with Torchvision models (#495)
* feature: support native YOLO .pt models with centralized output normalization
* feature: support native YOLO .pt models while ensuring compatibility with Torchvision models
* Removed dtype extraction and subsequent casting in DetectionModelWrapper
The loaded .pt file is a dictionary but doesn't contain a valid model under keys 'model' or 'ema'. Please export to TorchScript for better compatibility.
281
+
"""
282
+
)
283
+
model=candidate
284
+
else:
285
+
model=loaded
276
286
model_type="native"
277
-
exceptExceptionase:
278
-
raiseValueError(
279
-
f"Failed to load model. "
280
-
f"Ensure it is a valid PyTorch or TorchScript model. Error : {e}"
281
-
)
282
-
283
-
elifisinstance(model, torch.nn.Module):
284
-
model_fname=None
285
-
model_type="native"
286
-
else:
287
-
raiseValueError("Model must be a filename or a torch.nn.Module")
287
+
# Fallback for missing Ultralytics dependency
288
+
except (ModuleNotFoundError, AttributeError) ase:
289
+
raiseImportError(
290
+
f"Failed to load native .pt model. This often happens if the 'ultralytics' "
291
+
f"library is missing or incompatible. \nOriginal error: {e}\n"
292
+
f"SUGGESTION: 'pip install ultralytics' or export your model to TorchScript."
0 commit comments