ultralytics 8.3.70__py3-none-any.whl → 8.3.72__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ultralytics/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
2
 
3
- __version__ = "8.3.70"
3
+ __version__ = "8.3.72"
4
4
 
5
5
  import os
6
6
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  # Parameters
8
8
  nc: 80 # number of classes
9
- activation: nn.ReLU() # (optional) model default activation function
9
+ activation: torch.nn.ReLU() # (optional) model default activation function
10
10
  scales: # model compound scaling constants, i.e. 'model=yolov6n.yaml' will call yolov8.yaml with scale 'n'
11
11
  # [depth, width, max_channels]
12
12
  n: [0.33, 0.25, 1024]
@@ -386,6 +386,8 @@ class Exporter:
386
386
  "names": model.names,
387
387
  "args": {k: v for k, v in self.args if k in fmt_keys},
388
388
  } # model metadata
389
+ if dla is not None:
390
+ self.metadata["dla"] = dla # make sure `AutoBackend` uses correct dla device if it has one
389
391
  if model.task == "pose":
390
392
  self.metadata["kpt_shape"] = model.model[-1].kpt_shape
391
393
 
@@ -1544,10 +1546,10 @@ class NMSModel(torch.nn.Module):
1544
1546
  Performs inference with NMS post-processing. Supports Detect, Segment, OBB and Pose.
1545
1547
 
1546
1548
  Args:
1547
- x (torch.tensor): The preprocessed tensor with shape (N, 3, H, W).
1549
+ x (torch.Tensor): The preprocessed tensor with shape (N, 3, H, W).
1548
1550
 
1549
1551
  Returns:
1550
- out (torch.tensor): The post-processed results with shape (N, max_det, 4 + 2 + extra_shape).
1552
+ out (torch.Tensor): The post-processed results with shape (N, max_det, 4 + 2 + extra_shape).
1551
1553
  """
1552
1554
  from functools import partial
1553
1555
 
@@ -1556,8 +1558,8 @@ class NMSModel(torch.nn.Module):
1556
1558
  preds = self.model(x)
1557
1559
  pred = preds[0] if isinstance(preds, tuple) else preds
1558
1560
  pred = pred.transpose(-1, -2) # shape(1,84,6300) to shape(1,6300,84)
1559
- extra_shape = pred.shape[-1] - (4 + self.model.nc) # extras from Segment, OBB, Pose
1560
- boxes, scores, extras = pred.split([4, self.model.nc, extra_shape], dim=2)
1561
+ extra_shape = pred.shape[-1] - (4 + len(self.model.names)) # extras from Segment, OBB, Pose
1562
+ boxes, scores, extras = pred.split([4, len(self.model.names), extra_shape], dim=2)
1561
1563
  scores, classes = scores.max(dim=-1)
1562
1564
  self.args.max_det = min(pred.shape[1], self.args.max_det) # in case num_anchors < max_det
1563
1565
  # (N, max_det, 4 coords + 1 class score + 1 class label + extra_shape).
@@ -11,7 +11,7 @@ from PIL import Image
11
11
  from ultralytics.cfg import TASK2DATA, get_cfg, get_save_dir
12
12
  from ultralytics.engine.results import Results
13
13
  from ultralytics.hub import HUB_WEB_ROOT, HUBTrainingSession
14
- from ultralytics.nn.tasks import attempt_load_one_weight, guess_model_task, nn, yaml_model_load
14
+ from ultralytics.nn.tasks import attempt_load_one_weight, guess_model_task, yaml_model_load
15
15
  from ultralytics.utils import (
16
16
  ARGV,
17
17
  ASSETS,
@@ -26,7 +26,7 @@ from ultralytics.utils import (
26
26
  )
27
27
 
28
28
 
29
- class Model(nn.Module):
29
+ class Model(torch.nn.Module):
30
30
  """
31
31
  A base class for implementing YOLO models, unifying APIs across different model types.
32
32
 
@@ -37,7 +37,7 @@ class Model(nn.Module):
37
37
  Attributes:
38
38
  callbacks (Dict): A dictionary of callback functions for various events during model operations.
39
39
  predictor (BasePredictor): The predictor object used for making predictions.
40
- model (nn.Module): The underlying PyTorch model.
40
+ model (torch.nn.Module): The underlying PyTorch model.
41
41
  trainer (BaseTrainer): The trainer object used for training the model.
42
42
  ckpt (Dict): The checkpoint data if the model is loaded from a *.pt file.
43
43
  cfg (str): The configuration of the model if loaded from a *.yaml file.
@@ -317,7 +317,7 @@ class Model(nn.Module):
317
317
  >>> model._check_is_pytorch_model() # Raises TypeError
318
318
  """
319
319
  pt_str = isinstance(self.model, (str, Path)) and Path(self.model).suffix == ".pt"
320
- pt_module = isinstance(self.model, nn.Module)
320
+ pt_module = isinstance(self.model, torch.nn.Module)
321
321
  if not (pt_module or pt_str):
322
322
  raise TypeError(
323
323
  f"model='{self.model}' should be a *.pt PyTorch model to run this method, but is a different format. "
@@ -405,7 +405,7 @@ class Model(nn.Module):
405
405
  from ultralytics import __version__
406
406
 
407
407
  updates = {
408
- "model": deepcopy(self.model).half() if isinstance(self.model, nn.Module) else self.model,
408
+ "model": deepcopy(self.model).half() if isinstance(self.model, torch.nn.Module) else self.model,
409
409
  "date": datetime.now().isoformat(),
410
410
  "version": __version__,
411
411
  "license": "AGPL-3.0 License (https://ultralytics.com/license)",
@@ -452,7 +452,7 @@ class Model(nn.Module):
452
452
  performs both convolution and normalization in one step.
453
453
 
454
454
  Raises:
455
- TypeError: If the model is not a PyTorch nn.Module.
455
+ TypeError: If the model is not a PyTorch torch.nn.Module.
456
456
 
457
457
  Examples:
458
458
  >>> model = Model("yolo11n.pt")
@@ -921,13 +921,13 @@ class Model(nn.Module):
921
921
  Retrieves the device on which the model's parameters are allocated.
922
922
 
923
923
  This property determines the device (CPU or GPU) where the model's parameters are currently stored. It is
924
- applicable only to models that are instances of nn.Module.
924
+ applicable only to models that are instances of torch.nn.Module.
925
925
 
926
926
  Returns:
927
927
  (torch.device): The device (CPU/GPU) of the model.
928
928
 
929
929
  Raises:
930
- AttributeError: If the model is not a PyTorch nn.Module instance.
930
+ AttributeError: If the model is not a torch.nn.Module instance.
931
931
 
932
932
  Examples:
933
933
  >>> model = YOLO("yolo11n.pt")
@@ -937,7 +937,7 @@ class Model(nn.Module):
937
937
  >>> print(model.device)
938
938
  device(type='cpu')
939
939
  """
940
- return next(self.model.parameters()).device if isinstance(self.model, nn.Module) else None
940
+ return next(self.model.parameters()).device if isinstance(self.model, torch.nn.Module) else None
941
941
 
942
942
  @property
943
943
  def transforms(self):
@@ -494,8 +494,8 @@ class Results(SimpleClass):
494
494
  Examples:
495
495
  >>> results = model("image.jpg")
496
496
  >>> for result in results:
497
- ... im = result.plot()
498
- ... im.show()
497
+ >>> im = result.plot()
498
+ >>> im.show()
499
499
  """
500
500
  assert color_mode in {"instance", "class"}, f"Expected color_mode='instance' or 'class', not {color_mode}."
501
501
  if img is None and isinstance(self.orig_img, torch.Tensor):
@@ -600,7 +600,7 @@ class Results(SimpleClass):
600
600
  >>> results = model("path/to/image.jpg")
601
601
  >>> results[0].show() # Display the first result
602
602
  >>> for result in results:
603
- ... result.show() # Display all results
603
+ >>> result.show() # Display all results
604
604
  """
605
605
  self.plot(show=True, *args, **kwargs)
606
606
 
@@ -620,10 +620,10 @@ class Results(SimpleClass):
620
620
  Examples:
621
621
  >>> results = model("path/to/image.jpg")
622
622
  >>> for result in results:
623
- ... result.save("annotated_image.jpg")
623
+ >>> result.save("annotated_image.jpg")
624
624
  >>> # Or with custom plot arguments
625
625
  >>> for result in results:
626
- ... result.save("annotated_image.jpg", conf=False, line_width=2)
626
+ >>> result.save("annotated_image.jpg", conf=False, line_width=2)
627
627
  """
628
628
  if not filename:
629
629
  filename = f"results_{Path(self.path).name}"
@@ -644,7 +644,7 @@ class Results(SimpleClass):
644
644
  Examples:
645
645
  >>> results = model("path/to/image.jpg")
646
646
  >>> for result in results:
647
- ... print(result.verbose())
647
+ >>> print(result.verbose())
648
648
  2 persons, 1 car, 3 traffic lights,
649
649
  dog 0.92, cat 0.78, horse 0.64,
650
650
 
@@ -681,7 +681,7 @@ class Results(SimpleClass):
681
681
  >>> model = YOLO("yolo11n.pt")
682
682
  >>> results = model("path/to/image.jpg")
683
683
  >>> for result in results:
684
- ... result.save_txt("output.txt")
684
+ >>> result.save_txt("output.txt")
685
685
 
686
686
  Notes:
687
687
  - The file will contain one line per detection or classification with the following structure:
@@ -740,7 +740,7 @@ class Results(SimpleClass):
740
740
  Examples:
741
741
  >>> results = model("path/to/image.jpg")
742
742
  >>> for result in results:
743
- ... result.save_crop(save_dir="path/to/crops", file_name="detection")
743
+ >>> result.save_crop(save_dir="path/to/crops", file_name="detection")
744
744
  """
745
745
  if self.probs is not None:
746
746
  LOGGER.warning("WARNING ⚠️ Classify task do not support `save_crop`.")
@@ -776,8 +776,9 @@ class Results(SimpleClass):
776
776
 
777
777
  Examples:
778
778
  >>> results = model("image.jpg")
779
- >>> summary = results[0].summary()
780
- >>> print(summary)
779
+ >>> for result in results:
780
+ >>> summary = result.summary()
781
+ >>> print(summary)
781
782
  """
782
783
  # Create list of detection dictionaries
783
784
  results = []
@@ -839,8 +840,9 @@ class Results(SimpleClass):
839
840
 
840
841
  Examples:
841
842
  >>> results = model("path/to/image.jpg")
842
- >>> df_result = results[0].to_df()
843
- >>> print(df_result)
843
+ >>> for result in results:
844
+ >>> df_result = result.to_df()
845
+ >>> print(df_result)
844
846
  """
845
847
  import pandas as pd # scope for faster 'import ultralytics'
846
848
 
@@ -867,8 +869,9 @@ class Results(SimpleClass):
867
869
 
868
870
  Examples:
869
871
  >>> results = model("path/to/image.jpg")
870
- >>> csv_result = results[0].to_csv()
871
- >>> print(csv_result)
872
+ >>> for result in results:
873
+ >>> csv_result = result.to_csv()
874
+ >>> print(csv_result)
872
875
  """
873
876
  return self.to_df(normalize=normalize, decimals=decimals).to_csv(*args, **kwargs)
874
877
 
@@ -892,8 +895,9 @@ class Results(SimpleClass):
892
895
 
893
896
  Examples:
894
897
  >>> results = model("path/to/image.jpg")
895
- >>> xml_result = results[0].to_xml()
896
- >>> print(xml_result)
898
+ >>> for result in results:
899
+ >>> xml_result = result.to_xml()
900
+ >>> print(xml_result)
897
901
  """
898
902
  check_requirements("lxml")
899
903
  df = self.to_df(normalize=normalize, decimals=decimals)
@@ -922,8 +926,9 @@ class Results(SimpleClass):
922
926
 
923
927
  Examples:
924
928
  >>> results = model("path/to/image.jpg")
925
- >>> json_result = results[0].to_json()
926
- >>> print(json_result)
929
+ >>> for result in results:
930
+ >>> json_result = result.to_json()
931
+ >>> print(json_result)
927
932
 
928
933
  Notes:
929
934
  - For classification tasks, the JSON will contain class probabilities instead of bounding boxes.
@@ -954,8 +959,8 @@ class Results(SimpleClass):
954
959
 
955
960
  Examples:
956
961
  >>> results = model("path/to/image.jpg")
957
- >>> results[0].to_sql()
958
- >>> print("SQL data written successfully.")
962
+ >>> for result in results:
963
+ >>> result.to_sql()
959
964
  """
960
965
  import json
961
966
  import sqlite3
@@ -426,8 +426,7 @@ class SAM2Model(torch.nn.Module):
426
426
  high_res_masks: Tensor of shape (B, 1, H*16, W*16) with the best high-resolution mask.
427
427
  obj_ptr: Tensor of shape (B, C) with object pointer vector for the output mask.
428
428
  object_score_logits: Tensor of shape (B) with object score logits.
429
-
430
- Where M is 3 if multimask_output=True, and 1 if multimask_output=False.
429
+ Where M is 3 if multimask_output=True, and 1 if multimask_output=False.
431
430
 
432
431
  Examples:
433
432
  >>> backbone_features = torch.rand(1, 256, 32, 32)
@@ -158,7 +158,7 @@ class PoseValidator(DetectionValidator):
158
158
  gt_kpts (torch.Tensor | None): Optional tensor with shape (N, 51) representing ground truth keypoints.
159
159
 
160
160
  Returns:
161
- torch.Tensor: A tensor with shape (N, 10) representing the correct prediction matrix for 10 IoU levels,
161
+ (torch.Tensor): A tensor with shape (N, 10) representing the correct prediction matrix for 10 IoU levels,
162
162
  where N is the number of detections.
163
163
 
164
164
  Example:
@@ -292,13 +292,10 @@ class AutoBackend(nn.Module):
292
292
  metadata = json.loads(f.read(meta_len).decode("utf-8")) # read metadata
293
293
  except UnicodeDecodeError:
294
294
  f.seek(0) # engine file may lack embedded Ultralytics metadata
295
+ dla = metadata.get("dla", None)
296
+ if dla is not None:
297
+ runtime.DLA_core = int(dla)
295
298
  model = runtime.deserialize_cuda_engine(f.read()) # read engine
296
- if "dla" in str(device.type):
297
- dla_core = int(device.type.split(":")[1])
298
- assert dla_core in {0, 1}, (
299
- "Expected device type for inference in DLA is 'dla:0' or 'dla:1', but received '{device.type}'"
300
- )
301
- runtime.DLA_core = dla_core
302
299
 
303
300
  # Model context
304
301
  try:
@@ -780,7 +777,7 @@ class AutoBackend(nn.Module):
780
777
  saved_model, pb, tflite, edgetpu, tfjs, ncnn or paddle.
781
778
 
782
779
  Args:
783
- p: path to the model file. Defaults to path/to/model.pt
780
+ p (str): path to the model file. Defaults to path/to/model.pt
784
781
 
785
782
  Examples:
786
783
  >>> model = AutoBackend(weights="path/to/model.onnx")
ultralytics/nn/tasks.py CHANGED
@@ -9,7 +9,6 @@ from pathlib import Path
9
9
 
10
10
  import thop
11
11
  import torch
12
- import torch.nn as nn
13
12
 
14
13
  from ultralytics.nn.modules import (
15
14
  AIFI,
@@ -88,7 +87,7 @@ from ultralytics.utils.torch_utils import (
88
87
  )
89
88
 
90
89
 
91
- class BaseModel(nn.Module):
90
+ class BaseModel(torch.nn.Module):
92
91
  """The BaseModel class serves as a base class for all the models in the Ultralytics YOLO family."""
93
92
 
94
93
  def forward(self, x, *args, **kwargs):
@@ -151,7 +150,7 @@ class BaseModel(nn.Module):
151
150
  if visualize:
152
151
  feature_visualization(x, m.type, m.i, save_dir=visualize)
153
152
  if embed and m.i in embed:
154
- embeddings.append(nn.functional.adaptive_avg_pool2d(x, (1, 1)).squeeze(-1).squeeze(-1)) # flatten
153
+ embeddings.append(torch.nn.functional.adaptive_avg_pool2d(x, (1, 1)).squeeze(-1).squeeze(-1)) # flatten
155
154
  if m.i == max(embed):
156
155
  return torch.unbind(torch.cat(embeddings, 1), dim=0)
157
156
  return x
@@ -170,12 +169,9 @@ class BaseModel(nn.Module):
170
169
  the provided list.
171
170
 
172
171
  Args:
173
- m (nn.Module): The layer to be profiled.
172
+ m (torch.nn.Module): The layer to be profiled.
174
173
  x (torch.Tensor): The input data to the layer.
175
174
  dt (list): A list to store the computation time of the layer.
176
-
177
- Returns:
178
- None
179
175
  """
180
176
  c = m == self.model[-1] and isinstance(x, list) # is final layer list, copy input as inplace fix
181
177
  flops = thop.profile(m, inputs=[x.copy() if c else x], verbose=False)[0] / 1e9 * 2 if thop else 0 # GFLOPs
@@ -195,7 +191,7 @@ class BaseModel(nn.Module):
195
191
  computation efficiency.
196
192
 
197
193
  Returns:
198
- (nn.Module): The fused model is returned.
194
+ (torch.nn.Module): The fused model is returned.
199
195
  """
200
196
  if not self.is_fused():
201
197
  for m in self.model.modules():
@@ -229,7 +225,7 @@ class BaseModel(nn.Module):
229
225
  Returns:
230
226
  (bool): True if the number of BatchNorm layers in the model is less than the threshold, False otherwise.
231
227
  """
232
- bn = tuple(v for k, v in nn.__dict__.items() if "Norm" in k) # normalization layers, i.e. BatchNorm2d()
228
+ bn = tuple(v for k, v in torch.nn.__dict__.items() if "Norm" in k) # normalization layers, i.e. BatchNorm2d()
233
229
  return sum(isinstance(v, bn) for v in self.modules()) < thresh # True if < 'thresh' BatchNorm layers in model
234
230
 
235
231
  def info(self, detailed=False, verbose=True, imgsz=640):
@@ -304,7 +300,7 @@ class DetectionModel(BaseModel):
304
300
  self.yaml = cfg if isinstance(cfg, dict) else yaml_model_load(cfg) # cfg dict
305
301
  if self.yaml["backbone"][0][2] == "Silence":
306
302
  LOGGER.warning(
307
- "WARNING ⚠️ YOLOv9 `Silence` module is deprecated in favor of nn.Identity. "
303
+ "WARNING ⚠️ YOLOv9 `Silence` module is deprecated in favor of torch.nn.Identity. "
308
304
  "Please delete local *.pt file and re-download the latest model checkpoint."
309
305
  )
310
306
  self.yaml["backbone"][0][2] = "nn.Identity"
@@ -458,20 +454,22 @@ class ClassificationModel(BaseModel):
458
454
  name, m = list((model.model if hasattr(model, "model") else model).named_children())[-1] # last module
459
455
  if isinstance(m, Classify): # YOLO Classify() head
460
456
  if m.linear.out_features != nc:
461
- m.linear = nn.Linear(m.linear.in_features, nc)
462
- elif isinstance(m, nn.Linear): # ResNet, EfficientNet
457
+ m.linear = torch.nn.Linear(m.linear.in_features, nc)
458
+ elif isinstance(m, torch.nn.Linear): # ResNet, EfficientNet
463
459
  if m.out_features != nc:
464
- setattr(model, name, nn.Linear(m.in_features, nc))
465
- elif isinstance(m, nn.Sequential):
460
+ setattr(model, name, torch.nn.Linear(m.in_features, nc))
461
+ elif isinstance(m, torch.nn.Sequential):
466
462
  types = [type(x) for x in m]
467
- if nn.Linear in types:
468
- i = len(types) - 1 - types[::-1].index(nn.Linear) # last nn.Linear index
463
+ if torch.nn.Linear in types:
464
+ i = len(types) - 1 - types[::-1].index(torch.nn.Linear) # last torch.nn.Linear index
469
465
  if m[i].out_features != nc:
470
- m[i] = nn.Linear(m[i].in_features, nc)
471
- elif nn.Conv2d in types:
472
- i = len(types) - 1 - types[::-1].index(nn.Conv2d) # last nn.Conv2d index
466
+ m[i] = torch.nn.Linear(m[i].in_features, nc)
467
+ elif torch.nn.Conv2d in types:
468
+ i = len(types) - 1 - types[::-1].index(torch.nn.Conv2d) # last torch.nn.Conv2d index
473
469
  if m[i].out_channels != nc:
474
- m[i] = nn.Conv2d(m[i].in_channels, nc, m[i].kernel_size, m[i].stride, bias=m[i].bias is not None)
470
+ m[i] = torch.nn.Conv2d(
471
+ m[i].in_channels, nc, m[i].kernel_size, m[i].stride, bias=m[i].bias is not None
472
+ )
475
473
 
476
474
  def init_criterion(self):
477
475
  """Initialize the loss criterion for the ClassificationModel."""
@@ -486,12 +484,6 @@ class RTDETRDetectionModel(DetectionModel):
486
484
  the training and inference processes. RTDETR is an object detection and tracking model that extends from the
487
485
  DetectionModel base class.
488
486
 
489
- Attributes:
490
- cfg (str): The configuration file path or preset string. Default is 'rtdetr-l.yaml'.
491
- ch (int): Number of input channels. Default is 3 (RGB).
492
- nc (int, optional): Number of classes for object detection. Default is None.
493
- verbose (bool): Specifies if summary statistics are shown during initialization. Default is True.
494
-
495
487
  Methods:
496
488
  init_criterion: Initializes the criterion used for loss calculation.
497
489
  loss: Computes and returns the loss during training.
@@ -587,7 +579,7 @@ class RTDETRDetectionModel(DetectionModel):
587
579
  if visualize:
588
580
  feature_visualization(x, m.type, m.i, save_dir=visualize)
589
581
  if embed and m.i in embed:
590
- embeddings.append(nn.functional.adaptive_avg_pool2d(x, (1, 1)).squeeze(-1).squeeze(-1)) # flatten
582
+ embeddings.append(torch.nn.functional.adaptive_avg_pool2d(x, (1, 1)).squeeze(-1).squeeze(-1)) # flatten
591
583
  if m.i == max(embed):
592
584
  return torch.unbind(torch.cat(embeddings, 1), dim=0)
593
585
  head = self.model[-1]
@@ -663,7 +655,7 @@ class WorldModel(DetectionModel):
663
655
  if visualize:
664
656
  feature_visualization(x, m.type, m.i, save_dir=visualize)
665
657
  if embed and m.i in embed:
666
- embeddings.append(nn.functional.adaptive_avg_pool2d(x, (1, 1)).squeeze(-1).squeeze(-1)) # flatten
658
+ embeddings.append(torch.nn.functional.adaptive_avg_pool2d(x, (1, 1)).squeeze(-1).squeeze(-1)) # flatten
667
659
  if m.i == max(embed):
668
660
  return torch.unbind(torch.cat(embeddings, 1), dim=0)
669
661
  return x
@@ -684,7 +676,7 @@ class WorldModel(DetectionModel):
684
676
  return self.criterion(preds, batch)
685
677
 
686
678
 
687
- class Ensemble(nn.ModuleList):
679
+ class Ensemble(torch.nn.ModuleList):
688
680
  """Ensemble of models."""
689
681
 
690
682
  def __init__(self):
@@ -887,7 +879,7 @@ def attempt_load_weights(weights, device=None, inplace=True, fuse=False):
887
879
  for m in ensemble.modules():
888
880
  if hasattr(m, "inplace"):
889
881
  m.inplace = inplace
890
- elif isinstance(m, nn.Upsample) and not hasattr(m, "recompute_scale_factor"):
882
+ elif isinstance(m, torch.nn.Upsample) and not hasattr(m, "recompute_scale_factor"):
891
883
  m.recompute_scale_factor = None # torch 1.11.0 compatibility
892
884
 
893
885
  # Return model
@@ -922,7 +914,7 @@ def attempt_load_one_weight(weight, device=None, inplace=True, fuse=False):
922
914
  for m in model.modules():
923
915
  if hasattr(m, "inplace"):
924
916
  m.inplace = inplace
925
- elif isinstance(m, nn.Upsample) and not hasattr(m, "recompute_scale_factor"):
917
+ elif isinstance(m, torch.nn.Upsample) and not hasattr(m, "recompute_scale_factor"):
926
918
  m.recompute_scale_factor = None # torch 1.11.0 compatibility
927
919
 
928
920
  # Return model and ckpt
@@ -946,7 +938,7 @@ def parse_model(d, ch, verbose=True): # model_dict, input_channels(3)
946
938
  depth, width, max_channels = scales[scale]
947
939
 
948
940
  if act:
949
- Conv.default_act = eval(act) # redefine default activation, i.e. Conv.default_act = nn.SiLU()
941
+ Conv.default_act = eval(act) # redefine default activation, i.e. Conv.default_act = torch.nn.SiLU()
950
942
  if verbose:
951
943
  LOGGER.info(f"{colorstr('activation:')} {act}") # print
952
944
 
@@ -982,7 +974,7 @@ def parse_model(d, ch, verbose=True): # model_dict, input_channels(3)
982
974
  C3,
983
975
  C3TR,
984
976
  C3Ghost,
985
- nn.ConvTranspose2d,
977
+ torch.nn.ConvTranspose2d,
986
978
  DWConvTranspose2d,
987
979
  C3x,
988
980
  RepC3,
@@ -1048,7 +1040,7 @@ def parse_model(d, ch, verbose=True): # model_dict, input_channels(3)
1048
1040
  n = 1
1049
1041
  elif m is ResNetLayer:
1050
1042
  c2 = args[1] if args[3] else args[1] * 4
1051
- elif m is nn.BatchNorm2d:
1043
+ elif m is torch.nn.BatchNorm2d:
1052
1044
  args = [ch[f]]
1053
1045
  elif m is Concat:
1054
1046
  c2 = sum(ch[x] for x in f)
@@ -1073,7 +1065,7 @@ def parse_model(d, ch, verbose=True): # model_dict, input_channels(3)
1073
1065
  else:
1074
1066
  c2 = ch[f]
1075
1067
 
1076
- m_ = nn.Sequential(*(m(*args) for _ in range(n))) if n > 1 else m(*args) # module
1068
+ m_ = torch.nn.Sequential(*(m(*args) for _ in range(n))) if n > 1 else m(*args) # module
1077
1069
  t = str(m)[8:-2].replace("__main__.", "") # module type
1078
1070
  m_.np = sum(x.numel() for x in m_.parameters()) # number params
1079
1071
  m_.i, m_.f, m_.type = i, f, t # attach index, 'from' index, type
@@ -1084,7 +1076,7 @@ def parse_model(d, ch, verbose=True): # model_dict, input_channels(3)
1084
1076
  if i == 0:
1085
1077
  ch = []
1086
1078
  ch.append(c2)
1087
- return nn.Sequential(*layers), sorted(save)
1079
+ return torch.nn.Sequential(*layers), sorted(save)
1088
1080
 
1089
1081
 
1090
1082
  def yaml_model_load(path):
@@ -1126,7 +1118,7 @@ def guess_model_task(model):
1126
1118
  Guess the task of a PyTorch model from its architecture or configuration.
1127
1119
 
1128
1120
  Args:
1129
- model (nn.Module | dict): PyTorch model or model configuration in YAML format.
1121
+ model (torch.nn.Module | dict): PyTorch model or model configuration in YAML format.
1130
1122
 
1131
1123
  Returns:
1132
1124
  (str): Task of the model ('detect', 'segment', 'classify', 'pose').
@@ -1154,7 +1146,7 @@ def guess_model_task(model):
1154
1146
  with contextlib.suppress(Exception):
1155
1147
  return cfg2task(model)
1156
1148
  # Guess from PyTorch model
1157
- if isinstance(model, nn.Module): # PyTorch model
1149
+ if isinstance(model, torch.nn.Module): # PyTorch model
1158
1150
  for x in "model.args", "model.model.args", "model.model.model.args":
1159
1151
  with contextlib.suppress(Exception):
1160
1152
  return eval(x)["task"]
@@ -801,9 +801,8 @@ class Annotator:
801
801
  return
802
802
 
803
803
  cv2.polylines(self.im, [np.int32([mask])], isClosed=True, color=mask_color, thickness=2)
804
- text_size, _ = cv2.getTextSize(label, 0, self.sf, self.tf)
805
-
806
804
  if label:
805
+ text_size, _ = cv2.getTextSize(label, 0, self.sf, self.tf)
807
806
  cv2.rectangle(
808
807
  self.im,
809
808
  (int(mask[0][0]) - text_size[0] // 2 - 10, int(mask[0][1]) - text_size[1] - 10),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ultralytics
3
- Version: 8.3.70
3
+ Version: 8.3.72
4
4
  Summary: Ultralytics YOLO 🚀 for SOTA object detection, multi-object tracking, instance segmentation, pose estimation and image classification.
5
5
  Author-email: Glenn Jocher <glenn.jocher@ultralytics.com>, Jing Qiu <jing.qiu@ultralytics.com>
6
6
  Maintainer-email: Ultralytics <hello@ultralytics.com>
@@ -54,10 +54,11 @@ Requires-Dist: pytest; extra == "dev"
54
54
  Requires-Dist: pytest-cov; extra == "dev"
55
55
  Requires-Dist: coverage[toml]; extra == "dev"
56
56
  Requires-Dist: mkdocs>=1.6.0; extra == "dev"
57
+ Requires-Dist: beautifulsoup4<=4.12.3; extra == "dev"
57
58
  Requires-Dist: mkdocs-material>=9.5.9; extra == "dev"
58
59
  Requires-Dist: mkdocstrings[python]; extra == "dev"
59
60
  Requires-Dist: mkdocs-redirects; extra == "dev"
60
- Requires-Dist: mkdocs-ultralytics-plugin>=0.1.16; extra == "dev"
61
+ Requires-Dist: mkdocs-ultralytics-plugin>=0.1.17; extra == "dev"
61
62
  Requires-Dist: mkdocs-macros-plugin>=1.0.5; extra == "dev"
62
63
  Provides-Extra: export
63
64
  Requires-Dist: onnx>=1.12.0; extra == "export"
@@ -7,7 +7,7 @@ tests/test_exports.py,sha256=T_z_NUS9URQXv83k5XNLHTuksJ8srtzbZnWuiiQWM98,9260
7
7
  tests/test_integrations.py,sha256=p3DMnnPMKsV0Qm82JVJUIY1UZ67xRgF9E8AaL76TEHE,6154
8
8
  tests/test_python.py,sha256=tW-EFJC2rjl_DvAa8khXGWYdypseQjrLjGHhe2p9r9A,23238
9
9
  tests/test_solutions.py,sha256=aY0G3vNzXGCENG9FD76MfUp7jgzeESPsUvbvQYBUvH0,4205
10
- ultralytics/__init__.py,sha256=j3YQErIHDNSCpzI0cVKuv3P5WDskw3yu1p1_ZVpOZFY,709
10
+ ultralytics/__init__.py,sha256=y9BHqgcVeskz2VP0BY3sracXVHaR4Rf6Z7qXeSKo3OA,709
11
11
  ultralytics/assets/bus.jpg,sha256=wCAZxJecGR63Od3ZRERe9Aja1Weayrb9Ug751DS_vGM,137419
12
12
  ultralytics/assets/zidane.jpg,sha256=Ftc4aeMmen1O0A3o6GCDO9FlfBslLpTAw0gnetx7bts,50427
13
13
  ultralytics/cfg/__init__.py,sha256=qP44HnFP4QcC5FQz29A-EGTuwdtxXAzPvw_IvCVmiqA,39771
@@ -63,7 +63,7 @@ ultralytics/cfg/models/v3/yolov3-tiny.yaml,sha256=_DtEMJBOTriSaTUA3Aw5LvwgXyc3v_
63
63
  ultralytics/cfg/models/v3/yolov3.yaml,sha256=Fvt4_PTwLBpRw3R4v4VQ-1PIiojpoFZD1uuTZySUYSw,1612
64
64
  ultralytics/cfg/models/v5/yolov5-p6.yaml,sha256=VKEWykksykSlzvuy7if4yFo9WlblC3hdqcNxJ9bwHek,1994
65
65
  ultralytics/cfg/models/v5/yolov5.yaml,sha256=QD8dRe5e5ys52wXPKvNJn622H_3iX0jPzE_2--2dZx0,1626
66
- ultralytics/cfg/models/v6/yolov6.yaml,sha256=1mvf7RrZwoTqlgNpQnqCLyvIrDJ4OfN62bV4s9Bzn08,1807
66
+ ultralytics/cfg/models/v6/yolov6.yaml,sha256=NrRxq_E6yXnMZqJcLXrIPZtj8eqAxFxSAz4MDFGcwEg,1813
67
67
  ultralytics/cfg/models/v8/yolov8-cls-resnet101.yaml,sha256=0JaJos3dYrDryy_KdizfLZcGUawaNtFHjcL2GZJNzmA,994
68
68
  ultralytics/cfg/models/v8/yolov8-cls-resnet50.yaml,sha256=DvFH4vwpyqPZkLc_zY4KcCQbfAHj9LUv3nAjKx4ffow,992
69
69
  ultralytics/cfg/models/v8/yolov8-cls.yaml,sha256=G50mnw-C0SWrZpZl5wzov1dugdjZMM6zT30t5cQrcJQ,1019
@@ -102,10 +102,10 @@ ultralytics/data/loaders.py,sha256=JOwXbz-dxgG2bx0_cQHp-olz5FleoCX8EzrUvZ77vvg,2
102
102
  ultralytics/data/split_dota.py,sha256=YI-i2MqdiBt06W67TJnBXQHJrqTnkJDJ3zzoL0UZVro,10733
103
103
  ultralytics/data/utils.py,sha256=K8xyA1xHLpaeluUbqOl5fy6AWZ6nDciCBZJofjxzOuw,33841
104
104
  ultralytics/engine/__init__.py,sha256=lm6MckFYCPTbqIoX7w0s_daxdjNeBeKW6DXppv1-QUM,70
105
- ultralytics/engine/exporter.py,sha256=aXUX8GZUw1CBaXYSI7OFwx1tsnl6VkgQQXb_iKi-cs8,76632
106
- ultralytics/engine/model.py,sha256=OmYpb5YiCM_FPsqezUybWfUUD5jgWDvOu0CPg0hxj2Q,53239
105
+ ultralytics/engine/exporter.py,sha256=14zD5klVbAqv1jh2QPmpDcGflBUlLurRhYGM-wH9hFI,76780
106
+ ultralytics/engine/model.py,sha256=SbRt27DTUmq8S-yzog4o5EDcT4qX08EF7A8fyLzv4kQ,53275
107
107
  ultralytics/engine/predictor.py,sha256=jiYDAjupOlRUpPvw9tu7or9PjXtLm-YCRiawANtWxj0,17881
108
- ultralytics/engine/results.py,sha256=3jag9GQcJ2a_No76tEOWvT8gqm4X-SWAxoVc0NYenbI,78512
108
+ ultralytics/engine/results.py,sha256=OkXecfudYauisFxJocr3TXJgUb16vYxr_TL2u-Aa0rk,78710
109
109
  ultralytics/engine/trainer.py,sha256=ZGAc6C1_LUBHDdZlr6wT6sbMtDzWa5rr7M8QVlXpBLs,37362
110
110
  ultralytics/engine/tuner.py,sha256=EUlTs7KJQ2RVABm8pihr_14M_Z2kGSzJaWH-Y9TJYDw,11976
111
111
  ultralytics/engine/validator.py,sha256=r27X8HGeDEwq7V5sFjEQH_3EnP1CyG-HcOLpFABUisU,15034
@@ -139,7 +139,7 @@ ultralytics/models/sam/modules/blocks.py,sha256=CxThxk988iNy4jw_D599dWRWTj9FtkC8
139
139
  ultralytics/models/sam/modules/decoders.py,sha256=hRtZcrnZVV7SkwaYQuggX4_eCKIXxDbc-oP6iZisz24,25858
140
140
  ultralytics/models/sam/modules/encoders.py,sha256=7P8DT7Pv9N03tOyW18_UXzKYAjoEGcLey1GsJWp29DI,34852
141
141
  ultralytics/models/sam/modules/memory_attention.py,sha256=qV6so3WTFx2sey-VTE9IRS4clqXaBhWoFlScUYvjdEk,9750
142
- ultralytics/models/sam/modules/sam.py,sha256=5sw9AWxuOsJOXrXSTuyC5By6wfhBjiNYStF1eWHWvh0,52751
142
+ ultralytics/models/sam/modules/sam.py,sha256=zMyQNXAaRFHpjTxD8Q9fv2dRZKm-Gb5Ce9W2_VQMqXA,52754
143
143
  ultralytics/models/sam/modules/tiny_encoder.py,sha256=QYvZJlbeEQBpvw57Oj3LbZG3SuajrLD9J88rXVKBx3E,41372
144
144
  ultralytics/models/sam/modules/transformer.py,sha256=T_8AXVrxl9HDlBAUHNOysKZqKLD3guEKGme5JeDtwT8,16109
145
145
  ultralytics/models/sam/modules/utils.py,sha256=udx4cIfISm5nS8_YPUQwtWPSwACKbJdAnR8Rtyei6Ds,12343
@@ -163,7 +163,7 @@ ultralytics/models/yolo/obb/val.py,sha256=BydJTPxJS9hfuMFCqsm0xuLdKzxEFn4AKVqbfo
163
163
  ultralytics/models/yolo/pose/__init__.py,sha256=63xmuHZLNzV8I76HhVXAq4f2W0KTk8Oi9eL-Y204LyQ,227
164
164
  ultralytics/models/yolo/pose/predict.py,sha256=O-LI_acPh_xoXd7ZcxpxAUbIzfj5FkrwEXLuN16Rl7c,2120
165
165
  ultralytics/models/yolo/pose/train.py,sha256=472BgOjvDdNXe9GN68zO1ddRh5Cbmfg5m9_JZyHrTxY,2954
166
- ultralytics/models/yolo/pose/val.py,sha256=cdew3dyh7-rjlzVzXr9A7oFrd0z8rv2GhfLZl5jMxrU,11966
166
+ ultralytics/models/yolo/pose/val.py,sha256=W3OunA3SjhoKx5JICPth836pVjk6xejzMSn0Qm62r9o,11968
167
167
  ultralytics/models/yolo/segment/__init__.py,sha256=3IThhZ1wlkY9FvmWm9cE-5-ZyE6F1FgzAtQ6jOOFzzw,275
168
168
  ultralytics/models/yolo/segment/predict.py,sha256=p5bLdex_74bfk7pMr_NLAGISi6YOj8pMmUKF7aZ7lxk,3417
169
169
  ultralytics/models/yolo/segment/train.py,sha256=2PGirZ7cvAsK2LxrEKC0HisOqPw6hyUCAPMkYmqQkIY,2326
@@ -172,8 +172,8 @@ ultralytics/models/yolo/world/__init__.py,sha256=nlh8I6t8hMGz_vZg8QSlsUW1R-2eKvn
172
172
  ultralytics/models/yolo/world/train.py,sha256=6PVmQ0G-22OOPPwP_rqSobe2LM6e2b_lC7lJCdW3UIk,3714
173
173
  ultralytics/models/yolo/world/train_world.py,sha256=sCtg4Hnq9Y7amYjlQsdvTHXH8cKSooipvcXu_1Iyb2k,4885
174
174
  ultralytics/nn/__init__.py,sha256=rjociYD9lo_K-d-1s6TbdWklPLjTcEHk7OIlRDJstIE,615
175
- ultralytics/nn/autobackend.py,sha256=gYZ0BjyYuPdxVfshjcrjFX9F5Rvi_5J9HijEEGGlDmg,37574
176
- ultralytics/nn/tasks.py,sha256=Qe9EZ7NBDT5zOFAqJSl5XhYWnMDByuQL80r6pP0TuDM,48892
175
+ ultralytics/nn/autobackend.py,sha256=Sixewlem0qeGCD18Zihli1H25j1q71957L33kpVfrVE,37365
176
+ ultralytics/nn/tasks.py,sha256=Ckg6qFHZiJjRfYimV_F6cdC0nbKmbzu-E890lWMuyBA,48696
177
177
  ultralytics/nn/modules/__init__.py,sha256=02dPoAMtpPNQdHXHmvJeWZvJ_WG6eqwH8atLdFWgcuY,2713
178
178
  ultralytics/nn/modules/activation.py,sha256=oRkhMdqlNpIxQb35pTSUeHV-h0VyLl96GOqvIZ4OvT8,923
179
179
  ultralytics/nn/modules/block.py,sha256=vQqfKIXPmEnxupdzcLDGC5FkjCNIqURfqt4CEEseuXE,43940
@@ -217,7 +217,7 @@ ultralytics/utils/loss.py,sha256=paRY8K7R4pcUGJfApVzZx-m_iFzzMbHm5GgiaixfDuU,341
217
217
  ultralytics/utils/metrics.py,sha256=onGJkd4DW8DUofFFtHm9xoUCt8gcNlcCxxU-Q39IN7k,54175
218
218
  ultralytics/utils/ops.py,sha256=HJ33Z9U1_Fl2MJyiv1JKLb2hTmvQqbeNemqR0lbCZgQ,34576
219
219
  ultralytics/utils/patches.py,sha256=ARR89dP4YKq7Dd3g2eU-ukbnc2lo3BELukL_1c_d854,3298
220
- ultralytics/utils/plotting.py,sha256=cl8mctrkBMMTE976yrqDn1I8dH6IPO3ROZl99t5fo9w,62987
220
+ ultralytics/utils/plotting.py,sha256=hKji4TyxAmCXdSL264VX6dsC2AZYiL9StShI02dcAOM,62990
221
221
  ultralytics/utils/tal.py,sha256=DO-c006HEI62pcrNRpmt4lpqJPC5yu3veRDOvUuExno,18498
222
222
  ultralytics/utils/torch_utils.py,sha256=LjgZg5O9G2Qw1ZwX6axOt8QFwu3wqm0mWZHerMCy9jg,33165
223
223
  ultralytics/utils/triton.py,sha256=2L1_rZ8xCJEjexRVj75g9YU-u4tQln_DJ5N1Yr_0bSs,4071
@@ -233,9 +233,9 @@ ultralytics/utils/callbacks/neptune.py,sha256=waZ_bRu0-qBKujTLuqonC2gx2DkgBuVnfq
233
233
  ultralytics/utils/callbacks/raytune.py,sha256=TbuZlDb721aIkh-nMozZcP2g_ttUh2cG5LUaXmept6g,728
234
234
  ultralytics/utils/callbacks/tensorboard.py,sha256=JHOEVlNQ5dYJPd4Z-EvqbXowuK5uA0p8wPgyyaIUQs0,4194
235
235
  ultralytics/utils/callbacks/wb.py,sha256=ayhT2y62AcSOacnawshATU0rWrlSFQ77mrGgBdRl3W4,7086
236
- ultralytics-8.3.70.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
237
- ultralytics-8.3.70.dist-info/METADATA,sha256=8zLROnbBCxv6CrH0DeczplZZ_AKSFebeiOSNTwOp1kU,35158
238
- ultralytics-8.3.70.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
239
- ultralytics-8.3.70.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
240
- ultralytics-8.3.70.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
241
- ultralytics-8.3.70.dist-info/RECORD,,
236
+ ultralytics-8.3.72.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
237
+ ultralytics-8.3.72.dist-info/METADATA,sha256=ab2Cc23pNsmH8lArrPzXbsRS_dYxCWmhR2dBLLl0kxI,35212
238
+ ultralytics-8.3.72.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
239
+ ultralytics-8.3.72.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
240
+ ultralytics-8.3.72.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
241
+ ultralytics-8.3.72.dist-info/RECORD,,