ultralytics 8.2.14__py3-none-any.whl → 8.2.16__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.

Potentially problematic release.


This version of ultralytics might be problematic. Click here for more details.

ultralytics/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  # Ultralytics YOLO 🚀, AGPL-3.0 license
2
2
 
3
- __version__ = "8.2.14"
3
+ __version__ = "8.2.16"
4
4
 
5
5
  from ultralytics.data.explorer.explorer import Explorer
6
6
  from ultralytics.models import RTDETR, SAM, YOLO, YOLOWorld
@@ -527,13 +527,13 @@ class BaseTrainer:
527
527
  if isinstance(self.model, torch.nn.Module): # if model is loaded beforehand. No setup needed
528
528
  return
529
529
 
530
- model, weights = self.model, None
530
+ cfg, weights = self.model, None
531
531
  ckpt = None
532
- if str(model).endswith(".pt"):
533
- weights, ckpt = attempt_load_one_weight(model)
532
+ if str(self.model).endswith(".pt"):
533
+ weights, ckpt = attempt_load_one_weight(self.model)
534
534
  cfg = weights.yaml
535
- else:
536
- cfg = model
535
+ elif isinstance(self.args.pretrained, (str, Path)):
536
+ weights, _ = attempt_load_one_weight(self.args.pretrained)
537
537
  self.model = self.get_model(cfg=cfg, weights=weights, verbose=RANK == -1) # calls Model(cfg, weights)
538
538
  return ckpt
539
539
 
@@ -102,13 +102,15 @@ HELP_MSG = """
102
102
  GitHub: https://github.com/ultralytics/ultralytics
103
103
  """
104
104
 
105
- # Settings
105
+ # Settings and Environment Variables
106
106
  torch.set_printoptions(linewidth=320, precision=4, profile="default")
107
107
  np.set_printoptions(linewidth=320, formatter={"float_kind": "{:11.5g}".format}) # format short g, %precision=5
108
108
  cv2.setNumThreads(0) # prevent OpenCV from multithreading (incompatible with PyTorch DataLoader)
109
109
  os.environ["NUMEXPR_MAX_THREADS"] = str(NUM_THREADS) # NumExpr max threads
110
110
  os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":4096:8" # for deterministic training
111
- os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2" # suppress verbose TF compiler warnings in Colab
111
+ os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3" # suppress verbose TF compiler warnings in Colab
112
+ os.environ["TORCH_CPP_LOG_LEVEL"] = "ERROR" # suppress "NNPACK.cpp could not initialize NNPACK" warnings
113
+ os.environ["KINETO_LOG_LEVEL"] = "5" # suppress verbose PyTorch profiler output when computing FLOPs
112
114
 
113
115
 
114
116
  class TQDM(tqdm_original):
@@ -331,19 +331,28 @@ def get_flops(model, imgsz=640):
331
331
 
332
332
 
333
333
  def get_flops_with_torch_profiler(model, imgsz=640):
334
- """Compute model FLOPs (thop alternative)."""
335
- if TORCH_2_0:
336
- model = de_parallel(model)
337
- p = next(model.parameters())
334
+ """Compute model FLOPs (thop package alternative, but 2-10x slower unfortunately)."""
335
+ if not TORCH_2_0: # torch profiler implemented in torch>=2.0
336
+ return 0.0
337
+ model = de_parallel(model)
338
+ p = next(model.parameters())
339
+ if not isinstance(imgsz, list):
340
+ imgsz = [imgsz, imgsz] # expand if int/float
341
+ try:
342
+ # Use stride size for input tensor
338
343
  stride = (max(int(model.stride.max()), 32) if hasattr(model, "stride") else 32) * 2 # max stride
339
- im = torch.zeros((1, p.shape[1], stride, stride), device=p.device) # input image in BCHW format
344
+ im = torch.empty((1, p.shape[1], stride, stride), device=p.device) # input image in BCHW format
340
345
  with torch.profiler.profile(with_flops=True) as prof:
341
346
  model(im)
342
347
  flops = sum(x.flops for x in prof.key_averages()) / 1e9
343
- imgsz = imgsz if isinstance(imgsz, list) else [imgsz, imgsz] # expand if int/float
344
348
  flops = flops * imgsz[0] / stride * imgsz[1] / stride # 640x640 GFLOPs
345
- return flops
346
- return 0
349
+ except Exception:
350
+ # Use actual image size for input tensor (i.e. required for RTDETR models)
351
+ im = torch.empty((1, p.shape[1], *imgsz), device=p.device) # input image in BCHW format
352
+ with torch.profiler.profile(with_flops=True) as prof:
353
+ model(im)
354
+ flops = sum(x.flops for x in prof.key_averages()) / 1e9
355
+ return flops
347
356
 
348
357
 
349
358
  def initialize_weights(model):
@@ -390,8 +399,13 @@ def copy_attr(a, b, include=(), exclude=()):
390
399
 
391
400
 
392
401
  def get_latest_opset():
393
- """Return second-most (for maturity) recently supported ONNX opset by this version of torch."""
394
- return max(int(k[14:]) for k in vars(torch.onnx) if "symbolic_opset" in k) - 1 # opset
402
+ """Return the second-most recent ONNX opset version supported by this version of PyTorch, adjusted for maturity."""
403
+ if TORCH_1_13:
404
+ # If the PyTorch>=1.13, dynamically compute the latest opset minus one using 'symbolic_opset'
405
+ return max(int(k[14:]) for k in vars(torch.onnx) if "symbolic_opset" in k) - 1
406
+ # Otherwise for PyTorch<=1.12 return the corresponding predefined opset
407
+ version = torch.onnx.producer_version.rsplit(".", 1)[0] # i.e. '2.3'
408
+ return {"1.12": 15, "1.11": 14, "1.10": 13, "1.9": 12, "1.8": 12}.get(version, 12)
395
409
 
396
410
 
397
411
  def intersect_dicts(da, db, exclude=()):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ultralytics
3
- Version: 8.2.14
3
+ Version: 8.2.16
4
4
  Summary: Ultralytics YOLOv8 for SOTA object detection, multi-object tracking, instance segmentation, pose estimation and image classification.
5
5
  Author: Glenn Jocher, Ayush Chaurasia, Jing Qiu
6
6
  Maintainer: Glenn Jocher, Ayush Chaurasia, Jing Qiu
@@ -1,4 +1,4 @@
1
- ultralytics/__init__.py,sha256=8EzNpeOWBuxDV22YG7ft8mxB2hmiXrnzG1V2wyP5yic,633
1
+ ultralytics/__init__.py,sha256=U9gq2dVgJR4iYEqbeRhy4SDx2LIkYY0kzorgUp0siAA,633
2
2
  ultralytics/assets/bus.jpg,sha256=wCAZxJecGR63Od3ZRERe9Aja1Weayrb9Ug751DS_vGM,137419
3
3
  ultralytics/assets/zidane.jpg,sha256=Ftc4aeMmen1O0A3o6GCDO9FlfBslLpTAw0gnetx7bts,50427
4
4
  ultralytics/cfg/__init__.py,sha256=lR6jykSO_0cigsjrqSyFj_8JG_LvYi796viasyWhcfs,21358
@@ -82,7 +82,7 @@ ultralytics/engine/exporter.py,sha256=2troO7ah3gAhHyQ2VCjFvaK9NBc6uleIVft5IRBjeF
82
82
  ultralytics/engine/model.py,sha256=IE6HE9VIzqO3DscxSLexub0LUR673eiPFrCPCt6ozEE,40103
83
83
  ultralytics/engine/predictor.py,sha256=wQRKdWGDTP5A6CS0gTC6U3RPDMhP3QkEzWSPm6eqCkU,17022
84
84
  ultralytics/engine/results.py,sha256=tVcViFF2pT1THaNaM6LIDxzhIQQ7SZf2NN-vKjLlN6Y,30919
85
- ultralytics/engine/trainer.py,sha256=GpseAovVKLRgAoqG4bEVtQqemWdDcxrY7gE3vGRU9gs,35048
85
+ ultralytics/engine/trainer.py,sha256=P5XbPxh5hj4TLwuKeriuAlvcBWmILStm40-SgPrYvLk,35149
86
86
  ultralytics/engine/tuner.py,sha256=iZrgMmXSDpfuDu4bdFRflmAsscys2-8W8qAGxSyOVJE,11844
87
87
  ultralytics/engine/validator.py,sha256=Y21Uo8_Zto4qjk_YqQk6k7tyfpq_Qk9cfjeXeyDRxs8,14643
88
88
  ultralytics/hub/__init__.py,sha256=zXam81eSJ2IkH0CwPy_VhG1XHZem9vs9jR4uG7s-uAY,5383
@@ -170,7 +170,7 @@ ultralytics/trackers/utils/__init__.py,sha256=mHtJuK4hwF8cuV-VHDc7tp6u6D1gHz2Z7J
170
170
  ultralytics/trackers/utils/gmc.py,sha256=vwcPA1n5zjPaBGhCDt8ItN7rq_6Sczsjn4gsXJfRylU,13688
171
171
  ultralytics/trackers/utils/kalman_filter.py,sha256=0oqhk59NKEiwcJ2FXnw6_sT4bIFC6Wu5IY2B-TGxJKU,15168
172
172
  ultralytics/trackers/utils/matching.py,sha256=UxhSGa5pN6WoYwYSBAkkt-O7xMxUR47VuUB6PfVNkb4,5404
173
- ultralytics/utils/__init__.py,sha256=zyk1cbMtgG8LB9s1FRKRaN2ffMlkKQcVWnhGj1EPP5Y,39284
173
+ ultralytics/utils/__init__.py,sha256=BGA9z_s-MnB5DgzMPsGjBnC88582MiapOiFV09hplGs,39518
174
174
  ultralytics/utils/autobatch.py,sha256=ygZ3f2ByIkcujB89ENcTnGWWnAQw5Pbg6nBuShg-5t4,3863
175
175
  ultralytics/utils/benchmarks.py,sha256=PlnUqhl2Om7jp7bKICDj9a2ABpJSl31VFI3ESnGdme8,23552
176
176
  ultralytics/utils/checks.py,sha256=wppGRXSjjjCkdGkFUSzICiMpIQyo9kqbVTlwoEXLQcA,28076
@@ -185,7 +185,7 @@ ultralytics/utils/ops.py,sha256=wZCWx7dm5GJNIJHyZaFJRetGcQ7prdv-anplqq9figQ,3330
185
185
  ultralytics/utils/patches.py,sha256=SgMqeMsq2K6JoBJP1NplXMl9C6rK0JeJUChjBrJOneo,2750
186
186
  ultralytics/utils/plotting.py,sha256=ihlGqsBjL23p9ngI0rbjV1Mk10y4p6Z62SlxRORzDaU,48466
187
187
  ultralytics/utils/tal.py,sha256=xuIyryUjaaYHkHPG9GvBwh1xxN2Hq4y3hXOtuERehwY,16017
188
- ultralytics/utils/torch_utils.py,sha256=y1qJniyii0sJFg8dpP-yjYh8AMOoFok9NEZcRi669Jo,25916
188
+ ultralytics/utils/torch_utils.py,sha256=6AjQsncSsXZ3Cf_YzxWBeEBbks9s7gvPVpU6-dV3psg,26771
189
189
  ultralytics/utils/triton.py,sha256=gg1finxno_tY2Ge9PMhmu7PI9wvoFZoiicdT4Bhqv3w,3936
190
190
  ultralytics/utils/tuner.py,sha256=49KAadKZsUeCpwIm5Sn0grb0RPcMNI8vHGLwroDEJNI,6171
191
191
  ultralytics/utils/callbacks/__init__.py,sha256=YrWqC3BVVaTLob4iCPR6I36mUxIUOpPJW7B_LjT78Qw,214
@@ -199,9 +199,9 @@ ultralytics/utils/callbacks/neptune.py,sha256=5Z3ua5YBTUS56FH8VQKQG1aaIo9fH8GEyz
199
199
  ultralytics/utils/callbacks/raytune.py,sha256=ODVYzy-CoM4Uge0zjkh3Hnh9nF2M0vhDrSenXnvcizw,705
200
200
  ultralytics/utils/callbacks/tensorboard.py,sha256=Z1veCVcn9THPhdplWuIzwlsW2yF7y-On9IZIk3khM0Y,4135
201
201
  ultralytics/utils/callbacks/wb.py,sha256=woCQVuZzqtM5KnwxIibcfM3sFBYojeMPnv11jrRaIQA,6674
202
- ultralytics-8.2.14.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
203
- ultralytics-8.2.14.dist-info/METADATA,sha256=KBP6_nUk1bxKFb07J2lsiPfSH2-znVkSjgEwdWqMIyA,40694
204
- ultralytics-8.2.14.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
205
- ultralytics-8.2.14.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
206
- ultralytics-8.2.14.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
207
- ultralytics-8.2.14.dist-info/RECORD,,
202
+ ultralytics-8.2.16.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
203
+ ultralytics-8.2.16.dist-info/METADATA,sha256=7V-oI3J4lEAQXotsnu38UXuKiSLljYqFHd2HWSeLDDs,40694
204
+ ultralytics-8.2.16.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
205
+ ultralytics-8.2.16.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
206
+ ultralytics-8.2.16.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
207
+ ultralytics-8.2.16.dist-info/RECORD,,