dgenerate-ultralytics-headless 8.3.222__py3-none-any.whl → 8.3.225__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.
Files changed (158) hide show
  1. {dgenerate_ultralytics_headless-8.3.222.dist-info → dgenerate_ultralytics_headless-8.3.225.dist-info}/METADATA +2 -2
  2. dgenerate_ultralytics_headless-8.3.225.dist-info/RECORD +286 -0
  3. tests/conftest.py +5 -8
  4. tests/test_cli.py +1 -8
  5. tests/test_python.py +1 -2
  6. ultralytics/__init__.py +1 -1
  7. ultralytics/cfg/__init__.py +34 -49
  8. ultralytics/cfg/datasets/ImageNet.yaml +1 -1
  9. ultralytics/cfg/datasets/kitti.yaml +27 -0
  10. ultralytics/cfg/datasets/lvis.yaml +5 -5
  11. ultralytics/cfg/datasets/open-images-v7.yaml +1 -1
  12. ultralytics/data/annotator.py +3 -4
  13. ultralytics/data/augment.py +244 -323
  14. ultralytics/data/base.py +12 -22
  15. ultralytics/data/build.py +47 -40
  16. ultralytics/data/converter.py +32 -42
  17. ultralytics/data/dataset.py +43 -71
  18. ultralytics/data/loaders.py +22 -34
  19. ultralytics/data/split.py +5 -6
  20. ultralytics/data/split_dota.py +8 -15
  21. ultralytics/data/utils.py +27 -36
  22. ultralytics/engine/exporter.py +49 -116
  23. ultralytics/engine/model.py +144 -180
  24. ultralytics/engine/predictor.py +18 -29
  25. ultralytics/engine/results.py +165 -231
  26. ultralytics/engine/trainer.py +11 -19
  27. ultralytics/engine/tuner.py +13 -23
  28. ultralytics/engine/validator.py +6 -10
  29. ultralytics/hub/__init__.py +7 -12
  30. ultralytics/hub/auth.py +6 -12
  31. ultralytics/hub/google/__init__.py +7 -10
  32. ultralytics/hub/session.py +15 -25
  33. ultralytics/hub/utils.py +3 -6
  34. ultralytics/models/fastsam/model.py +6 -8
  35. ultralytics/models/fastsam/predict.py +5 -10
  36. ultralytics/models/fastsam/utils.py +1 -2
  37. ultralytics/models/fastsam/val.py +2 -4
  38. ultralytics/models/nas/model.py +5 -8
  39. ultralytics/models/nas/predict.py +7 -9
  40. ultralytics/models/nas/val.py +1 -2
  41. ultralytics/models/rtdetr/model.py +5 -8
  42. ultralytics/models/rtdetr/predict.py +15 -18
  43. ultralytics/models/rtdetr/train.py +10 -13
  44. ultralytics/models/rtdetr/val.py +13 -20
  45. ultralytics/models/sam/amg.py +12 -18
  46. ultralytics/models/sam/build.py +6 -9
  47. ultralytics/models/sam/model.py +16 -23
  48. ultralytics/models/sam/modules/blocks.py +62 -84
  49. ultralytics/models/sam/modules/decoders.py +17 -24
  50. ultralytics/models/sam/modules/encoders.py +40 -56
  51. ultralytics/models/sam/modules/memory_attention.py +10 -16
  52. ultralytics/models/sam/modules/sam.py +41 -47
  53. ultralytics/models/sam/modules/tiny_encoder.py +64 -83
  54. ultralytics/models/sam/modules/transformer.py +17 -27
  55. ultralytics/models/sam/modules/utils.py +31 -42
  56. ultralytics/models/sam/predict.py +172 -209
  57. ultralytics/models/utils/loss.py +14 -26
  58. ultralytics/models/utils/ops.py +13 -17
  59. ultralytics/models/yolo/classify/predict.py +8 -11
  60. ultralytics/models/yolo/classify/train.py +8 -16
  61. ultralytics/models/yolo/classify/val.py +13 -20
  62. ultralytics/models/yolo/detect/predict.py +4 -8
  63. ultralytics/models/yolo/detect/train.py +11 -20
  64. ultralytics/models/yolo/detect/val.py +38 -48
  65. ultralytics/models/yolo/model.py +35 -47
  66. ultralytics/models/yolo/obb/predict.py +5 -8
  67. ultralytics/models/yolo/obb/train.py +11 -14
  68. ultralytics/models/yolo/obb/val.py +20 -28
  69. ultralytics/models/yolo/pose/predict.py +5 -8
  70. ultralytics/models/yolo/pose/train.py +4 -8
  71. ultralytics/models/yolo/pose/val.py +31 -39
  72. ultralytics/models/yolo/segment/predict.py +9 -14
  73. ultralytics/models/yolo/segment/train.py +3 -6
  74. ultralytics/models/yolo/segment/val.py +16 -26
  75. ultralytics/models/yolo/world/train.py +8 -14
  76. ultralytics/models/yolo/world/train_world.py +11 -16
  77. ultralytics/models/yolo/yoloe/predict.py +16 -23
  78. ultralytics/models/yolo/yoloe/train.py +30 -43
  79. ultralytics/models/yolo/yoloe/train_seg.py +5 -10
  80. ultralytics/models/yolo/yoloe/val.py +15 -20
  81. ultralytics/nn/autobackend.py +10 -18
  82. ultralytics/nn/modules/activation.py +4 -6
  83. ultralytics/nn/modules/block.py +99 -185
  84. ultralytics/nn/modules/conv.py +45 -90
  85. ultralytics/nn/modules/head.py +44 -98
  86. ultralytics/nn/modules/transformer.py +44 -76
  87. ultralytics/nn/modules/utils.py +14 -19
  88. ultralytics/nn/tasks.py +86 -146
  89. ultralytics/nn/text_model.py +25 -40
  90. ultralytics/solutions/ai_gym.py +10 -16
  91. ultralytics/solutions/analytics.py +7 -10
  92. ultralytics/solutions/config.py +4 -5
  93. ultralytics/solutions/distance_calculation.py +9 -12
  94. ultralytics/solutions/heatmap.py +7 -13
  95. ultralytics/solutions/instance_segmentation.py +5 -8
  96. ultralytics/solutions/object_blurrer.py +7 -10
  97. ultralytics/solutions/object_counter.py +8 -12
  98. ultralytics/solutions/object_cropper.py +5 -8
  99. ultralytics/solutions/parking_management.py +12 -14
  100. ultralytics/solutions/queue_management.py +4 -6
  101. ultralytics/solutions/region_counter.py +7 -10
  102. ultralytics/solutions/security_alarm.py +14 -19
  103. ultralytics/solutions/similarity_search.py +7 -12
  104. ultralytics/solutions/solutions.py +31 -53
  105. ultralytics/solutions/speed_estimation.py +6 -9
  106. ultralytics/solutions/streamlit_inference.py +2 -4
  107. ultralytics/solutions/trackzone.py +7 -10
  108. ultralytics/solutions/vision_eye.py +5 -8
  109. ultralytics/trackers/basetrack.py +2 -4
  110. ultralytics/trackers/bot_sort.py +6 -11
  111. ultralytics/trackers/byte_tracker.py +10 -15
  112. ultralytics/trackers/track.py +3 -6
  113. ultralytics/trackers/utils/gmc.py +6 -12
  114. ultralytics/trackers/utils/kalman_filter.py +35 -43
  115. ultralytics/trackers/utils/matching.py +6 -10
  116. ultralytics/utils/__init__.py +61 -100
  117. ultralytics/utils/autobatch.py +2 -4
  118. ultralytics/utils/autodevice.py +11 -13
  119. ultralytics/utils/benchmarks.py +25 -35
  120. ultralytics/utils/callbacks/base.py +8 -10
  121. ultralytics/utils/callbacks/clearml.py +2 -4
  122. ultralytics/utils/callbacks/comet.py +30 -44
  123. ultralytics/utils/callbacks/dvc.py +13 -18
  124. ultralytics/utils/callbacks/mlflow.py +4 -5
  125. ultralytics/utils/callbacks/neptune.py +4 -6
  126. ultralytics/utils/callbacks/raytune.py +3 -4
  127. ultralytics/utils/callbacks/tensorboard.py +4 -6
  128. ultralytics/utils/callbacks/wb.py +10 -13
  129. ultralytics/utils/checks.py +29 -56
  130. ultralytics/utils/cpu.py +1 -2
  131. ultralytics/utils/dist.py +8 -12
  132. ultralytics/utils/downloads.py +17 -27
  133. ultralytics/utils/errors.py +6 -8
  134. ultralytics/utils/events.py +2 -4
  135. ultralytics/utils/export/__init__.py +4 -239
  136. ultralytics/utils/export/engine.py +237 -0
  137. ultralytics/utils/export/imx.py +11 -17
  138. ultralytics/utils/export/tensorflow.py +217 -0
  139. ultralytics/utils/files.py +10 -15
  140. ultralytics/utils/git.py +5 -7
  141. ultralytics/utils/instance.py +30 -51
  142. ultralytics/utils/logger.py +11 -15
  143. ultralytics/utils/loss.py +8 -14
  144. ultralytics/utils/metrics.py +98 -138
  145. ultralytics/utils/nms.py +13 -16
  146. ultralytics/utils/ops.py +47 -74
  147. ultralytics/utils/patches.py +11 -18
  148. ultralytics/utils/plotting.py +29 -42
  149. ultralytics/utils/tal.py +25 -39
  150. ultralytics/utils/torch_utils.py +45 -73
  151. ultralytics/utils/tqdm.py +6 -8
  152. ultralytics/utils/triton.py +9 -12
  153. ultralytics/utils/tuner.py +1 -2
  154. dgenerate_ultralytics_headless-8.3.222.dist-info/RECORD +0 -283
  155. {dgenerate_ultralytics_headless-8.3.222.dist-info → dgenerate_ultralytics_headless-8.3.225.dist-info}/WHEEL +0 -0
  156. {dgenerate_ultralytics_headless-8.3.222.dist-info → dgenerate_ultralytics_headless-8.3.225.dist-info}/entry_points.txt +0 -0
  157. {dgenerate_ultralytics_headless-8.3.222.dist-info → dgenerate_ultralytics_headless-8.3.225.dist-info}/licenses/LICENSE +0 -0
  158. {dgenerate_ultralytics_headless-8.3.222.dist-info → dgenerate_ultralytics_headless-8.3.225.dist-info}/top_level.txt +0 -0
@@ -138,8 +138,7 @@ STR_OR_PATH = (str, Path)
138
138
 
139
139
 
140
140
  class DataExportMixin:
141
- """
142
- Mixin class for exporting validation metrics or prediction results in various formats.
141
+ """Mixin class for exporting validation metrics or prediction results in various formats.
143
142
 
144
143
  This class provides utilities to export performance metrics (e.g., mAP, precision, recall) or prediction results
145
144
  from classification, object detection, segmentation, or pose estimation tasks into various formats: Polars
@@ -160,8 +159,7 @@ class DataExportMixin:
160
159
  """
161
160
 
162
161
  def to_df(self, normalize=False, decimals=5):
163
- """
164
- Create a polars DataFrame from the prediction results summary or validation metrics.
162
+ """Create a polars DataFrame from the prediction results summary or validation metrics.
165
163
 
166
164
  Args:
167
165
  normalize (bool, optional): Normalize numerical values for easier comparison.
@@ -175,15 +173,14 @@ class DataExportMixin:
175
173
  return pl.DataFrame(self.summary(normalize=normalize, decimals=decimals))
176
174
 
177
175
  def to_csv(self, normalize=False, decimals=5):
178
- """
179
- Export results or metrics to CSV string format.
176
+ """Export results or metrics to CSV string format.
180
177
 
181
178
  Args:
182
- normalize (bool, optional): Normalize numeric values.
183
- decimals (int, optional): Decimal precision.
179
+ normalize (bool, optional): Normalize numeric values.
180
+ decimals (int, optional): Decimal precision.
184
181
 
185
182
  Returns:
186
- (str): CSV content as string.
183
+ (str): CSV content as string.
187
184
  """
188
185
  import polars as pl
189
186
 
@@ -207,8 +204,7 @@ class DataExportMixin:
207
204
  return df_str.write_csv()
208
205
 
209
206
  def to_json(self, normalize=False, decimals=5):
210
- """
211
- Export results to JSON format.
207
+ """Export results to JSON format.
212
208
 
213
209
  Args:
214
210
  normalize (bool, optional): Normalize numeric values.
@@ -221,11 +217,10 @@ class DataExportMixin:
221
217
 
222
218
 
223
219
  class SimpleClass:
224
- """
225
- A simple base class for creating objects with string representations of their attributes.
220
+ """A simple base class for creating objects with string representations of their attributes.
226
221
 
227
- This class provides a foundation for creating objects that can be easily printed or represented as strings,
228
- showing all their non-callable attributes. It's useful for debugging and introspection of object states.
222
+ This class provides a foundation for creating objects that can be easily printed or represented as strings, showing
223
+ all their non-callable attributes. It's useful for debugging and introspection of object states.
229
224
 
230
225
  Methods:
231
226
  __str__: Return a human-readable string representation of the object.
@@ -275,12 +270,11 @@ class SimpleClass:
275
270
 
276
271
 
277
272
  class IterableSimpleNamespace(SimpleNamespace):
278
- """
279
- An iterable SimpleNamespace class that provides enhanced functionality for attribute access and iteration.
273
+ """An iterable SimpleNamespace class that provides enhanced functionality for attribute access and iteration.
280
274
 
281
- This class extends the SimpleNamespace class with additional methods for iteration, string representation,
282
- and attribute access. It is designed to be used as a convenient container for storing and accessing
283
- configuration parameters.
275
+ This class extends the SimpleNamespace class with additional methods for iteration, string representation, and
276
+ attribute access. It is designed to be used as a convenient container for storing and accessing configuration
277
+ parameters.
284
278
 
285
279
  Methods:
286
280
  __iter__: Return an iterator of key-value pairs from the namespace's attributes.
@@ -335,8 +329,7 @@ class IterableSimpleNamespace(SimpleNamespace):
335
329
 
336
330
 
337
331
  def plt_settings(rcparams=None, backend="Agg"):
338
- """
339
- Decorator to temporarily set rc parameters and the backend for a plotting function.
332
+ """Decorator to temporarily set rc parameters and the backend for a plotting function.
340
333
 
341
334
  Args:
342
335
  rcparams (dict, optional): Dictionary of rc parameters to set.
@@ -389,12 +382,11 @@ def plt_settings(rcparams=None, backend="Agg"):
389
382
 
390
383
 
391
384
  def set_logging(name="LOGGING_NAME", verbose=True):
392
- """
393
- Set up logging with UTF-8 encoding and configurable verbosity.
385
+ """Set up logging with UTF-8 encoding and configurable verbosity.
394
386
 
395
- This function configures logging for the Ultralytics library, setting the appropriate logging level and
396
- formatter based on the verbosity flag and the current process rank. It handles special cases for Windows
397
- environments where UTF-8 encoding might not be the default.
387
+ This function configures logging for the Ultralytics library, setting the appropriate logging level and formatter
388
+ based on the verbosity flag and the current process rank. It handles special cases for Windows environments where
389
+ UTF-8 encoding might not be the default.
398
390
 
399
391
  Args:
400
392
  name (str): Name of the logger.
@@ -469,8 +461,7 @@ def emojis(string=""):
469
461
 
470
462
 
471
463
  class ThreadingLocked:
472
- """
473
- A decorator class for ensuring thread-safe execution of a function or method.
464
+ """A decorator class for ensuring thread-safe execution of a function or method.
474
465
 
475
466
  This class can be used as a decorator to make sure that if the decorated function is called from multiple threads,
476
467
  only one thread at a time will be able to execute the function.
@@ -503,8 +494,7 @@ class ThreadingLocked:
503
494
 
504
495
 
505
496
  class YAML:
506
- """
507
- YAML utility class for efficient file operations with automatic C-implementation detection.
497
+ """YAML utility class for efficient file operations with automatic C-implementation detection.
508
498
 
509
499
  This class provides optimized YAML loading and saving operations using PyYAML's fastest available implementation
510
500
  (C-based when possible). It implements a singleton pattern with lazy initialization, allowing direct class method
@@ -554,8 +544,7 @@ class YAML:
554
544
 
555
545
  @classmethod
556
546
  def save(cls, file="data.yaml", data=None, header=""):
557
- """
558
- Save Python object as YAML file.
547
+ """Save Python object as YAML file.
559
548
 
560
549
  Args:
561
550
  file (str | Path): Path to save YAML file.
@@ -584,8 +573,7 @@ class YAML:
584
573
 
585
574
  @classmethod
586
575
  def load(cls, file="data.yaml", append_filename=False):
587
- """
588
- Load YAML file to Python object with robust error handling.
576
+ """Load YAML file to Python object with robust error handling.
589
577
 
590
578
  Args:
591
579
  file (str | Path): Path to YAML file.
@@ -619,8 +607,7 @@ class YAML:
619
607
 
620
608
  @classmethod
621
609
  def print(cls, yaml_file):
622
- """
623
- Pretty print YAML file or object to console.
610
+ """Pretty print YAML file or object to console.
624
611
 
625
612
  Args:
626
613
  yaml_file (str | Path | dict): Path to YAML file or dict to print.
@@ -643,8 +630,7 @@ DEFAULT_CFG = IterableSimpleNamespace(**DEFAULT_CFG_DICT)
643
630
 
644
631
 
645
632
  def read_device_model() -> str:
646
- """
647
- Read the device model information from the system and cache it for quick access.
633
+ """Read the device model information from the system and cache it for quick access.
648
634
 
649
635
  Returns:
650
636
  (str): Kernel release information.
@@ -653,8 +639,7 @@ def read_device_model() -> str:
653
639
 
654
640
 
655
641
  def is_ubuntu() -> bool:
656
- """
657
- Check if the OS is Ubuntu.
642
+ """Check if the OS is Ubuntu.
658
643
 
659
644
  Returns:
660
645
  (bool): True if OS is Ubuntu, False otherwise.
@@ -667,8 +652,7 @@ def is_ubuntu() -> bool:
667
652
 
668
653
 
669
654
  def is_colab():
670
- """
671
- Check if the current script is running inside a Google Colab notebook.
655
+ """Check if the current script is running inside a Google Colab notebook.
672
656
 
673
657
  Returns:
674
658
  (bool): True if running inside a Colab notebook, False otherwise.
@@ -677,8 +661,7 @@ def is_colab():
677
661
 
678
662
 
679
663
  def is_kaggle():
680
- """
681
- Check if the current script is running inside a Kaggle kernel.
664
+ """Check if the current script is running inside a Kaggle kernel.
682
665
 
683
666
  Returns:
684
667
  (bool): True if running inside a Kaggle kernel, False otherwise.
@@ -687,8 +670,7 @@ def is_kaggle():
687
670
 
688
671
 
689
672
  def is_jupyter():
690
- """
691
- Check if the current script is running inside a Jupyter Notebook.
673
+ """Check if the current script is running inside a Jupyter Notebook.
692
674
 
693
675
  Returns:
694
676
  (bool): True if running inside a Jupyter Notebook, False otherwise.
@@ -701,8 +683,7 @@ def is_jupyter():
701
683
 
702
684
 
703
685
  def is_runpod():
704
- """
705
- Check if the current script is running inside a RunPod container.
686
+ """Check if the current script is running inside a RunPod container.
706
687
 
707
688
  Returns:
708
689
  (bool): True if running in RunPod, False otherwise.
@@ -711,8 +692,7 @@ def is_runpod():
711
692
 
712
693
 
713
694
  def is_docker() -> bool:
714
- """
715
- Determine if the script is running inside a Docker container.
695
+ """Determine if the script is running inside a Docker container.
716
696
 
717
697
  Returns:
718
698
  (bool): True if the script is running inside a Docker container, False otherwise.
@@ -724,8 +704,7 @@ def is_docker() -> bool:
724
704
 
725
705
 
726
706
  def is_raspberrypi() -> bool:
727
- """
728
- Determine if the Python environment is running on a Raspberry Pi.
707
+ """Determine if the Python environment is running on a Raspberry Pi.
729
708
 
730
709
  Returns:
731
710
  (bool): True if running on a Raspberry Pi, False otherwise.
@@ -735,8 +714,7 @@ def is_raspberrypi() -> bool:
735
714
 
736
715
  @lru_cache(maxsize=3)
737
716
  def is_jetson(jetpack=None) -> bool:
738
- """
739
- Determine if the Python environment is running on an NVIDIA Jetson device.
717
+ """Determine if the Python environment is running on an NVIDIA Jetson device.
740
718
 
741
719
  Args:
742
720
  jetpack (int | None): If specified, check for specific JetPack version (4, 5, 6).
@@ -756,8 +734,7 @@ def is_jetson(jetpack=None) -> bool:
756
734
 
757
735
 
758
736
  def is_online() -> bool:
759
- """
760
- Fast online check using DNS (v4/v6) resolution (Cloudflare + Google).
737
+ """Fast online check using DNS (v4/v6) resolution (Cloudflare + Google).
761
738
 
762
739
  Returns:
763
740
  (bool): True if connection is successful, False otherwise.
@@ -775,8 +752,7 @@ def is_online() -> bool:
775
752
 
776
753
 
777
754
  def is_pip_package(filepath: str = __name__) -> bool:
778
- """
779
- Determine if the file at the given filepath is part of a pip package.
755
+ """Determine if the file at the given filepath is part of a pip package.
780
756
 
781
757
  Args:
782
758
  filepath (str): The filepath to check.
@@ -794,8 +770,7 @@ def is_pip_package(filepath: str = __name__) -> bool:
794
770
 
795
771
 
796
772
  def is_dir_writeable(dir_path: str | Path) -> bool:
797
- """
798
- Check if a directory is writable.
773
+ """Check if a directory is writable.
799
774
 
800
775
  Args:
801
776
  dir_path (str | Path): The path to the directory.
@@ -807,8 +782,7 @@ def is_dir_writeable(dir_path: str | Path) -> bool:
807
782
 
808
783
 
809
784
  def is_pytest_running():
810
- """
811
- Determine whether pytest is currently running or not.
785
+ """Determine whether pytest is currently running or not.
812
786
 
813
787
  Returns:
814
788
  (bool): True if pytest is running, False otherwise.
@@ -817,8 +791,7 @@ def is_pytest_running():
817
791
 
818
792
 
819
793
  def is_github_action_running() -> bool:
820
- """
821
- Determine if the current environment is a GitHub Actions runner.
794
+ """Determine if the current environment is a GitHub Actions runner.
822
795
 
823
796
  Returns:
824
797
  (bool): True if the current environment is a GitHub Actions runner, False otherwise.
@@ -827,8 +800,7 @@ def is_github_action_running() -> bool:
827
800
 
828
801
 
829
802
  def get_default_args(func):
830
- """
831
- Return a dictionary of default arguments for a function.
803
+ """Return a dictionary of default arguments for a function.
832
804
 
833
805
  Args:
834
806
  func (callable): The function to inspect.
@@ -841,8 +813,7 @@ def get_default_args(func):
841
813
 
842
814
 
843
815
  def get_ubuntu_version():
844
- """
845
- Retrieve the Ubuntu version if the OS is Ubuntu.
816
+ """Retrieve the Ubuntu version if the OS is Ubuntu.
846
817
 
847
818
  Returns:
848
819
  (str): Ubuntu version or None if not an Ubuntu OS.
@@ -856,8 +827,7 @@ def get_ubuntu_version():
856
827
 
857
828
 
858
829
  def get_user_config_dir(sub_dir="Ultralytics"):
859
- """
860
- Return a writable config dir, preferring YOLO_CONFIG_DIR and being OS-aware.
830
+ """Return a writable config dir, preferring YOLO_CONFIG_DIR and being OS-aware.
861
831
 
862
832
  Args:
863
833
  sub_dir (str): The name of the subdirectory to create.
@@ -915,8 +885,7 @@ SETTINGS_FILE = USER_CONFIG_DIR / "settings.json"
915
885
 
916
886
 
917
887
  def colorstr(*input):
918
- r"""
919
- Color a string based on the provided color and style arguments using ANSI escape codes.
888
+ r"""Color a string based on the provided color and style arguments using ANSI escape codes.
920
889
 
921
890
  This function can be called in two ways:
922
891
  - colorstr('color', 'style', 'your string')
@@ -925,12 +894,16 @@ def colorstr(*input):
925
894
  In the second form, 'blue' and 'bold' will be applied by default.
926
895
 
927
896
  Args:
928
- *input (str | Path): A sequence of strings where the first n-1 strings are color and style arguments,
929
- and the last string is the one to be colored.
897
+ *input (str | Path): A sequence of strings where the first n-1 strings are color and style arguments, and the
898
+ last string is the one to be colored.
930
899
 
931
900
  Returns:
932
901
  (str): The input string wrapped with ANSI escape codes for the specified color and style.
933
902
 
903
+ Examples:
904
+ >>> colorstr("blue", "bold", "hello world")
905
+ >>> "\033[34m\033[1mhello world\033[0m"
906
+
934
907
  Notes:
935
908
  Supported Colors and Styles:
936
909
  - Basic Colors: 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'
@@ -938,10 +911,6 @@ def colorstr(*input):
938
911
  'bright_blue', 'bright_magenta', 'bright_cyan', 'bright_white'
939
912
  - Misc: 'end', 'bold', 'underline'
940
913
 
941
- Examples:
942
- >>> colorstr("blue", "bold", "hello world")
943
- >>> "\033[34m\033[1mhello world\033[0m"
944
-
945
914
  References:
946
915
  https://en.wikipedia.org/wiki/ANSI_escape_code
947
916
  """
@@ -971,8 +940,7 @@ def colorstr(*input):
971
940
 
972
941
 
973
942
  def remove_colorstr(input_string):
974
- """
975
- Remove ANSI escape codes from a string, effectively un-coloring it.
943
+ """Remove ANSI escape codes from a string, effectively un-coloring it.
976
944
 
977
945
  Args:
978
946
  input_string (str): The string to remove color and style from.
@@ -989,8 +957,7 @@ def remove_colorstr(input_string):
989
957
 
990
958
 
991
959
  class TryExcept(contextlib.ContextDecorator):
992
- """
993
- Ultralytics TryExcept class for handling exceptions gracefully.
960
+ """Ultralytics TryExcept class for handling exceptions gracefully.
994
961
 
995
962
  This class can be used as a decorator or context manager to catch exceptions and optionally print warning messages.
996
963
  It allows code to continue execution even when exceptions occur, which is useful for non-critical operations.
@@ -1029,12 +996,11 @@ class TryExcept(contextlib.ContextDecorator):
1029
996
 
1030
997
 
1031
998
  class Retry(contextlib.ContextDecorator):
1032
- """
1033
- Retry class for function execution with exponential backoff.
999
+ """Retry class for function execution with exponential backoff.
1034
1000
 
1035
1001
  This decorator can be used to retry a function on exceptions, up to a specified number of times with an
1036
- exponentially increasing delay between retries. It's useful for handling transient failures in network
1037
- operations or other unreliable processes.
1002
+ exponentially increasing delay between retries. It's useful for handling transient failures in network operations or
1003
+ other unreliable processes.
1038
1004
 
1039
1005
  Attributes:
1040
1006
  times (int): Maximum number of retry attempts.
@@ -1074,12 +1040,11 @@ class Retry(contextlib.ContextDecorator):
1074
1040
 
1075
1041
 
1076
1042
  def threaded(func):
1077
- """
1078
- Multi-thread a target function by default and return the thread or function result.
1043
+ """Multi-thread a target function by default and return the thread or function result.
1079
1044
 
1080
- This decorator provides flexible execution of the target function, either in a separate thread or synchronously.
1081
- By default, the function runs in a thread, but this can be controlled via the 'threaded=False' keyword argument
1082
- which is removed from kwargs before calling the function.
1045
+ This decorator provides flexible execution of the target function, either in a separate thread or synchronously. By
1046
+ default, the function runs in a thread, but this can be controlled via the 'threaded=False' keyword argument which
1047
+ is removed from kwargs before calling the function.
1083
1048
 
1084
1049
  Args:
1085
1050
  func (callable): The function to be potentially executed in a separate thread.
@@ -1109,8 +1074,7 @@ def threaded(func):
1109
1074
 
1110
1075
 
1111
1076
  def set_sentry():
1112
- """
1113
- Initialize the Sentry SDK for error tracking and reporting.
1077
+ """Initialize the Sentry SDK for error tracking and reporting.
1114
1078
 
1115
1079
  Only used if sentry_sdk package is installed and sync=True in settings. Run 'yolo settings' to see and update
1116
1080
  settings.
@@ -1142,8 +1106,7 @@ def set_sentry():
1142
1106
  return
1143
1107
 
1144
1108
  def before_send(event, hint):
1145
- """
1146
- Modify the event before sending it to Sentry based on specific exception types and messages.
1109
+ """Modify the event before sending it to Sentry based on specific exception types and messages.
1147
1110
 
1148
1111
  Args:
1149
1112
  event (dict): The event dictionary containing information about the error.
@@ -1179,8 +1142,7 @@ def set_sentry():
1179
1142
 
1180
1143
 
1181
1144
  class JSONDict(dict):
1182
- """
1183
- A dictionary-like class that provides JSON persistence for its contents.
1145
+ """A dictionary-like class that provides JSON persistence for its contents.
1184
1146
 
1185
1147
  This class extends the built-in dictionary to automatically save its contents to a JSON file whenever they are
1186
1148
  modified. It ensures thread-safe operations using a lock and handles JSON serialization of Path objects.
@@ -1272,8 +1234,7 @@ class JSONDict(dict):
1272
1234
 
1273
1235
 
1274
1236
  class SettingsManager(JSONDict):
1275
- """
1276
- SettingsManager class for managing and persisting Ultralytics settings.
1237
+ """SettingsManager class for managing and persisting Ultralytics settings.
1277
1238
 
1278
1239
  This class extends JSONDict to provide JSON persistence for settings, ensuring thread-safe operations and default
1279
1240
  values. It validates settings on initialization and provides methods to update or reset settings. The settings
@@ -20,8 +20,7 @@ def check_train_batch_size(
20
20
  batch: int | float = -1,
21
21
  max_num_obj: int = 1,
22
22
  ) -> int:
23
- """
24
- Compute optimal YOLO training batch size using the autobatch() function.
23
+ """Compute optimal YOLO training batch size using the autobatch() function.
25
24
 
26
25
  Args:
27
26
  model (torch.nn.Module): YOLO model to check batch size for.
@@ -50,8 +49,7 @@ def autobatch(
50
49
  batch_size: int = DEFAULT_CFG.batch,
51
50
  max_num_obj: int = 1,
52
51
  ) -> int:
53
- """
54
- Automatically estimate the best YOLO batch size to use a fraction of the available CUDA memory.
52
+ """Automatically estimate the best YOLO batch size to use a fraction of the available CUDA memory.
55
53
 
56
54
  Args:
57
55
  model (torch.nn.Module): YOLO model to compute batch size for.
@@ -9,24 +9,23 @@ from ultralytics.utils.checks import check_requirements
9
9
 
10
10
 
11
11
  class GPUInfo:
12
- """
13
- Manages NVIDIA GPU information via pynvml with robust error handling.
12
+ """Manages NVIDIA GPU information via pynvml with robust error handling.
14
13
 
15
- Provides methods to query detailed GPU statistics (utilization, memory, temp, power) and select the most idle
16
- GPUs based on configurable criteria. It safely handles the absence or initialization failure of the pynvml
17
- library by logging warnings and disabling related features, preventing application crashes.
14
+ Provides methods to query detailed GPU statistics (utilization, memory, temp, power) and select the most idle GPUs
15
+ based on configurable criteria. It safely handles the absence or initialization failure of the pynvml library by
16
+ logging warnings and disabling related features, preventing application crashes.
18
17
 
19
18
  Includes fallback logic using `torch.cuda` for basic device counting if NVML is unavailable during GPU
20
19
  selection. Manages NVML initialization and shutdown internally.
21
20
 
22
21
  Attributes:
23
22
  pynvml (module | None): The `pynvml` module if successfully imported and initialized, otherwise `None`.
24
- nvml_available (bool): Indicates if `pynvml` is ready for use. True if import and `nvmlInit()` succeeded,
25
- False otherwise.
26
- gpu_stats (list[dict[str, Any]]): A list of dictionaries, each holding stats for one GPU. Populated on
27
- initialization and by `refresh_stats()`. Keys include: 'index', 'name', 'utilization' (%),
28
- 'memory_used' (MiB), 'memory_total' (MiB), 'memory_free' (MiB), 'temperature' (C), 'power_draw' (W),
29
- 'power_limit' (W or 'N/A'). Empty if NVML is unavailable or queries fail.
23
+ nvml_available (bool): Indicates if `pynvml` is ready for use. True if import and `nvmlInit()` succeeded, False
24
+ otherwise.
25
+ gpu_stats (list[dict[str, Any]]): A list of dictionaries, each holding stats for one GPU, populated on
26
+ initialization and by `refresh_stats()`. Keys include: 'index', 'name', 'utilization' (%), 'memory_used' (MiB),
27
+ 'memory_total' (MiB), 'memory_free' (MiB), 'temperature' (C), 'power_draw' (W), 'power_limit' (W or 'N/A').
28
+ Empty if NVML is unavailable or queries fail.
30
29
 
31
30
  Methods:
32
31
  refresh_stats: Refresh the internal gpu_stats list by querying NVML.
@@ -137,8 +136,7 @@ class GPUInfo:
137
136
  def select_idle_gpu(
138
137
  self, count: int = 1, min_memory_fraction: float = 0, min_util_fraction: float = 0
139
138
  ) -> list[int]:
140
- """
141
- Select the most idle GPUs based on utilization and free memory.
139
+ """Select the most idle GPUs based on utilization and free memory.
142
140
 
143
141
  Args:
144
142
  count (int): The number of idle GPUs to select.