ultralytics 8.3.208__py3-none-any.whl → 8.3.210__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.208"
3
+ __version__ = "8.3.210"
4
4
 
5
5
  import importlib
6
6
  import os
@@ -612,7 +612,7 @@ class Exporter:
612
612
  """Export YOLO model to ONNX format."""
613
613
  requirements = ["onnx>=1.12.0"]
614
614
  if self.args.simplify:
615
- requirements += ["onnxslim>=0.1.67", "onnxruntime" + ("-gpu" if torch.cuda.is_available() else "")]
615
+ requirements += ["onnxslim>=0.1.71", "onnxruntime" + ("-gpu" if torch.cuda.is_available() else "")]
616
616
  check_requirements(requirements)
617
617
  import onnx # noqa
618
618
 
@@ -1014,7 +1014,7 @@ class Exporter:
1014
1014
  "ai-edge-litert>=1.2.0" + (",<1.4.0" if MACOS else ""), # required by 'onnx2tf' package
1015
1015
  "onnx>=1.12.0",
1016
1016
  "onnx2tf>=1.26.3",
1017
- "onnxslim>=0.1.67",
1017
+ "onnxslim>=0.1.71",
1018
1018
  "onnxruntime-gpu" if cuda else "onnxruntime",
1019
1019
  "protobuf>=5",
1020
1020
  ),
@@ -1039,6 +1039,9 @@ class Exporter:
1039
1039
  attempt_download_asset(f"{onnx2tf_file}.zip", unzip=True, delete=True)
1040
1040
 
1041
1041
  # Export to ONNX
1042
+ if "rtdetr" in self.model.model[-1]._get_name().lower():
1043
+ self.args.opset = self.args.opset or 19
1044
+ assert 16 <= self.args.opset <= 19, "RTDETR export requires opset>=16;<=19"
1042
1045
  self.args.simplify = True
1043
1046
  f_onnx = self.export_onnx()
1044
1047
 
@@ -420,9 +420,10 @@ class BaseTrainer:
420
420
  self.loss = loss.sum()
421
421
  if RANK != -1:
422
422
  self.loss *= self.world_size
423
- self.tloss = (
424
- (self.tloss * i + self.loss_items) / (i + 1) if self.tloss is not None else self.loss_items
425
- )
423
+ if not self.loss.isfinite():
424
+ LOGGER.warning("Non-finite forward pass, skipping batch...")
425
+ continue
426
+ self.tloss = self.loss_items if self.tloss is None else (self.tloss * i + self.loss_items) / (i + 1)
426
427
 
427
428
  # Backward
428
429
  self.scaler.scale(self.loss).backward()
@@ -429,7 +429,7 @@ class Tuner:
429
429
  x = np.loadtxt(self.tune_csv, ndmin=2, delimiter=",", skiprows=1)
430
430
  fitness = x[:, 0] # first column
431
431
  best_idx = fitness.argmax()
432
- best_is_current = best_idx == (i - start)
432
+ best_is_current = best_idx == i
433
433
  if best_is_current:
434
434
  best_save_dir = str(save_dir)
435
435
  best_metrics = {k: round(v, 5) for k, v in metrics.items()}
ultralytics/nn/tasks.py CHANGED
@@ -743,6 +743,22 @@ class RTDETRDetectionModel(DetectionModel):
743
743
  """
744
744
  super().__init__(cfg=cfg, ch=ch, nc=nc, verbose=verbose)
745
745
 
746
+ def _apply(self, fn):
747
+ """
748
+ Apply a function to all tensors in the model that are not parameters or registered buffers.
749
+
750
+ Args:
751
+ fn (function): The function to apply to the model.
752
+
753
+ Returns:
754
+ (RTDETRDetectionModel): An updated BaseModel object.
755
+ """
756
+ self = super()._apply(fn)
757
+ m = self.model[-1]
758
+ m.anchors = fn(m.anchors)
759
+ m.valid_mask = fn(m.valid_mask)
760
+ return self
761
+
746
762
  def init_criterion(self):
747
763
  """Initialize the loss criterion for the RTDETRDetectionModel."""
748
764
  from ultralytics.models.utils.loss import RTDETRDetectionLoss
@@ -583,6 +583,11 @@ class ProfileModels:
583
583
  run_times = self.iterative_sigma_clipping(np.array(run_times), sigma=2, max_iters=3) # sigma clipping
584
584
  return np.mean(run_times), np.std(run_times)
585
585
 
586
+ @staticmethod
587
+ def check_dynamic(tensor_shape):
588
+ """Check whether the tensor shape in the ONNX model is dynamic."""
589
+ return not all(isinstance(dim, int) and dim >= 0 for dim in tensor_shape)
590
+
586
591
  def profile_onnx_model(self, onnx_file: str, eps: float = 1e-3):
587
592
  """
588
593
  Profile an ONNX model, measuring average inference time and standard deviation across multiple runs.
@@ -604,27 +609,36 @@ class ProfileModels:
604
609
  sess_options.intra_op_num_threads = 8 # Limit the number of threads
605
610
  sess = ort.InferenceSession(onnx_file, sess_options, providers=["CPUExecutionProvider"])
606
611
 
607
- input_tensor = sess.get_inputs()[0]
608
- input_type = input_tensor.type
609
- dynamic = not all(isinstance(dim, int) and dim >= 0 for dim in input_tensor.shape) # dynamic input shape
610
- input_shape = (1, 3, self.imgsz, self.imgsz) if dynamic else input_tensor.shape
611
-
612
- # Mapping ONNX datatype to numpy datatype
613
- if "float16" in input_type:
614
- input_dtype = np.float16
615
- elif "float" in input_type:
616
- input_dtype = np.float32
617
- elif "double" in input_type:
618
- input_dtype = np.float64
619
- elif "int64" in input_type:
620
- input_dtype = np.int64
621
- elif "int32" in input_type:
622
- input_dtype = np.int32
623
- else:
624
- raise ValueError(f"Unsupported ONNX datatype {input_type}")
612
+ input_data_dict = dict()
613
+ for input_tensor in sess.get_inputs():
614
+ input_type = input_tensor.type
615
+ if self.check_dynamic(input_tensor.shape):
616
+ if len(input_tensor.shape) != 4 and self.check_dynamic(input_tensor.shape[1:]):
617
+ raise ValueError(f"Unsupported dynamic shape {input_tensor.shape} of {input_tensor.name}")
618
+ input_shape = (
619
+ (1, 3, self.imgsz, self.imgsz) if len(input_tensor.shape) == 4 else (1, *input_tensor.shape[1:])
620
+ )
621
+ else:
622
+ input_shape = input_tensor.shape
623
+
624
+ # Mapping ONNX datatype to numpy datatype
625
+ if "float16" in input_type:
626
+ input_dtype = np.float16
627
+ elif "float" in input_type:
628
+ input_dtype = np.float32
629
+ elif "double" in input_type:
630
+ input_dtype = np.float64
631
+ elif "int64" in input_type:
632
+ input_dtype = np.int64
633
+ elif "int32" in input_type:
634
+ input_dtype = np.int32
635
+ else:
636
+ raise ValueError(f"Unsupported ONNX datatype {input_type}")
637
+
638
+ input_data = np.random.rand(*input_shape).astype(input_dtype)
639
+ input_name = input_tensor.name
640
+ input_data_dict.update({input_name: input_data})
625
641
 
626
- input_data = np.random.rand(*input_shape).astype(input_dtype)
627
- input_name = input_tensor.name
628
642
  output_name = sess.get_outputs()[0].name
629
643
 
630
644
  # Warmup runs
@@ -632,7 +646,7 @@ class ProfileModels:
632
646
  for _ in range(3):
633
647
  start_time = time.time()
634
648
  for _ in range(self.num_warmup_runs):
635
- sess.run([output_name], {input_name: input_data})
649
+ sess.run([output_name], input_data_dict)
636
650
  elapsed = time.time() - start_time
637
651
 
638
652
  # Compute number of runs as higher of min_time or num_timed_runs
@@ -642,7 +656,7 @@ class ProfileModels:
642
656
  run_times = []
643
657
  for _ in TQDM(range(num_runs), desc=onnx_file):
644
658
  start_time = time.time()
645
- sess.run([output_name], {input_name: input_data})
659
+ sess.run([output_name], input_data_dict)
646
660
  run_times.append((time.time() - start_time) * 1000) # Convert to milliseconds
647
661
 
648
662
  run_times = self.iterative_sigma_clipping(np.array(run_times), sigma=2, max_iters=5) # sigma clipping
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ultralytics
3
- Version: 8.3.208
3
+ Version: 8.3.210
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>
@@ -7,7 +7,7 @@ tests/test_exports.py,sha256=3o-qqPrPqjD1a_U6KBvwAusZ_Wy6S1WzmuvgRRUXmcA,11099
7
7
  tests/test_integrations.py,sha256=kl_AKmE_Qs1GB0_91iVwbzNxofm_hFTt0zzU6JF-pg4,6323
8
8
  tests/test_python.py,sha256=0D0VVzIk8Bdc-0qRUv5Wq3ASGOWl7fwWUtYzT9kyZ1I,28210
9
9
  tests/test_solutions.py,sha256=oaTz5BttPDIeHkQh9oEaw-O73L4iYDP3Lfe82V7DeKM,13416
10
- ultralytics/__init__.py,sha256=nqfnPtnAhClIjwIAQhPnP6rGlkCNiP0S5OAC50FWNQk,1302
10
+ ultralytics/__init__.py,sha256=pL0dZguk4T5WlgzpRo9nhdG9ATRZXqtj7zazMbnELOo,1302
11
11
  ultralytics/py.typed,sha256=la67KBlbjXN-_-DfGNcdOcjYumVpKG_Tkw-8n5dnGB4,8
12
12
  ultralytics/assets/bus.jpg,sha256=wCAZxJecGR63Od3ZRERe9Aja1Weayrb9Ug751DS_vGM,137419
13
13
  ultralytics/assets/zidane.jpg,sha256=Ftc4aeMmen1O0A3o6GCDO9FlfBslLpTAw0gnetx7bts,50427
@@ -121,12 +121,12 @@ ultralytics/data/scripts/get_coco.sh,sha256=UuJpJeo3qQpTHVINeOpmP0NYmg8PhEFE3A8J
121
121
  ultralytics/data/scripts/get_coco128.sh,sha256=qmRQl_hOKrsdHrTrnyQuFIH01oDz3lfaz138OgGfLt8,650
122
122
  ultralytics/data/scripts/get_imagenet.sh,sha256=hr42H16bM47iT27rgS7MpEo-GeOZAYUQXgr0B2cwn48,1705
123
123
  ultralytics/engine/__init__.py,sha256=lm6MckFYCPTbqIoX7w0s_daxdjNeBeKW6DXppv1-QUM,70
124
- ultralytics/engine/exporter.py,sha256=O367yF058mSaoIZdkxKfHcAD-W_lWJpNyfV43w4joA8,71233
124
+ ultralytics/engine/exporter.py,sha256=BFzmv7tn2e9zUPwFspb677o1QzzJlOfcVyl3gXmVGWg,71438
125
125
  ultralytics/engine/model.py,sha256=uX6cTFdlLllGRbz8Lr90IZGb4OrtMDIHQEg7DxUqwe8,53449
126
126
  ultralytics/engine/predictor.py,sha256=4lfw2RbBDE7939011FcSCuznscrcnMuabZtc8GXaKO4,22735
127
127
  ultralytics/engine/results.py,sha256=uQ_tgvdxKAg28pRgb5WCHiqx9Ktu7wYiVbwZy_IJ5bo,71499
128
- ultralytics/engine/trainer.py,sha256=OQZWfG2PFm8O6N6fwFmTOgkGeRSR5gSGjfy9NWNnKnQ,41178
129
- ultralytics/engine/tuner.py,sha256=Cq_iyP3Ur2AbG7sR-Z0p1_szZ34UH0AY0bCwetglqRA,21674
128
+ ultralytics/engine/trainer.py,sha256=8e1utMjk85pp8_ZrCaUrr3lvSdoZpu2J8zITpozNGG4,41293
129
+ ultralytics/engine/tuner.py,sha256=8uiZ9DSYdjHmbhfiuzbMPw--1DLS3cpfZPeSzJ9dGEA,21664
130
130
  ultralytics/engine/validator.py,sha256=s7cKMqj2HgVm-GL9bUc76QBeue2jb4cKPk-uQQG5nck,16949
131
131
  ultralytics/hub/__init__.py,sha256=xCF02lzlPKbdmGfO3NxLuXl5Kb0MaBZp_-fAWDHZ8zw,6698
132
132
  ultralytics/hub/auth.py,sha256=RIwZDWfW6vS2yGpZKR0xVl0-38itJYEFtmqY_M70bl8,6304
@@ -197,7 +197,7 @@ ultralytics/models/yolo/yoloe/train_seg.py,sha256=aCV7M8oQOvODFnU4piZdJh3tIrBJYA
197
197
  ultralytics/models/yolo/yoloe/val.py,sha256=5Gd9EoFH0FmKKvWXBl4J7gBe9DVxIczN-s3ceHwdUDo,9458
198
198
  ultralytics/nn/__init__.py,sha256=PJgOn2phQTTBR2P3s_JWvGeGXQpvw1znsumKow4tCuE,545
199
199
  ultralytics/nn/autobackend.py,sha256=Fs4gjgfCzR9mSpvZpnNXh1V1WWaUEap6oEZeSg5R4Hw,41270
200
- ultralytics/nn/tasks.py,sha256=1hz7w60SNYk7T5TRWBOPup-mbAqCJDgZ91rv9cheqdc,70379
200
+ ultralytics/nn/tasks.py,sha256=r01JGRa9bgGdOHXycN6TSK30I_Ip4GHO9dZ8LtpkmYk,70846
201
201
  ultralytics/nn/text_model.py,sha256=pHqnKe8UueR1MuwJcIE_IvrnYIlt68QL796xjcRJs2A,15275
202
202
  ultralytics/nn/modules/__init__.py,sha256=BPMbEm1daI7Tuds3zph2_afAX7Gq1uAqK8BfiCfKTZs,3198
203
203
  ultralytics/nn/modules/activation.py,sha256=75JcIMH2Cu9GTC2Uf55r_5YLpxcrXQDaVoeGQ0hlUAU,2233
@@ -239,7 +239,7 @@ ultralytics/trackers/utils/matching.py,sha256=I8SX0sBaBgr4GBJ9uDGOy5LnotgNZHpB2p
239
239
  ultralytics/utils/__init__.py,sha256=whSIuj-0lV0SAp4YjOeBJZ2emP1Qa8pqLnrhRiwl2Qs,53503
240
240
  ultralytics/utils/autobatch.py,sha256=i6KYLLSItKP1Q2IUlTPHrZhjcxl7UOjs0Seb8bF8pvM,5124
241
241
  ultralytics/utils/autodevice.py,sha256=d9yq6eEn05fdfzfpxeSECd0YEO61er5f7T-0kjLdofg,8843
242
- ultralytics/utils/benchmarks.py,sha256=L0EAWMTYmH-vvPp-mGkxaMXzKghmuWW766DSipm7wJM,31504
242
+ ultralytics/utils/benchmarks.py,sha256=5O9ABDF2FtnLfvnfZOW3HiAm2NT1ak7-2cr6iXDKfck,32155
243
243
  ultralytics/utils/checks.py,sha256=R3Fm3N3B5k4a_ATWMnOVuwFAFeSYaWmQm2yoNYh3MvU,36304
244
244
  ultralytics/utils/cpu.py,sha256=OPlVxROWhQp-kEa9EkeNRKRQ-jz0KwySu5a-h91JZjk,3634
245
245
  ultralytics/utils/dist.py,sha256=5xQhWK0OLORvseAL08UmG1LYdkiDVLquxmaGSnqiSqo,4151
@@ -275,9 +275,9 @@ ultralytics/utils/callbacks/tensorboard.py,sha256=_4nfGK1dDLn6ijpvphBDhc-AS8qhS3
275
275
  ultralytics/utils/callbacks/wb.py,sha256=ngQO8EJ1kxJDF1YajScVtzBbm26jGuejA0uWeOyvf5A,7685
276
276
  ultralytics/utils/export/__init__.py,sha256=jQtf716PP0jt7bMoY9FkqmjG26KbvDzuR84jGhaBi2U,9901
277
277
  ultralytics/utils/export/imx.py,sha256=Jl5nuNxqaP_bY5yrV2NypmoJSrexHE71TxR72SDdjcg,11394
278
- ultralytics-8.3.208.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
279
- ultralytics-8.3.208.dist-info/METADATA,sha256=gqk4EPrrKV0rxtvGakdOHYUlAAdRF3tGdLPo5-tDmUA,37667
280
- ultralytics-8.3.208.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
281
- ultralytics-8.3.208.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
282
- ultralytics-8.3.208.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
283
- ultralytics-8.3.208.dist-info/RECORD,,
278
+ ultralytics-8.3.210.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
279
+ ultralytics-8.3.210.dist-info/METADATA,sha256=myKJKGUsiFuQH_MuE2SbAIbYQxGTMLuFyTiDKW-BVfk,37667
280
+ ultralytics-8.3.210.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
281
+ ultralytics-8.3.210.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
282
+ ultralytics-8.3.210.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
283
+ ultralytics-8.3.210.dist-info/RECORD,,