ultralytics 8.2.97__py3-none-any.whl → 8.2.98__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 YOLO 🚀, AGPL-3.0 license
2
2
 
3
- __version__ = "8.2.97"
3
+ __version__ = "8.2.98"
4
4
 
5
5
 
6
6
  import os
@@ -95,9 +95,7 @@ from ultralytics.utils.torch_utils import TORCH_1_13, get_latest_opset, select_d
95
95
 
96
96
 
97
97
  def export_formats():
98
- """YOLOv8 export formats."""
99
- import pandas # scope for faster 'import ultralytics'
100
-
98
+ """Ultralytics YOLO export formats."""
101
99
  x = [
102
100
  ["PyTorch", "-", ".pt", True, True],
103
101
  ["TorchScript", "torchscript", ".torchscript", True, True],
@@ -113,7 +111,7 @@ def export_formats():
113
111
  ["PaddlePaddle", "paddle", "_paddle_model", True, True],
114
112
  ["NCNN", "ncnn", "_ncnn_model", True, True],
115
113
  ]
116
- return pandas.DataFrame(x, columns=["Format", "Argument", "Suffix", "CPU", "GPU"])
114
+ return dict(zip(["Format", "Argument", "Suffix", "CPU", "GPU"], zip(*x)))
117
115
 
118
116
 
119
117
  def gd_outputs(gd):
@@ -161,16 +161,6 @@ class HUBTrainingSession:
161
161
  HUBModelError: If the identifier format is not recognized.
162
162
  """
163
163
  api_key, model_id, filename = None, None, None
164
-
165
- # path = identifier.split(f"{HUB_WEB_ROOT}/models/")[-1]
166
- # parts = path.split("_")
167
- # if Path(path).suffix in {".pt", ".yaml"}:
168
- # filename = path
169
- # elif len(parts) == 2 and len(parts[0]) == 42 and len(parts[1]) == 20:
170
- # api_key, model_id = parts
171
- # elif len(path) == 20:
172
- # model_id = path
173
-
174
164
  if Path(identifier).suffix in {".pt", ".yaml"}:
175
165
  filename = identifier
176
166
  elif identifier.startswith(f"{HUB_WEB_ROOT}/models/"):
@@ -398,8 +398,8 @@ class AutoBackend(nn.Module):
398
398
  from ultralytics.engine.exporter import export_formats
399
399
 
400
400
  raise TypeError(
401
- f"model='{w}' is not a supported model format. "
402
- f"See https://docs.ultralytics.com/modes/predict for help.\n\n{export_formats()}"
401
+ f"model='{w}' is not a supported model format. Ultralytics supports: {export_formats()['Format']}\n"
402
+ f"See https://docs.ultralytics.com/modes/predict for help."
403
403
  )
404
404
 
405
405
  # Load external metadata YAML
@@ -653,7 +653,7 @@ class AutoBackend(nn.Module):
653
653
  """
654
654
  from ultralytics.engine.exporter import export_formats
655
655
 
656
- sf = list(export_formats().Suffix) # export suffixes
656
+ sf = export_formats()["Suffix"] # export suffixes
657
657
  if not is_url(p) and not isinstance(p, str):
658
658
  check_suffix(p, sf) # checks
659
659
  name = Path(p).name
@@ -3,6 +3,7 @@
3
3
  import contextlib
4
4
  import importlib.metadata
5
5
  import inspect
6
+ import json
6
7
  import logging.config
7
8
  import os
8
9
  import platform
@@ -14,6 +15,7 @@ import time
14
15
  import urllib
15
16
  import uuid
16
17
  from pathlib import Path
18
+ from threading import Lock
17
19
  from types import SimpleNamespace
18
20
  from typing import Union
19
21
 
@@ -1136,6 +1138,61 @@ class SettingsManager(dict):
1136
1138
  self.save()
1137
1139
 
1138
1140
 
1141
+ class PersistentCacheDict(dict):
1142
+ """A thread-safe dictionary that persists data to a JSON file for caching purposes."""
1143
+
1144
+ def __init__(self, file_path=USER_CONFIG_DIR / "persistent_cache.json"):
1145
+ """Initializes a thread-safe persistent cache dictionary with a specified file path for storage."""
1146
+ super().__init__()
1147
+ self.file_path = Path(file_path)
1148
+ self.lock = Lock()
1149
+ self._load()
1150
+
1151
+ def _load(self):
1152
+ """Load the persistent cache from a JSON file into the dictionary, handling errors gracefully."""
1153
+ try:
1154
+ if self.file_path.exists():
1155
+ with open(self.file_path) as f:
1156
+ self.update(json.load(f))
1157
+ except json.JSONDecodeError:
1158
+ print(f"Error decoding JSON from {self.file_path}. Starting with an empty cache.")
1159
+ except Exception as e:
1160
+ print(f"Error reading from {self.file_path}: {e}")
1161
+
1162
+ def _save(self):
1163
+ """Save the current state of the cache dictionary to a JSON file, ensuring thread safety."""
1164
+ try:
1165
+ self.file_path.parent.mkdir(parents=True, exist_ok=True)
1166
+ with open(self.file_path, "w") as f:
1167
+ json.dump(dict(self), f, indent=2)
1168
+ except Exception as e:
1169
+ print(f"Error writing to {self.file_path}: {e}")
1170
+
1171
+ def __setitem__(self, key, value):
1172
+ """Store a key-value pair in the cache and persist the updated cache to disk."""
1173
+ with self.lock:
1174
+ super().__setitem__(key, value)
1175
+ self._save()
1176
+
1177
+ def __delitem__(self, key):
1178
+ """Remove an item from the PersistentCacheDict and update the persistent storage."""
1179
+ with self.lock:
1180
+ super().__delitem__(key)
1181
+ self._save()
1182
+
1183
+ def update(self, *args, **kwargs):
1184
+ """Update the dictionary with key-value pairs from other mappings or iterables, ensuring thread safety."""
1185
+ with self.lock:
1186
+ super().update(*args, **kwargs)
1187
+ self._save()
1188
+
1189
+ def clear(self):
1190
+ """Clears all entries from the persistent cache dictionary, ensuring thread safety."""
1191
+ with self.lock:
1192
+ super().clear()
1193
+ self._save()
1194
+
1195
+
1139
1196
  def deprecation_warn(arg, new_arg):
1140
1197
  """Issue a deprecation warning when a deprecated argument is used, suggesting an updated argument."""
1141
1198
  LOGGER.warning(
@@ -1171,6 +1228,7 @@ def vscode_msg(ext="ultralytics.ultralytics-snippets") -> str:
1171
1228
  # Check first-install steps
1172
1229
  PREFIX = colorstr("Ultralytics: ")
1173
1230
  SETTINGS = SettingsManager() # initialize settings
1231
+ PERSISTENT_CACHE = PersistentCacheDict() # initialize persistent cache
1174
1232
  DATASETS_DIR = Path(SETTINGS["datasets_dir"]) # global datasets directory
1175
1233
  WEIGHTS_DIR = Path(SETTINGS["weights_dir"]) # global weights directory
1176
1234
  RUNS_DIR = Path(SETTINGS["runs_dir"]) # global runs directory
@@ -85,7 +85,7 @@ def benchmark(
85
85
 
86
86
  y = []
87
87
  t0 = time.time()
88
- for i, (name, format, suffix, cpu, gpu) in export_formats().iterrows(): # index, (name, format, suffix, CPU, GPU)
88
+ for i, (name, format, suffix, cpu, gpu) in enumerate(zip(*export_formats().values())):
89
89
  emoji, filename = "❌", None # export defaults
90
90
  try:
91
91
  # Checks
@@ -419,7 +419,7 @@ class Annotator:
419
419
  # Convert im back to PIL and update draw
420
420
  self.fromarray(self.im)
421
421
 
422
- def kpts(self, kpts, shape=(640, 640), radius=5, kpt_line=True, conf_thres=0.25, kpt_color=None):
422
+ def kpts(self, kpts, shape=(640, 640), radius=None, kpt_line=True, conf_thres=0.25, kpt_color=None):
423
423
  """
424
424
  Plot keypoints on the image.
425
425
 
@@ -436,6 +436,7 @@ class Annotator:
436
436
  - Modifies self.im in-place.
437
437
  - If self.pil is True, converts image to numpy array and back to PIL.
438
438
  """
439
+ radius = radius if radius is not None else self.lw
439
440
  if self.pil:
440
441
  # Convert to numpy first
441
442
  self.im = np.asarray(self.im).copy()
@@ -471,7 +472,7 @@ class Annotator:
471
472
  pos1,
472
473
  pos2,
473
474
  kpt_color or self.limb_color[i].tolist(),
474
- thickness=2,
475
+ thickness=int(np.ceil(self.lw / 2)),
475
476
  lineType=cv2.LINE_AA,
476
477
  )
477
478
  if self.pil:
@@ -110,13 +110,17 @@ def autocast(enabled: bool, device: str = "cuda"):
110
110
 
111
111
  def get_cpu_info():
112
112
  """Return a string with system CPU information, i.e. 'Apple M2'."""
113
- with contextlib.suppress(Exception):
114
- import cpuinfo # pip install py-cpuinfo
113
+ from ultralytics.utils import PERSISTENT_CACHE # avoid circular import error
115
114
 
116
- k = "brand_raw", "hardware_raw", "arch_string_raw" # keys sorted by preference (not all keys always available)
117
- info = cpuinfo.get_cpu_info() # info dict
118
- string = info.get(k[0] if k[0] in info else k[1] if k[1] in info else k[2], "unknown")
119
- return string.replace("(R)", "").replace("CPU ", "").replace("@ ", "")
115
+ if "cpu_info" not in PERSISTENT_CACHE:
116
+ with contextlib.suppress(Exception):
117
+ import cpuinfo # pip install py-cpuinfo
118
+
119
+ k = "brand_raw", "hardware_raw", "arch_string_raw" # keys sorted by preference
120
+ info = cpuinfo.get_cpu_info() # info dict
121
+ string = info.get(k[0] if k[0] in info else k[1] if k[1] in info else k[2], "unknown")
122
+ PERSISTENT_CACHE["cpu_info"] = string.replace("(R)", "").replace("CPU ", "").replace("@ ", "")
123
+ return PERSISTENT_CACHE.get("cpu_info", "unknown")
120
124
 
121
125
  return "unknown"
122
126
 
@@ -247,7 +251,7 @@ def fuse_conv_and_bn(conv, bn):
247
251
  )
248
252
 
249
253
  # Prepare filters
250
- w_conv = conv.weight.clone().view(conv.out_channels, -1)
254
+ w_conv = conv.weight.view(conv.out_channels, -1)
251
255
  w_bn = torch.diag(bn.weight.div(torch.sqrt(bn.eps + bn.running_var)))
252
256
  fusedconv.weight.copy_(torch.mm(w_bn, w_conv).view(fusedconv.weight.shape))
253
257
 
@@ -278,7 +282,7 @@ def fuse_deconv_and_bn(deconv, bn):
278
282
  )
279
283
 
280
284
  # Prepare filters
281
- w_deconv = deconv.weight.clone().view(deconv.out_channels, -1)
285
+ w_deconv = deconv.weight.view(deconv.out_channels, -1)
282
286
  w_bn = torch.diag(bn.weight.div(torch.sqrt(bn.eps + bn.running_var)))
283
287
  fuseddconv.weight.copy_(torch.mm(w_bn, w_deconv).view(fuseddconv.weight.shape))
284
288
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ultralytics
3
- Version: 8.2.97
3
+ Version: 8.2.98
4
4
  Summary: Ultralytics YOLO 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
@@ -8,7 +8,7 @@ tests/test_exports.py,sha256=Uezf3OatpPHlo5qoPw-2kqkZxuMCF9L4XF2riD4vmII,8225
8
8
  tests/test_integrations.py,sha256=xglcfMPjfVh346PV8WTpk6tBxraCXEFJEQyyJMr5tyU,6064
9
9
  tests/test_python.py,sha256=vkA0F9XgOSpU1BxI2Lzq69f6g-vi8PtOfmb_7P96ZUk,23560
10
10
  tests/test_solutions.py,sha256=p_2edhl96Ty3jwzSf02Q2m2mTu9skc0Z-eMcUuuXfLg,3300
11
- ultralytics/__init__.py,sha256=4ko8wqP19EM9zJljwbpzSwRQRNGDBUI_jSGHJg5rmD0,695
11
+ ultralytics/__init__.py,sha256=97VvSWQKGYuM4GfzWMo_UmDtaN8fZpboLas7y9pPuzA,695
12
12
  ultralytics/assets/bus.jpg,sha256=wCAZxJecGR63Od3ZRERe9Aja1Weayrb9Ug751DS_vGM,137419
13
13
  ultralytics/assets/zidane.jpg,sha256=Ftc4aeMmen1O0A3o6GCDO9FlfBslLpTAw0gnetx7bts,50427
14
14
  ultralytics/cfg/__init__.py,sha256=7FFk0HG4AvAre9CV70QMTtx1h74pSiNSJaxKSiuFkSo,33138
@@ -98,7 +98,7 @@ ultralytics/data/explorer/utils.py,sha256=EvvukQiQUTBrsZznmMnyEX2EqTuwZo_Geyc8yf
98
98
  ultralytics/data/explorer/gui/__init__.py,sha256=mHtJuK4hwF8cuV-VHDc7tp6u6D1gHz2Z7JI8grmQDTs,42
99
99
  ultralytics/data/explorer/gui/dash.py,sha256=vZ476NaUH4FKU08rAJ1K9WNyKtg0soMyJJxqg176yWc,10498
100
100
  ultralytics/engine/__init__.py,sha256=mHtJuK4hwF8cuV-VHDc7tp6u6D1gHz2Z7JI8grmQDTs,42
101
- ultralytics/engine/exporter.py,sha256=MtBFbJp3ifhn9sQXuQb7vxxOmtS_SOw7lnQhrq4H42c,57078
101
+ ultralytics/engine/exporter.py,sha256=BFYvv763kbEm5q0-AYIh979vL0ccU4RNvON2w8qtm1s,57019
102
102
  ultralytics/engine/model.py,sha256=1sWOBvLL2JIH8JuHoxwvr1MPfKFww0ORyLESx3Fs2c8,51582
103
103
  ultralytics/engine/predictor.py,sha256=MgMWHUJdRcVCaVmOyvdy2Gjk_EyRHv-ar0SSGxQe8F4,17471
104
104
  ultralytics/engine/results.py,sha256=8RJlN8J-_9w-mrDZm9wC-DZJTPBS7v1c_r_R173QyRM,75043
@@ -107,7 +107,7 @@ ultralytics/engine/tuner.py,sha256=gPqDTHH7vRB2O3YyH26m1BjVKbXxuA2XAlPRzTKFZsc,1
107
107
  ultralytics/engine/validator.py,sha256=483Ad87Irk7IBlJNLu2SQAJsb7YriALTX9GIgriCmRg,14650
108
108
  ultralytics/hub/__init__.py,sha256=AM_twjV9ouUmyxh3opoPgTqDpMOd8xIOHsAKdWS2L18,5663
109
109
  ultralytics/hub/auth.py,sha256=kDLakGa2NbzvMAeXc2UdzZ65r0AH-XeM_JfsDY97WGk,5545
110
- ultralytics/hub/session.py,sha256=ivTJpGEKEi7F55RloWN-Ks6oeB3ll74AWGAsBtAQOPM,16715
110
+ ultralytics/hub/session.py,sha256=xD4oBiWfeIMReNxSIPE-VK5xVdUHEjS8WrpBvjlRfnU,16350
111
111
  ultralytics/hub/utils.py,sha256=I7NATG6O_QRw7EU7EHkdTVvbCkwKCyUe54BP60To_so,9715
112
112
  ultralytics/hub/google/__init__.py,sha256=uclNs-_5vAzQMgQKgl8eBvml1cx6IZYXRUhrF57v6_k,7504
113
113
  ultralytics/models/__init__.py,sha256=TT9iLCL_n9Y80dcUq0Fo-p-GRZCSU2vrWXM3CoMwqqE,265
@@ -168,7 +168,7 @@ ultralytics/models/yolo/world/__init__.py,sha256=3VTH0q4NOt2EWRom15yCymvmvm0Etp2
168
168
  ultralytics/models/yolo/world/train.py,sha256=gaDrAmLJpg9qDtmL5evA5HsV2yb4RTRSfk2EDYrHdRg,3686
169
169
  ultralytics/models/yolo/world/train_world.py,sha256=IsnCEVt6DcM9lUskCKmIN-M8MM79xLpwTRqRoAHUnZ4,4857
170
170
  ultralytics/nn/__init__.py,sha256=4BPLHY89xEM_al5uK0aOmFgiML6CMGEZbezxOvTjOEs,587
171
- ultralytics/nn/autobackend.py,sha256=DZTIHsp2PLs8H2-oQR9LqA-uPj8DARGonCXzRv2Pkdc,31546
171
+ ultralytics/nn/autobackend.py,sha256=95FVDv_l5fax5f8gmhYAIIS2e_8u6HYxNd4Saxh7E10,31573
172
172
  ultralytics/nn/tasks.py,sha256=5ESFTm1CYt7uSCyWkW7rsLAdMLPHSBla95GWj439SrA,47894
173
173
  ultralytics/nn/modules/__init__.py,sha256=m8x-XRHVLWMECPeysVlv1TQenV-n8oAbK1gxnoXzLpk,2553
174
174
  ultralytics/nn/modules/activation.py,sha256=chhn469wnRHEs5BMGNBYXwPYZc_7-urspTT8fnBd-xA,895
@@ -196,9 +196,9 @@ ultralytics/trackers/utils/__init__.py,sha256=mHtJuK4hwF8cuV-VHDc7tp6u6D1gHz2Z7J
196
196
  ultralytics/trackers/utils/gmc.py,sha256=VcURuY041qGCeWUGMxHZBr10T16LtcMqyv7AmTfE1MY,14557
197
197
  ultralytics/trackers/utils/kalman_filter.py,sha256=cH9zD3fwkuezP97H9mw8cSBN7a8hHKx_Sx1j7t3oYGs,21349
198
198
  ultralytics/trackers/utils/matching.py,sha256=3Ie1WNNRZ4_q3365F03XD7Nr9juZB_08mw4yUKC3w74,7162
199
- ultralytics/utils/__init__.py,sha256=BRqC6AE9epuZJy4XcGzGfuR2zNiXx-mfot2JQomterw,44097
199
+ ultralytics/utils/__init__.py,sha256=dfNCZcBDqDOjJdIx1W_fVXSDEqKRq-CYRZOucOOQJ_0,46410
200
200
  ultralytics/utils/autobatch.py,sha256=AXboYfNSnTGsYj5FmgGYPQd0crfkeleyms6QXQfZGQ4,4194
201
- ultralytics/utils/benchmarks.py,sha256=UsVJXTgB6xQ8QBjlNghN3WuZQwXShQjuqv2RcGBLHDY,23640
201
+ ultralytics/utils/benchmarks.py,sha256=gFs-YCzNEvgggpYchVNw2PKbk9XEC_8TVy70JbP30u8,23612
202
202
  ultralytics/utils/checks.py,sha256=PmdN42XJ7IIUNbeiY8zjPIfJceaxAO04nc780EoYxTc,28910
203
203
  ultralytics/utils/dist.py,sha256=NDFga-uKxkBX2zLxFHSene_cCiGQJoyOeCXcN9JIOIk,2358
204
204
  ultralytics/utils/downloads.py,sha256=uLsYFN2G4g2joTNrsZsfc8ytvfNNRXDPkI20qgkZ2B8,21897
@@ -209,9 +209,9 @@ ultralytics/utils/loss.py,sha256=mDHGmF-gjggAUVhI1dkCm7TtfZHCwz25XKm4M2xJKLs,339
209
209
  ultralytics/utils/metrics.py,sha256=UgLGudWp57uXDMlMUJy4gsz6cfVjcq7tYmHeto3TqvM,53927
210
210
  ultralytics/utils/ops.py,sha256=dsXNdyrYx_p6io6zezig9p84dxS7U-10vceHNVu2IL0,32888
211
211
  ultralytics/utils/patches.py,sha256=Oo3DkP7MbXnNGvPfoFSocAkVvaPh9kwMT_9RQUfjVhI,3594
212
- ultralytics/utils/plotting.py,sha256=bud5mAvFxQ2JD29dReaO4c7Z00k6jIaPJJCznIoyy2w,61543
212
+ ultralytics/utils/plotting.py,sha256=lCx9i3USQK2KGsgD-l2cbdbv33c396gIwMFsZ9iOa1w,61629
213
213
  ultralytics/utils/tal.py,sha256=ECsu95xEqOItmxMDN4YTD3FsUiIsQNWy0pZC3TfvFfk,16877
214
- ultralytics/utils/torch_utils.py,sha256=lTTbFD8SlnXT11O9E8NKTQnrXEOsRmayywQP6niUZMc,29535
214
+ ultralytics/utils/torch_utils.py,sha256=yxm5JAM21RtFjSDI6F22GcovDUzL4raAqaQKLIxZ2v8,29716
215
215
  ultralytics/utils/triton.py,sha256=gg1finxno_tY2Ge9PMhmu7PI9wvoFZoiicdT4Bhqv3w,3936
216
216
  ultralytics/utils/tuner.py,sha256=AtEtK6pOt9xVTyx864OpNRVxNdAxz5aKHzveiXwkD1A,6250
217
217
  ultralytics/utils/callbacks/__init__.py,sha256=YrWqC3BVVaTLob4iCPR6I36mUxIUOpPJW7B_LjT78Qw,214
@@ -225,9 +225,9 @@ ultralytics/utils/callbacks/neptune.py,sha256=5Z3ua5YBTUS56FH8VQKQG1aaIo9fH8GEyz
225
225
  ultralytics/utils/callbacks/raytune.py,sha256=ODVYzy-CoM4Uge0zjkh3Hnh9nF2M0vhDrSenXnvcizw,705
226
226
  ultralytics/utils/callbacks/tensorboard.py,sha256=0kn4IR10no99UCIheojWRujgybmUHSx5fPI6Vsq6l_g,4135
227
227
  ultralytics/utils/callbacks/wb.py,sha256=9-fjQIdLjr3b73DTE3rHO171KvbH1VweJ-bmbv-rqTw,6747
228
- ultralytics-8.2.97.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
229
- ultralytics-8.2.97.dist-info/METADATA,sha256=ZXllOjVWz8Z_-O8l8U7EAIr7Hy32uYtPLoMpa9-Vbs0,39504
230
- ultralytics-8.2.97.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
231
- ultralytics-8.2.97.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
232
- ultralytics-8.2.97.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
233
- ultralytics-8.2.97.dist-info/RECORD,,
228
+ ultralytics-8.2.98.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
229
+ ultralytics-8.2.98.dist-info/METADATA,sha256=bTjpqsyHKIXo5Bm9Jef6DufhkW_gG4Bc5rpHnE-bBP0,39504
230
+ ultralytics-8.2.98.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
231
+ ultralytics-8.2.98.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
232
+ ultralytics-8.2.98.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
233
+ ultralytics-8.2.98.dist-info/RECORD,,