ultralytics 8.3.105__py3-none-any.whl → 8.3.107__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.105"
3
+ __version__ = "8.3.107"
4
4
 
5
5
  import os
6
6
 
@@ -55,7 +55,6 @@ TensorFlow.js:
55
55
  $ npm start
56
56
  """
57
57
 
58
- import gc
59
58
  import json
60
59
  import os
61
60
  import re
@@ -86,7 +85,7 @@ from ultralytics.utils import (
86
85
  LINUX,
87
86
  LOGGER,
88
87
  MACOS,
89
- PYTHON_VERSION,
88
+ MACOS_VERSION,
90
89
  RKNN_CHIPS,
91
90
  ROOT,
92
91
  WINDOWS,
@@ -104,6 +103,7 @@ from ultralytics.utils.checks import (
104
103
  is_sudo_available,
105
104
  )
106
105
  from ultralytics.utils.downloads import attempt_download_asset, get_github_assets, safe_download
106
+ from ultralytics.utils.export import export_engine, export_onnx
107
107
  from ultralytics.utils.files import file_size, spaces_in_path
108
108
  from ultralytics.utils.ops import Profile, nms_rotated, xywh2xyxy
109
109
  from ultralytics.utils.torch_utils import TORCH_1_13, get_latest_opset, select_device
@@ -578,16 +578,14 @@ class Exporter:
578
578
  check_requirements("onnxslim>=0.1.46") # Older versions has bug with OBB
579
579
 
580
580
  with arange_patch(self.args):
581
- torch.onnx.export(
581
+ export_onnx(
582
582
  NMSModel(self.model, self.args) if self.args.nms else self.model,
583
583
  self.im,
584
584
  f,
585
- verbose=False,
586
- opset_version=opset_version,
587
- do_constant_folding=True, # WARNING: DNN inference with torch>=1.12 may require do_constant_folding=False
585
+ opset=opset_version,
588
586
  input_names=["images"],
589
587
  output_names=output_names,
590
- dynamic_axes=dynamic or None,
588
+ dynamic=dynamic or None,
591
589
  )
592
590
 
593
591
  # Checks
@@ -615,7 +613,10 @@ class Exporter:
615
613
  @try_export
616
614
  def export_openvino(self, prefix=colorstr("OpenVINO:")):
617
615
  """YOLO OpenVINO export."""
618
- check_requirements("openvino>=2024.0.0,!=2025.0.0")
616
+ if MACOS:
617
+ msg = "OpenVINO error in macOS>=15.4 https://github.com/openvinotoolkit/openvino/issues/30023"
618
+ check_version(MACOS_VERSION, "<15.4", name="macOS ", hard=True, msg=msg)
619
+ check_requirements("openvino>=2024.0.0")
619
620
  import openvino as ov
620
621
 
621
622
  LOGGER.info(f"\n{prefix} starting export with openvino {ov.__version__}...")
@@ -795,7 +796,7 @@ class Exporter:
795
796
  def export_coreml(self, prefix=colorstr("CoreML:")):
796
797
  """YOLO CoreML export."""
797
798
  mlmodel = self.args.format.lower() == "mlmodel" # legacy *.mlmodel export format requested
798
- check_requirements("coremltools>=6.0,<=6.2" if mlmodel else "coremltools>=8.0")
799
+ check_requirements("coremltools>=8.0")
799
800
  import coremltools as ct # noqa
800
801
 
801
802
  LOGGER.info(f"\n{prefix} starting export with coremltools {ct.__version__}...")
@@ -819,11 +820,15 @@ class Exporter:
819
820
  # TODO CoreML Segment and Pose model pipelining
820
821
  model = self.model
821
822
  ts = torch.jit.trace(model.eval(), self.im, strict=False) # TorchScript model
823
+
824
+ # Based on apple's documentation it is better to leave out the minimum_deployment target and let that get set
825
+ # Internally based on the model conversion and output type.
826
+ # Setting minimum_depoloyment_target >= iOS16 will require setting compute_precision=ct.precision.FLOAT32.
827
+ # iOS16 adds in better support for FP16, but none of the CoreML NMS specifications handle FP16 as input.
822
828
  ct_model = ct.convert(
823
829
  ts,
824
830
  inputs=[ct.ImageType("image", shape=self.im.shape, scale=scale, bias=bias)], # expects ct.TensorType
825
831
  classifier_config=classifier_config,
826
- minimum_deployment_target=ct.target.iOS15, # warning: >=16 causes pipeline errors
827
832
  convert_to="neuralnetwork" if mlmodel else "mlprogram",
828
833
  )
829
834
  bits, mode = (8, "kmeans") if self.args.int8 else (16, "linear") if self.args.half else (32, None)
@@ -840,8 +845,6 @@ class Exporter:
840
845
  ct_model = cto.palettize_weights(ct_model, config=config)
841
846
  if self.args.nms and self.model.task == "detect":
842
847
  if mlmodel:
843
- # coremltools<=6.2 NMS export requires Python<3.11
844
- check_version(PYTHON_VERSION, "<3.11", name="Python ", hard=True)
845
848
  weights_dir = None
846
849
  else:
847
850
  ct_model.save(str(f)) # save otherwise weights_dir does not exist
@@ -882,134 +885,22 @@ class Exporter:
882
885
 
883
886
  # Setup and checks
884
887
  LOGGER.info(f"\n{prefix} starting export with TensorRT {trt.__version__}...")
885
- is_trt10 = int(trt.__version__.split(".")[0]) >= 10 # is TensorRT >= 10
886
888
  assert Path(f_onnx).exists(), f"failed to export ONNX file: {f_onnx}"
887
889
  f = self.file.with_suffix(".engine") # TensorRT engine file
888
- logger = trt.Logger(trt.Logger.INFO)
889
- if self.args.verbose:
890
- logger.min_severity = trt.Logger.Severity.VERBOSE
891
-
892
- # Engine builder
893
- builder = trt.Builder(logger)
894
- config = builder.create_builder_config()
895
- workspace = int((self.args.workspace or 0) * (1 << 30))
896
- if is_trt10 and workspace > 0:
897
- config.set_memory_pool_limit(trt.MemoryPoolType.WORKSPACE, workspace)
898
- elif workspace > 0: # TensorRT versions 7, 8
899
- config.max_workspace_size = workspace
900
- flag = 1 << int(trt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH)
901
- network = builder.create_network(flag)
902
- half = builder.platform_has_fast_fp16 and self.args.half
903
- int8 = builder.platform_has_fast_int8 and self.args.int8
904
-
905
- # Optionally switch to DLA if enabled
906
- if dla is not None:
907
- if not IS_JETSON:
908
- raise ValueError("DLA is only available on NVIDIA Jetson devices")
909
- LOGGER.info(f"{prefix} enabling DLA on core {dla}...")
910
- if not self.args.half and not self.args.int8:
911
- raise ValueError(
912
- "DLA requires either 'half=True' (FP16) or 'int8=True' (INT8) to be enabled. Please enable one of them and try again."
913
- )
914
- config.default_device_type = trt.DeviceType.DLA
915
- config.DLA_core = int(dla)
916
- config.set_flag(trt.BuilderFlag.GPU_FALLBACK)
917
-
918
- # Read ONNX file
919
- parser = trt.OnnxParser(network, logger)
920
- if not parser.parse_from_file(f_onnx):
921
- raise RuntimeError(f"failed to load ONNX file: {f_onnx}")
922
-
923
- # Network inputs
924
- inputs = [network.get_input(i) for i in range(network.num_inputs)]
925
- outputs = [network.get_output(i) for i in range(network.num_outputs)]
926
- for inp in inputs:
927
- LOGGER.info(f'{prefix} input "{inp.name}" with shape{inp.shape} {inp.dtype}')
928
- for out in outputs:
929
- LOGGER.info(f'{prefix} output "{out.name}" with shape{out.shape} {out.dtype}')
930
-
931
- if self.args.dynamic:
932
- shape = self.im.shape
933
- if shape[0] <= 1:
934
- LOGGER.warning(f"{prefix} WARNING ⚠️ 'dynamic=True' model requires max batch size, i.e. 'batch=16'")
935
- profile = builder.create_optimization_profile()
936
- min_shape = (1, shape[1], 32, 32) # minimum input shape
937
- max_shape = (*shape[:2], *(int(max(1, self.args.workspace or 1) * d) for d in shape[2:])) # max input shape
938
- for inp in inputs:
939
- profile.set_shape(inp.name, min=min_shape, opt=shape, max=max_shape)
940
- config.add_optimization_profile(profile)
941
-
942
- LOGGER.info(f"{prefix} building {'INT8' if int8 else 'FP' + ('16' if half else '32')} engine as {f}")
943
- if int8:
944
- config.set_flag(trt.BuilderFlag.INT8)
945
- config.set_calibration_profile(profile)
946
- config.profiling_verbosity = trt.ProfilingVerbosity.DETAILED
947
-
948
- class EngineCalibrator(trt.IInt8Calibrator):
949
- def __init__(
950
- self,
951
- dataset, # ultralytics.data.build.InfiniteDataLoader
952
- batch: int,
953
- cache: str = "",
954
- ) -> None:
955
- trt.IInt8Calibrator.__init__(self)
956
- self.dataset = dataset
957
- self.data_iter = iter(dataset)
958
- self.algo = trt.CalibrationAlgoType.ENTROPY_CALIBRATION_2
959
- self.batch = batch
960
- self.cache = Path(cache)
961
-
962
- def get_algorithm(self) -> trt.CalibrationAlgoType:
963
- """Get the calibration algorithm to use."""
964
- return self.algo
965
-
966
- def get_batch_size(self) -> int:
967
- """Get the batch size to use for calibration."""
968
- return self.batch or 1
969
-
970
- def get_batch(self, names) -> list:
971
- """Get the next batch to use for calibration, as a list of device memory pointers."""
972
- try:
973
- im0s = next(self.data_iter)["img"] / 255.0
974
- im0s = im0s.to("cuda") if im0s.device.type == "cpu" else im0s
975
- return [int(im0s.data_ptr())]
976
- except StopIteration:
977
- # Return [] or None, signal to TensorRT there is no calibration data remaining
978
- return None
979
-
980
- def read_calibration_cache(self) -> bytes:
981
- """Use existing cache instead of calibrating again, otherwise, implicitly return None."""
982
- if self.cache.exists() and self.cache.suffix == ".cache":
983
- return self.cache.read_bytes()
984
-
985
- def write_calibration_cache(self, cache) -> None:
986
- """Write calibration cache to disk."""
987
- _ = self.cache.write_bytes(cache)
988
-
989
- # Load dataset w/ builder (for batching) and calibrate
990
- config.int8_calibrator = EngineCalibrator(
991
- dataset=self.get_int8_calibration_dataloader(prefix),
992
- batch=2 * self.args.batch, # TensorRT INT8 calibration should use 2x batch size
993
- cache=str(self.file.with_suffix(".cache")),
994
- )
995
-
996
- elif half:
997
- config.set_flag(trt.BuilderFlag.FP16)
998
-
999
- # Free CUDA memory
1000
- del self.model
1001
- gc.collect()
1002
- torch.cuda.empty_cache()
1003
-
1004
- # Write file
1005
- build = builder.build_serialized_network if is_trt10 else builder.build_engine
1006
- with build(network, config) as engine, open(f, "wb") as t:
1007
- # Metadata
1008
- meta = json.dumps(self.metadata)
1009
- t.write(len(meta).to_bytes(4, byteorder="little", signed=True))
1010
- t.write(meta.encode())
1011
- # Model
1012
- t.write(engine if is_trt10 else engine.serialize())
890
+ export_engine(
891
+ f_onnx,
892
+ f,
893
+ self.args.workspace,
894
+ self.args.half,
895
+ self.args.int8,
896
+ self.args.dynamic,
897
+ self.im.shape,
898
+ dla=dla,
899
+ dataset=self.get_int8_calibration_dataloader(prefix) if self.args.int8 else None,
900
+ metadata=self.metadata,
901
+ verbose=self.args.verbose,
902
+ prefix=prefix,
903
+ )
1013
904
 
1014
905
  return f, None
1015
906
 
@@ -1469,7 +1360,7 @@ class Exporter:
1469
1360
 
1470
1361
  # 3. Create NMS protobuf
1471
1362
  nms_spec = ct.proto.Model_pb2.Model()
1472
- nms_spec.specificationVersion = 9
1363
+ nms_spec.specificationVersion = spec.specificationVersion
1473
1364
  for i in range(2):
1474
1365
  decoder_output = model._spec.description.output[i].SerializeToString()
1475
1366
  nms_spec.description.input.add()
@@ -1522,7 +1413,7 @@ class Exporter:
1522
1413
  pipeline.spec.description.output[1].ParseFromString(nms_model._spec.description.output[1].SerializeToString())
1523
1414
 
1524
1415
  # Update metadata
1525
- pipeline.spec.specificationVersion = 9
1416
+ pipeline.spec.specificationVersion = spec.specificationVersion
1526
1417
  pipeline.spec.description.metadata.userDefined.update(
1527
1418
  {"IoU threshold": str(nms.iouThreshold), "Confidence threshold": str(nms.confidenceThreshold)}
1528
1419
  )
@@ -258,7 +258,7 @@ class AutoBackend(nn.Module):
258
258
  # OpenVINO
259
259
  elif xml:
260
260
  LOGGER.info(f"Loading {w} for OpenVINO inference...")
261
- check_requirements("openvino>=2024.0.0,!=2025.0.0")
261
+ check_requirements("openvino>=2024.0.0")
262
262
  import openvino as ov
263
263
 
264
264
  core = ov.Core()
@@ -511,9 +511,9 @@ class AutoBackend(nn.Module):
511
511
  if not w.is_file(): # if not *.rknn
512
512
  w = next(w.rglob("*.rknn")) # get *.rknn file from *_rknn_model dir
513
513
  rknn_model = RKNNLite()
514
- rknn_model.load_rknn(w)
514
+ rknn_model.load_rknn(str(w))
515
515
  rknn_model.init_runtime()
516
- metadata = Path(w).parent / "metadata.yaml"
516
+ metadata = w.parent / "metadata.yaml"
517
517
 
518
518
  # Any other format (unsupported)
519
519
  else:
@@ -48,6 +48,7 @@ VERBOSE = str(os.getenv("YOLO_VERBOSE", True)).lower() == "true" # global verbo
48
48
  TQDM_BAR_FORMAT = "{l_bar}{bar:10}{r_bar}" if VERBOSE else None # tqdm bar format
49
49
  LOGGING_NAME = "ultralytics"
50
50
  MACOS, LINUX, WINDOWS = (platform.system() == x for x in ["Darwin", "Linux", "Windows"]) # environment booleans
51
+ MACOS_VERSION = platform.mac_ver()[0] if MACOS else None
51
52
  ARM64 = platform.machine() in {"arm64", "aarch64"} # ARM64 booleans
52
53
  PYTHON_VERSION = platform.python_version()
53
54
  TORCH_VERSION = torch.__version__
@@ -0,0 +1,217 @@
1
+ import json
2
+ from pathlib import Path
3
+
4
+ import torch
5
+
6
+ from ultralytics.utils import IS_JETSON, LOGGER
7
+
8
+
9
+ def export_onnx(
10
+ torch_model,
11
+ im,
12
+ onnx_file,
13
+ opset=14,
14
+ input_names=["images"],
15
+ output_names=["output0"],
16
+ dynamic=False,
17
+ ):
18
+ """
19
+ Exports a PyTorch model to ONNX format.
20
+
21
+ Args:
22
+ torch_model (torch.nn.Module): The PyTorch model to export.
23
+ im (torch.Tensor): Example input tensor for the model.
24
+ onnx_file (str): Path to save the exported ONNX file.
25
+ opset (int): ONNX opset version to use for export.
26
+ input_names (list): List of input tensor names.
27
+ output_names (list): List of output tensor names.
28
+ dynamic (bool | dict, optional): Whether to enable dynamic axes. Defaults to False.
29
+
30
+ Notes:
31
+ - Setting `do_constant_folding=True` may cause issues with DNN inference for torch>=1.12.
32
+ """
33
+ torch.onnx.export(
34
+ torch_model,
35
+ im,
36
+ onnx_file,
37
+ verbose=False,
38
+ opset_version=opset,
39
+ do_constant_folding=True, # WARNING: DNN inference with torch>=1.12 may require do_constant_folding=False
40
+ input_names=input_names,
41
+ output_names=output_names,
42
+ dynamic_axes=dynamic or None,
43
+ )
44
+
45
+
46
+ def export_engine(
47
+ onnx_file,
48
+ engine_file=None,
49
+ workspace=None,
50
+ half=False,
51
+ int8=False,
52
+ dynamic=False,
53
+ shape=(1, 3, 640, 640),
54
+ dla=None,
55
+ dataset=None,
56
+ metadata=None,
57
+ verbose=False,
58
+ prefix="",
59
+ ):
60
+ """
61
+ Exports a YOLO model to TensorRT engine format.
62
+
63
+ Args:
64
+ onnx_file (str): Path to the ONNX file to be converted.
65
+ engine_file (str, optional): Path to save the generated TensorRT engine file.
66
+ workspace (int, optional): Workspace size in GB for TensorRT. Defaults to None.
67
+ half (bool, optional): Enable FP16 precision. Defaults to False.
68
+ int8 (bool, optional): Enable INT8 precision. Defaults to False.
69
+ dynamic (bool, optional): Enable dynamic input shapes. Defaults to False.
70
+ shape (tuple, optional): Input shape (batch, channels, height, width). Defaults to (1, 3, 640, 640).
71
+ dla (int, optional): DLA core to use (Jetson devices only). Defaults to None.
72
+ dataset (ultralytics.data.build.InfiniteDataLoader, optional): Dataset for INT8 calibration. Defaults to None.
73
+ metadata (dict, optional): Metadata to include in the engine file. Defaults to None.
74
+ verbose (bool, optional): Enable verbose logging. Defaults to False.
75
+ prefix (str, optional): Prefix for log messages. Defaults to "".
76
+
77
+ Raises:
78
+ ValueError: If DLA is enabled on non-Jetson devices or required precision is not set.
79
+ RuntimeError: If the ONNX file cannot be parsed.
80
+
81
+ Notes:
82
+ - TensorRT version compatibility is handled for workspace size and engine building.
83
+ - INT8 calibration requires a dataset and generates a calibration cache.
84
+ - Metadata is serialized and written to the engine file if provided.
85
+ """
86
+ import tensorrt as trt # noqa
87
+
88
+ engine_file = engine_file or Path(onnx_file).with_suffix(".engine")
89
+
90
+ logger = trt.Logger(trt.Logger.INFO)
91
+ if verbose:
92
+ logger.min_severity = trt.Logger.Severity.VERBOSE
93
+
94
+ # Engine builder
95
+ builder = trt.Builder(logger)
96
+ config = builder.create_builder_config()
97
+ workspace = int((workspace or 0) * (1 << 30))
98
+ is_trt10 = int(trt.__version__.split(".")[0]) >= 10 # is TensorRT >= 10
99
+ if is_trt10 and workspace > 0:
100
+ config.set_memory_pool_limit(trt.MemoryPoolType.WORKSPACE, workspace)
101
+ elif workspace > 0: # TensorRT versions 7, 8
102
+ config.max_workspace_size = workspace
103
+ flag = 1 << int(trt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH)
104
+ network = builder.create_network(flag)
105
+ half = builder.platform_has_fast_fp16 and half
106
+ int8 = builder.platform_has_fast_int8 and int8
107
+
108
+ # Optionally switch to DLA if enabled
109
+ if dla is not None:
110
+ if not IS_JETSON:
111
+ raise ValueError("DLA is only available on NVIDIA Jetson devices")
112
+ LOGGER.info(f"{prefix} enabling DLA on core {dla}...")
113
+ if not half and not int8:
114
+ raise ValueError(
115
+ "DLA requires either 'half=True' (FP16) or 'int8=True' (INT8) to be enabled. Please enable one of them and try again."
116
+ )
117
+ config.default_device_type = trt.DeviceType.DLA
118
+ config.DLA_core = int(dla)
119
+ config.set_flag(trt.BuilderFlag.GPU_FALLBACK)
120
+
121
+ # Read ONNX file
122
+ parser = trt.OnnxParser(network, logger)
123
+ if not parser.parse_from_file(onnx_file):
124
+ raise RuntimeError(f"failed to load ONNX file: {onnx_file}")
125
+
126
+ # Network inputs
127
+ inputs = [network.get_input(i) for i in range(network.num_inputs)]
128
+ outputs = [network.get_output(i) for i in range(network.num_outputs)]
129
+ for inp in inputs:
130
+ LOGGER.info(f'{prefix} input "{inp.name}" with shape{inp.shape} {inp.dtype}')
131
+ for out in outputs:
132
+ LOGGER.info(f'{prefix} output "{out.name}" with shape{out.shape} {out.dtype}')
133
+
134
+ if dynamic:
135
+ if shape[0] <= 1:
136
+ LOGGER.warning(f"{prefix} WARNING ⚠️ 'dynamic=True' model requires max batch size, i.e. 'batch=16'")
137
+ profile = builder.create_optimization_profile()
138
+ min_shape = (1, shape[1], 32, 32) # minimum input shape
139
+ max_shape = (*shape[:2], *(int(max(1, workspace or 1) * d) for d in shape[2:])) # max input shape
140
+ for inp in inputs:
141
+ profile.set_shape(inp.name, min=min_shape, opt=shape, max=max_shape)
142
+ config.add_optimization_profile(profile)
143
+
144
+ LOGGER.info(f"{prefix} building {'INT8' if int8 else 'FP' + ('16' if half else '32')} engine as {engine_file}")
145
+ if int8:
146
+ config.set_flag(trt.BuilderFlag.INT8)
147
+ config.set_calibration_profile(profile)
148
+ config.profiling_verbosity = trt.ProfilingVerbosity.DETAILED
149
+
150
+ class EngineCalibrator(trt.IInt8Calibrator):
151
+ """
152
+ Custom INT8 calibrator for TensorRT.
153
+
154
+ Args:
155
+ dataset (object): Dataset for calibration.
156
+ batch (int): Batch size for calibration.
157
+ cache (str, optional): Path to save the calibration cache. Defaults to "".
158
+ """
159
+
160
+ def __init__(
161
+ self,
162
+ dataset, # ultralytics.data.build.InfiniteDataLoader
163
+ cache: str = "",
164
+ ) -> None:
165
+ trt.IInt8Calibrator.__init__(self)
166
+ self.dataset = dataset
167
+ self.data_iter = iter(dataset)
168
+ self.algo = trt.CalibrationAlgoType.ENTROPY_CALIBRATION_2
169
+ self.batch = dataset.batch_size
170
+ self.cache = Path(cache)
171
+
172
+ def get_algorithm(self) -> trt.CalibrationAlgoType:
173
+ """Get the calibration algorithm to use."""
174
+ return self.algo
175
+
176
+ def get_batch_size(self) -> int:
177
+ """Get the batch size to use for calibration."""
178
+ return self.batch or 1
179
+
180
+ def get_batch(self, names) -> list:
181
+ """Get the next batch to use for calibration, as a list of device memory pointers."""
182
+ try:
183
+ im0s = next(self.data_iter)["img"] / 255.0
184
+ im0s = im0s.to("cuda") if im0s.device.type == "cpu" else im0s
185
+ return [int(im0s.data_ptr())]
186
+ except StopIteration:
187
+ # Return [] or None, signal to TensorRT there is no calibration data remaining
188
+ return None
189
+
190
+ def read_calibration_cache(self) -> bytes:
191
+ """Use existing cache instead of calibrating again, otherwise, implicitly return None."""
192
+ if self.cache.exists() and self.cache.suffix == ".cache":
193
+ return self.cache.read_bytes()
194
+
195
+ def write_calibration_cache(self, cache) -> None:
196
+ """Write calibration cache to disk."""
197
+ _ = self.cache.write_bytes(cache)
198
+
199
+ # Load dataset w/ builder (for batching) and calibrate
200
+ config.int8_calibrator = EngineCalibrator(
201
+ dataset=dataset,
202
+ cache=str(Path(onnx_file).with_suffix(".cache")),
203
+ )
204
+
205
+ elif half:
206
+ config.set_flag(trt.BuilderFlag.FP16)
207
+
208
+ # Write file
209
+ build = builder.build_serialized_network if is_trt10 else builder.build_engine
210
+ with build(network, config) as engine, open(engine_file, "wb") as t:
211
+ # Metadata
212
+ if metadata is not None:
213
+ meta = json.dumps(metadata)
214
+ t.write(len(meta).to_bytes(4, byteorder="little", signed=True))
215
+ t.write(meta.encode())
216
+ # Model
217
+ t.write(engine if is_trt10 else engine.serialize())
@@ -260,7 +260,11 @@ def fuse_conv_and_bn(conv, bn):
260
260
  fusedconv.weight.copy_(torch.mm(w_bn, w_conv).view(fusedconv.weight.shape))
261
261
 
262
262
  # Prepare spatial bias
263
- b_conv = torch.zeros(conv.weight.shape[0], device=conv.weight.device) if conv.bias is None else conv.bias
263
+ b_conv = (
264
+ torch.zeros(conv.weight.shape[0], dtype=conv.weight.dtype, device=conv.weight.device)
265
+ if conv.bias is None
266
+ else conv.bias
267
+ )
264
268
  b_bn = bn.bias - bn.weight.mul(bn.running_mean).div(torch.sqrt(bn.running_var + bn.eps))
265
269
  fusedconv.bias.copy_(torch.mm(w_bn, b_conv.reshape(-1, 1)).reshape(-1) + b_bn)
266
270
 
@@ -137,7 +137,12 @@ def run_ray_tune(
137
137
  tuner = tune.Tuner(
138
138
  trainable_with_resources,
139
139
  param_space=space,
140
- tune_config=tune.TuneConfig(scheduler=asha_scheduler, num_samples=max_samples),
140
+ tune_config=tune.TuneConfig(
141
+ scheduler=asha_scheduler,
142
+ num_samples=max_samples,
143
+ trial_name_creator=lambda trial: f"{trial.trainable_name}_{trial.trial_id}",
144
+ trial_dirname_creator=lambda trial: f"{trial.trainable_name}_{trial.trial_id}",
145
+ ),
141
146
  run_config=RunConfig(callbacks=tuner_callbacks, storage_path=tune_dir.parent, name=tune_dir.name),
142
147
  )
143
148
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ultralytics
3
- Version: 8.3.105
3
+ Version: 8.3.107
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>
@@ -62,7 +62,7 @@ Provides-Extra: export
62
62
  Requires-Dist: onnx>=1.12.0; extra == "export"
63
63
  Requires-Dist: coremltools>=8.0; (platform_system != "Windows" and python_version <= "3.12") and extra == "export"
64
64
  Requires-Dist: scikit-learn>=1.3.2; (platform_system != "Windows" and python_version <= "3.12") and extra == "export"
65
- Requires-Dist: openvino!=2025.0.0,>=2024.0.0; extra == "export"
65
+ Requires-Dist: openvino>=2024.0.0; extra == "export"
66
66
  Requires-Dist: tensorflow>=2.0.0; extra == "export"
67
67
  Requires-Dist: tensorflowjs>=4.0.0; extra == "export"
68
68
  Requires-Dist: tensorstore>=0.1.63; (platform_machine == "aarch64" and python_version >= "3.9") and extra == "export"
@@ -1,13 +1,4 @@
1
- tests/__init__.py,sha256=xnMhv3O_DF1YrW4zk__ZywQzAaoTDjPKPoiI1Ktss1w,670
2
- tests/conftest.py,sha256=rsIAipRKfrVNoTaJ1LdpYue8AbcJ_fr3d3WIlM_6uXY,2982
3
- tests/test_cli.py,sha256=DPxUjcGAex_cmGMNaRIK7mT7wrILWaPBtlfXuHQpveI,5284
4
- tests/test_cuda.py,sha256=0uvTF4bY_Grsd_Xgtp7TdIEgMpUqKv8_kWA82NYDl_g,6260
5
- tests/test_engine.py,sha256=aGqZ8P7QO5C_nOa1b4FOyk92Ysdk5WiP-ST310Vyxys,4962
6
- tests/test_exports.py,sha256=dhZn86LdbapW15RthQF870LGxDjC1MUZhlGdBgPmgIQ,9716
7
- tests/test_integrations.py,sha256=ZgpddWHEVqiP4bGhVw8fLc2wdz0rCxuxr0FQ2dTgnIE,6067
8
- tests/test_python.py,sha256=ij0MV87WtbY2WVs0uP41GdVxt_p_M5Rrkldna3M5nXY,24620
9
- tests/test_solutions.py,sha256=428CUFC-ns0GDRZWt_er1Ma8Kb1jtDgSj3cw3T2HjWE,5530
10
- ultralytics/__init__.py,sha256=70uClMXEl0zWqRYtxBGmqsXSqZT6XKCKR-m47cxzkGA,730
1
+ ultralytics/__init__.py,sha256=tIiMmD1lgop-6FXN0gw50mi9LmU73AZGjQSfh2uE0Aw,730
11
2
  ultralytics/assets/bus.jpg,sha256=wCAZxJecGR63Od3ZRERe9Aja1Weayrb9Ug751DS_vGM,137419
12
3
  ultralytics/assets/zidane.jpg,sha256=Ftc4aeMmen1O0A3o6GCDO9FlfBslLpTAw0gnetx7bts,50427
13
4
  ultralytics/cfg/__init__.py,sha256=UCUFiZg-bqJwpuLLaGgy7RvAMxD-nbcVsPLxSo8x3ZA,39821
@@ -111,7 +102,7 @@ ultralytics/data/loaders.py,sha256=_Gyp_BfGTZwsFdn4UnolXxdU_sAYZLIrv0L2TRI9R5g,2
111
102
  ultralytics/data/split_dota.py,sha256=p8eVGht9tABSVbf9vwvxA_AQYEva3IGHePKlMeNrn64,11872
112
103
  ultralytics/data/utils.py,sha256=aRPwIoLrCML_Kcd0dI9B6c5Ct4dvhdF36rDHtuf7Ww4,33217
113
104
  ultralytics/engine/__init__.py,sha256=lm6MckFYCPTbqIoX7w0s_daxdjNeBeKW6DXppv1-QUM,70
114
- ultralytics/engine/exporter.py,sha256=XJYeJYloVPkXyl7-kCzbYt6KqqZPpLz4-BgkUrQFlOc,78346
105
+ ultralytics/engine/exporter.py,sha256=G-It6VeXPxo7bxuLt8mEyXVx8uzjpooalJ1aSdI23VQ,72998
115
106
  ultralytics/engine/model.py,sha256=YgQKYZrPENSTvLENspg-bXI9FinzzWARfb0U-C9vH-M,52916
116
107
  ultralytics/engine/predictor.py,sha256=fRUh82EJlu_6ZlIy8NFovlCcgX53UbRYSXcLljOs7Sc,21669
117
108
  ultralytics/engine/results.py,sha256=H3pFJhUjYKvVyOUqqZjfIn8vnCpl81aYNOnregMrBoQ,79716
@@ -186,7 +177,7 @@ ultralytics/models/yolo/yoloe/train.py,sha256=7JxJkMN9bkUGsO-RojFG2Q3yfdKhb-TXlB
186
177
  ultralytics/models/yolo/yoloe/train_seg.py,sha256=JguKB1ez8Rf7XBu_D_mWHMLJto7y7Kr2m0Tq2NwDtwU,5269
187
178
  ultralytics/models/yolo/yoloe/val.py,sha256=utdt8wZvvW9OPxO5rx8KsFlkLG0FXj0YMD7Jhyk54D8,8440
188
179
  ultralytics/nn/__init__.py,sha256=rjociYD9lo_K-d-1s6TbdWklPLjTcEHk7OIlRDJstIE,615
189
- ultralytics/nn/autobackend.py,sha256=Y597hrrvhHlRX5SoOiXJZXj_1ND9kHMn94V2m_saRAU,38871
180
+ ultralytics/nn/autobackend.py,sha256=XaPuvhfCz8l1x_Zw3F4ZV9SfQ1EhAuXNE1xpcUc7jzY,38859
190
181
  ultralytics/nn/tasks.py,sha256=r9CoXW9owNK5UWH2ufM5cyG3DB5TEEIX-JmhTSECCN8,62991
191
182
  ultralytics/nn/text_model.py,sha256=H6OiLe0FOyZY4pd7-ixRTxaBgx3lOc2GmGTmrFnoJd0,10136
192
183
  ultralytics/nn/modules/__init__.py,sha256=dXLtIk9rt944WfsTdpgEdWOg3HQEHdwQztuZ6WNJygs,3144
@@ -223,13 +214,14 @@ ultralytics/trackers/utils/__init__.py,sha256=lm6MckFYCPTbqIoX7w0s_daxdjNeBeKW6D
223
214
  ultralytics/trackers/utils/gmc.py,sha256=NnLxtgZIKdO5-C_J0xqeob1iRXgpubyJOgbIEeJz0Ps,14500
224
215
  ultralytics/trackers/utils/kalman_filter.py,sha256=A0CqOnnaKH6kr0XwuHzyHmIU6aJAjJYxF9jVlNBKZHo,21326
225
216
  ultralytics/trackers/utils/matching.py,sha256=7eIufSdeN7cXuFMjvcfvz0Ldq84m4YKZl5IGxBR8IIo,7169
226
- ultralytics/utils/__init__.py,sha256=vkL5eXMA-1CvTJou5D16FkIdO_ANDwPUJPB4NovnMQw,50197
217
+ ultralytics/utils/__init__.py,sha256=-OY2ZAJdN7XLPSG1dpnWWv63ZqmhzAxrio2dMGXuyEg,50254
227
218
  ultralytics/utils/autobatch.py,sha256=KnvmNSAO_6H3ZLJ4fOFMTFbOaMlbp025LiJqrdKIz8c,4998
228
219
  ultralytics/utils/benchmarks.py,sha256=7xJ7I0XqLXE-51_OCETKdfMKpk1zUkMTq0kCbdMsMks,30359
229
220
  ultralytics/utils/checks.py,sha256=d30cJY1G3wBWWTlq3C3yGVmDhAUtfXa9U3nuTO4sXQo,32677
230
221
  ultralytics/utils/dist.py,sha256=M8svPWdrRDcSmqIBGrqIaV8yi98Z3HUhXwsauDjVlkM,4090
231
222
  ultralytics/utils/downloads.py,sha256=4P1JIc04tTd_oz3-AHlhRSGaVtnSQPg_gYlh__U27-4,22169
232
223
  ultralytics/utils/errors.py,sha256=vY9h2evFSrHnZdHJVVrmm8Zzw4qVDLyo9DeYW5g0dFk,1573
224
+ ultralytics/utils/export.py,sha256=yv2CL_CfG_f6hO8-WC6fgdWrSfBc_iCp5dQ3uI1O1YM,8761
233
225
  ultralytics/utils/files.py,sha256=0K4O1cgqRiXaDw7EQK13TqA5SME_RrvfDVQSPetNr5w,8042
234
226
  ultralytics/utils/instance.py,sha256=UOEsXR9V-bXNRk6BTonASBEgeMqvzzAk4S7VdXZJUAM,18090
235
227
  ultralytics/utils/loss.py,sha256=us3lwmSlIwEzoMztNjpet7Kb1r1-sMGyESykqgYPDVo,36945
@@ -238,9 +230,9 @@ ultralytics/utils/ops.py,sha256=Ag69Hvy8HxKLvewrtfQRseveboc_RGzlMYmO1B2U1Lk,3421
238
230
  ultralytics/utils/patches.py,sha256=auTWwYBieowiwH7ww1FgR67JSPkKr_7-PGA1SCYXB4A,4569
239
231
  ultralytics/utils/plotting.py,sha256=wAg_z9ik6Wi3XZCfKO2K6TWV1G0TcLEkjxxz2H42CX8,46703
240
232
  ultralytics/utils/tal.py,sha256=B-NV9qC3WIiKDcRWgJB2RN1r6aA0UUp0lL7RFwYhYK4,20814
241
- ultralytics/utils/torch_utils.py,sha256=7O0sJhISx3RzQI6uRtx2ZhJm-qNEYF359qXwQFL99pw,38894
233
+ ultralytics/utils/torch_utils.py,sha256=3sm0oG9rmLfCWUeeiuqxSwrTGk4AnWPidEoM4vaRmYM,38951
242
234
  ultralytics/utils/triton.py,sha256=xK9Db_ZUVDnIK1u76S2G-6ulIBsLfj9HN_YOaSrnMuU,5304
243
- ultralytics/utils/tuner.py,sha256=JBarTM7E8AC6ZLfRf8XCE5s_nwzEAp-dU4wM9MKDQ5k,6476
235
+ ultralytics/utils/tuner.py,sha256=eX238JDALFejbx-QMEQBLoNfXQvA7GzArqgVUa1l4nI,6712
244
236
  ultralytics/utils/callbacks/__init__.py,sha256=hzL63Rce6VkZhP4Lcim9LKjadixaQG86nKqPhk7IkS0,242
245
237
  ultralytics/utils/callbacks/base.py,sha256=p8YCeYDp4GLcyHWFZxC2Wxr2IXLw_MfIE5ef1fOQcWk,6848
246
238
  ultralytics/utils/callbacks/clearml.py,sha256=jxTL2QSt8Cjp_BkK2XUDPg5t2XnykMYXJFRp6B66ulA,6005
@@ -252,9 +244,9 @@ ultralytics/utils/callbacks/neptune.py,sha256=XXnnKQ-MoLIexl8y2Vb0i-cCLyePE0n5BU
252
244
  ultralytics/utils/callbacks/raytune.py,sha256=omVZNNuzYxsZZXrF9xpbFv7R1Wjdx1j-gv0xXuZrQas,1122
253
245
  ultralytics/utils/callbacks/tensorboard.py,sha256=7eUX21_Ym7i6iN4euZzrqglphyl5xak1yl_-wfFshbg,5502
254
246
  ultralytics/utils/callbacks/wb.py,sha256=iDRFXI4IIDm8R5OI89DMTmjs8aHLo1HRCLkOFKdaMG4,7507
255
- ultralytics-8.3.105.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
256
- ultralytics-8.3.105.dist-info/METADATA,sha256=HYewTGSUpFpPREiAy_L5PYIA00RbBfj5jbm7miunRc0,37355
257
- ultralytics-8.3.105.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
258
- ultralytics-8.3.105.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
259
- ultralytics-8.3.105.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
260
- ultralytics-8.3.105.dist-info/RECORD,,
247
+ ultralytics-8.3.107.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
248
+ ultralytics-8.3.107.dist-info/METADATA,sha256=7CYps8WGNYgKPtFPnDZip1QagdZFeHHPhTd0gp3uZ-s,37344
249
+ ultralytics-8.3.107.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
250
+ ultralytics-8.3.107.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
251
+ ultralytics-8.3.107.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
252
+ ultralytics-8.3.107.dist-info/RECORD,,
tests/__init__.py DELETED
@@ -1,22 +0,0 @@
1
- # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
-
3
- from ultralytics.utils import ASSETS, ROOT, WEIGHTS_DIR, checks
4
-
5
- # Constants used in tests
6
- MODEL = WEIGHTS_DIR / "path with spaces" / "yolo11n.pt" # test spaces in path
7
- CFG = "yolo11n.yaml"
8
- SOURCE = ASSETS / "bus.jpg"
9
- SOURCES_LIST = [ASSETS / "bus.jpg", ASSETS, ASSETS / "*", ASSETS / "**/*.jpg"]
10
- TMP = (ROOT / "../tests/tmp").resolve() # temp directory for test files
11
- CUDA_IS_AVAILABLE = checks.cuda_is_available()
12
- CUDA_DEVICE_COUNT = checks.cuda_device_count()
13
-
14
- __all__ = (
15
- "MODEL",
16
- "CFG",
17
- "SOURCE",
18
- "SOURCES_LIST",
19
- "TMP",
20
- "CUDA_IS_AVAILABLE",
21
- "CUDA_DEVICE_COUNT",
22
- )