Ultralytics YOLO
Description
)]): List of input images in HWC numpy array format.
Returns:
(torch.Tensor): The transformed image tensor, ready for further preprocessing steps.
(torch.Tensor): The transformed image tensor in BCHW format, ready for further preprocessing steps.Examples:>>> predictor = Predictor()>>> image = [np.random.rand(640, 640, 3).astype(np.float32)]>>> transformed_image = predictor.pre_transform(image)
diff --git a/ultralytics/yolo/utils/ops.py b/ultralytics/yolo/utils/ops.py index fea849f4b9c..e5e62b58ed9 100644 --- a/ultralytics/yolo/utils/ops.py +++ b/ultralytics/yolo/utils/ops.py @@ -17,6 +17,7 @@ import torch.nn as nn import torch.nn.functional as F import torchvision from IPython import display # IPython.autoimport() +from typing import Tuple, Any""" if isinstance(im, list) and len(im): assert len(im) == 1, "Batched inference not supported for SAM." im = im[0]
from ultralytics.yolo.utils import LOGGER, TryExcept, colorstr, emojis, yaml_load
@@ -24,6 +25,14 @@ from .checks import check_version
TORCH_1_13 = check_version(torch.version, "1.13.0")
+Tuple.args = (Any, Any) # Fixes Tuple deserialization + + +def get_num_params(module: nn.Module, exclude=None) -> int:
- """Calculate the total number of parameters in a module."""
- if exclude:
params = [p.numel() for n, p in module.named_parameters() if exclude not in n]- return sum(p.numel() for p in module.parameters())
def try_new(op, *args, **kwargs):
"""Try torch.[operation](*args, **kwargs)."""
Notes
Files
ultralytics/ultralytics-v8.2.73.zip
Files
(2.0 MB)
| Name | Size | Download all |
|---|---|---|
|
md5:8661c330b34d1c3d2336bd6fd5c49137
|
2.0 MB | Preview Download |
Additional details
Related works
- Is supplement to
- Software: https://github.com/ultralytics/ultralytics/tree/v8.2.73 (URL)