ultralytics 8.2.66__py3-none-any.whl → 8.2.68__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.66"
3
+ __version__ = "8.2.68"
4
4
 
5
5
  import os
6
6
 
@@ -0,0 +1,159 @@
1
+ # Ultralytics YOLO 🚀, AGPL-3.0 license
2
+
3
+ import concurrent.futures
4
+ import statistics
5
+ import time
6
+ from typing import List, Optional, Tuple
7
+
8
+ import requests
9
+
10
+
11
+ class GCPRegions:
12
+ """
13
+ A class for managing and analyzing Google Cloud Platform (GCP) regions.
14
+
15
+ This class provides functionality to initialize, categorize, and analyze GCP regions based on their
16
+ geographical location, tier classification, and network latency.
17
+
18
+ Attributes:
19
+ regions (Dict[str, Tuple[int, str, str]]): A dictionary of GCP regions with their tier, city, and country.
20
+
21
+ Methods:
22
+ tier1: Returns a list of tier 1 GCP regions.
23
+ tier2: Returns a list of tier 2 GCP regions.
24
+ lowest_latency: Determines the GCP region(s) with the lowest network latency.
25
+
26
+ Examples:
27
+ >>> from ultralytics.hub.google import GCPRegions
28
+ >>> regions = GCPRegions()
29
+ >>> lowest_latency_region = regions.lowest_latency(verbose=True, attempts=3)
30
+ >>> print(f"Lowest latency region: {lowest_latency_region[0][0]}")
31
+ """
32
+
33
+ def __init__(self):
34
+ """Initializes the GCPRegions class with predefined Google Cloud Platform regions and their details."""
35
+ self.regions = {
36
+ "asia-east1": (1, "Taiwan", "China"),
37
+ "asia-east2": (2, "Hong Kong", "China"),
38
+ "asia-northeast1": (1, "Tokyo", "Japan"),
39
+ "asia-northeast2": (1, "Osaka", "Japan"),
40
+ "asia-northeast3": (2, "Seoul", "South Korea"),
41
+ "asia-south1": (2, "Mumbai", "India"),
42
+ "asia-south2": (2, "Delhi", "India"),
43
+ "asia-southeast1": (2, "Jurong West", "Singapore"),
44
+ "asia-southeast2": (2, "Jakarta", "Indonesia"),
45
+ "australia-southeast1": (2, "Sydney", "Australia"),
46
+ "australia-southeast2": (2, "Melbourne", "Australia"),
47
+ "europe-central2": (2, "Warsaw", "Poland"),
48
+ "europe-north1": (1, "Hamina", "Finland"),
49
+ "europe-southwest1": (1, "Madrid", "Spain"),
50
+ "europe-west1": (1, "St. Ghislain", "Belgium"),
51
+ "europe-west10": (2, "Berlin", "Germany"),
52
+ "europe-west12": (2, "Turin", "Italy"),
53
+ "europe-west2": (2, "London", "United Kingdom"),
54
+ "europe-west3": (2, "Frankfurt", "Germany"),
55
+ "europe-west4": (1, "Eemshaven", "Netherlands"),
56
+ "europe-west6": (2, "Zurich", "Switzerland"),
57
+ "europe-west8": (1, "Milan", "Italy"),
58
+ "europe-west9": (1, "Paris", "France"),
59
+ "me-central1": (2, "Doha", "Qatar"),
60
+ "me-west1": (1, "Tel Aviv", "Israel"),
61
+ "northamerica-northeast1": (2, "Montreal", "Canada"),
62
+ "northamerica-northeast2": (2, "Toronto", "Canada"),
63
+ "southamerica-east1": (2, "São Paulo", "Brazil"),
64
+ "southamerica-west1": (2, "Santiago", "Chile"),
65
+ "us-central1": (1, "Iowa", "United States"),
66
+ "us-east1": (1, "South Carolina", "United States"),
67
+ "us-east4": (1, "Northern Virginia", "United States"),
68
+ "us-east5": (1, "Columbus", "United States"),
69
+ "us-south1": (1, "Dallas", "United States"),
70
+ "us-west1": (1, "Oregon", "United States"),
71
+ "us-west2": (2, "Los Angeles", "United States"),
72
+ "us-west3": (2, "Salt Lake City", "United States"),
73
+ "us-west4": (2, "Las Vegas", "United States"),
74
+ }
75
+
76
+ def tier1(self) -> List[str]:
77
+ """Returns a list of GCP regions classified as tier 1 based on predefined criteria."""
78
+ return [region for region, info in self.regions.items() if info[0] == 1]
79
+
80
+ def tier2(self) -> List[str]:
81
+ """Returns a list of GCP regions classified as tier 2 based on predefined criteria."""
82
+ return [region for region, info in self.regions.items() if info[0] == 2]
83
+
84
+ @staticmethod
85
+ def _ping_region(region: str, attempts: int = 1) -> Tuple[str, float, float, float, float]:
86
+ """Pings a specified GCP region and returns latency statistics: mean, min, max, and standard deviation."""
87
+ url = f"https://{region}-docker.pkg.dev"
88
+ latencies = []
89
+ for _ in range(attempts):
90
+ try:
91
+ start_time = time.time()
92
+ _ = requests.head(url, timeout=5)
93
+ latency = (time.time() - start_time) * 1000 # convert latency to milliseconds
94
+ if latency != float("inf"):
95
+ latencies.append(latency)
96
+ except requests.RequestException:
97
+ pass
98
+ if not latencies:
99
+ return region, float("inf"), float("inf"), float("inf"), float("inf")
100
+
101
+ std_dev = statistics.stdev(latencies) if len(latencies) > 1 else 0
102
+ return region, statistics.mean(latencies), std_dev, min(latencies), max(latencies)
103
+
104
+ def lowest_latency(
105
+ self,
106
+ top: int = 1,
107
+ verbose: bool = False,
108
+ tier: Optional[int] = None,
109
+ attempts: int = 1,
110
+ ) -> List[Tuple[str, float, float, float, float]]:
111
+ """
112
+ Determines the GCP regions with the lowest latency based on ping tests.
113
+
114
+ Args:
115
+ top (int): Number of top regions to return.
116
+ verbose (bool): If True, prints detailed latency information for all tested regions.
117
+ tier (int | None): Filter regions by tier (1 or 2). If None, all regions are tested.
118
+ attempts (int): Number of ping attempts per region.
119
+
120
+ Returns:
121
+ (List[Tuple[str, float, float, float, float]]): List of tuples containing region information and
122
+ latency statistics. Each tuple contains (region, mean_latency, std_dev, min_latency, max_latency).
123
+
124
+ Examples:
125
+ >>> regions = GCPRegions()
126
+ >>> results = regions.lowest_latency(top=3, verbose=True, tier=1, attempts=2)
127
+ >>> print(results[0][0]) # Print the name of the lowest latency region
128
+ """
129
+ if verbose:
130
+ print(f"Testing GCP regions for latency (with {attempts} {'retry' if attempts == 1 else 'attempts'})...")
131
+
132
+ regions_to_test = [k for k, v in self.regions.items() if v[0] == tier] if tier else list(self.regions.keys())
133
+ with concurrent.futures.ThreadPoolExecutor(max_workers=50) as executor:
134
+ results = list(executor.map(lambda r: self._ping_region(r, attempts), regions_to_test))
135
+
136
+ sorted_results = sorted(results, key=lambda x: x[1])
137
+
138
+ if verbose:
139
+ print(f"{'Region':<20} {'Location':<35} {'Tier':<5} {'Latency (ms)'}")
140
+ for region, mean, std, min_, max_ in sorted_results:
141
+ tier, city, country = self.regions[region]
142
+ location = f"{city}, {country}"
143
+ if mean == float("inf"):
144
+ print(f"{region:<20} {location:<35} {tier:<5} {'Timeout'}")
145
+ else:
146
+ print(f"{region:<20} {location:<35} {tier:<5} {mean:.0f} ± {std:.0f} ({min_:.0f} - {max_:.0f})")
147
+ print(f"\nLowest latency region{'s' if top > 1 else ''}:")
148
+ for region, mean, std, min_, max_ in sorted_results[:top]:
149
+ tier, city, country = self.regions[region]
150
+ location = f"{city}, {country}"
151
+ print(f"{region} ({location}, {mean:.0f} ± {std:.0f} ms ({min_:.0f} - {max_:.0f}))")
152
+
153
+ return sorted_results[:top]
154
+
155
+
156
+ # Usage example
157
+ if __name__ == "__main__":
158
+ regions = GCPRegions()
159
+ top_3_latency_tier1 = regions.lowest_latency(top=3, verbose=True, tier=1, attempts=3)
@@ -44,6 +44,7 @@ LOGGING_NAME = "ultralytics"
44
44
  MACOS, LINUX, WINDOWS = (platform.system() == x for x in ["Darwin", "Linux", "Windows"]) # environment booleans
45
45
  ARM64 = platform.machine() in {"arm64", "aarch64"} # ARM64 booleans
46
46
  PYTHON_VERSION = platform.python_version()
47
+ TORCH_VERSION = torch.__version__
47
48
  TORCHVISION_VERSION = importlib.metadata.version("torchvision") # faster than importing torchvision
48
49
  HELP_MSG = """
49
50
  Usage examples for running YOLOv8:
@@ -975,6 +976,11 @@ class SettingsManager(dict):
975
976
  "tensorboard": True,
976
977
  "wandb": True,
977
978
  }
979
+ self.help_msg = (
980
+ f"\nView settings with 'yolo settings' or at '{self.file}'"
981
+ "\nUpdate settings with 'yolo settings key=value', i.e. 'yolo settings runs_dir=path/to/dir'. "
982
+ "For help see https://docs.ultralytics.com/quickstart/#ultralytics-settings."
983
+ )
978
984
 
979
985
  super().__init__(copy.deepcopy(self.defaults))
980
986
 
@@ -986,15 +992,10 @@ class SettingsManager(dict):
986
992
  correct_keys = self.keys() == self.defaults.keys()
987
993
  correct_types = all(type(a) is type(b) for a, b in zip(self.values(), self.defaults.values()))
988
994
  correct_version = check_version(self["settings_version"], self.version)
989
- help_msg = (
990
- f"\nView settings with 'yolo settings' or at '{self.file}'"
991
- "\nUpdate settings with 'yolo settings key=value', i.e. 'yolo settings runs_dir=path/to/dir'. "
992
- "For help see https://docs.ultralytics.com/quickstart/#ultralytics-settings."
993
- )
994
995
  if not (correct_keys and correct_types and correct_version):
995
996
  LOGGER.warning(
996
997
  "WARNING ⚠️ Ultralytics settings reset to default values. This may be due to a possible problem "
997
- f"with your settings or a recent ultralytics package update. {help_msg}"
998
+ f"with your settings or a recent ultralytics package update. {self.help_msg}"
998
999
  )
999
1000
  self.reset()
1000
1001
 
@@ -1002,7 +1003,7 @@ class SettingsManager(dict):
1002
1003
  LOGGER.warning(
1003
1004
  f"WARNING ⚠️ Ultralytics setting 'datasets_dir: {self.get('datasets_dir')}' "
1004
1005
  f"must be different than 'runs_dir: {self.get('runs_dir')}'. "
1005
- f"Please change one to avoid possible issues during training. {help_msg}"
1006
+ f"Please change one to avoid possible issues during training. {self.help_msg}"
1006
1007
  )
1007
1008
 
1008
1009
  def load(self):
@@ -1015,6 +1016,12 @@ class SettingsManager(dict):
1015
1016
 
1016
1017
  def update(self, *args, **kwargs):
1017
1018
  """Updates a setting value in the current settings."""
1019
+ for k, v in kwargs.items():
1020
+ if k not in self.defaults:
1021
+ raise KeyError(f"No Ultralytics setting '{k}'. {self.help_msg}")
1022
+ t = type(self.defaults[k])
1023
+ if not isinstance(v, t):
1024
+ raise TypeError(f"Ultralytics setting '{k}' must be of type '{t}', not '{type(v)}'. {self.help_msg}")
1018
1025
  super().update(*args, **kwargs)
1019
1026
  self.save()
1020
1027
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ultralytics
3
- Version: 8.2.66
3
+ Version: 8.2.68
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
@@ -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=cLK8dyRf_4H_znFIm-krnOFMydwkxKlVZvHwl9vbck8,21780
10
10
  tests/test_solutions.py,sha256=EACnPXbeJe2aVTOKfqMk5jclKKCWCVgFEzjpR6y7Sh8,3304
11
- ultralytics/__init__.py,sha256=DI1GNRiF17xoRSVrHICeAxCcgyfbcZCnWdhJ6PdQUj8,694
11
+ ultralytics/__init__.py,sha256=kFbWHacl29mp-kVoUKfsiqYWu9a_pbJU0q7y0xeg7uE,694
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=fD3Llw12sIkJo4g667t6b051je9nEpwdBLGgbbVEzHY,32973
@@ -109,6 +109,7 @@ ultralytics/hub/__init__.py,sha256=93bqI8x8-MfDYdKkQVduuocUiQj3WGnk1nIk0li08zA,5
109
109
  ultralytics/hub/auth.py,sha256=FID58NE6fh7Op_B45QOpWBw1qoBN0ponL16uvyb2dZ8,5399
110
110
  ultralytics/hub/session.py,sha256=UF_aVwyxnbP-OzpzKXGGhi4i6KGWjjhoj5Qsn46dFpE,16257
111
111
  ultralytics/hub/utils.py,sha256=tXfM3QbXBcf4Y6StgHI1pktT4OM7Ic9eF3xiBFHGlhY,9721
112
+ ultralytics/hub/google/__init__.py,sha256=0jjs294Kd1iEdRUGgoqIGUrUNzDFtSwV_M8H9_BQoGU,7512
112
113
  ultralytics/models/__init__.py,sha256=TT9iLCL_n9Y80dcUq0Fo-p-GRZCSU2vrWXM3CoMwqqE,265
113
114
  ultralytics/models/fastsam/__init__.py,sha256=0dt65jZ_5b7Q-mdXN8MSEkgnFRA0FIwlel_LS2RaOlU,254
114
115
  ultralytics/models/fastsam/model.py,sha256=c7GGwaa9AXssJFwrcuytFHpPOlgSrS3n0utyf4JSL2o,1055
@@ -193,7 +194,7 @@ ultralytics/trackers/utils/__init__.py,sha256=mHtJuK4hwF8cuV-VHDc7tp6u6D1gHz2Z7J
193
194
  ultralytics/trackers/utils/gmc.py,sha256=-1oBNFRB-9EawJmUOT566AygLCVxJw-jsPSIOl5j_Hk,13683
194
195
  ultralytics/trackers/utils/kalman_filter.py,sha256=0oqhk59NKEiwcJ2FXnw6_sT4bIFC6Wu5IY2B-TGxJKU,15168
195
196
  ultralytics/trackers/utils/matching.py,sha256=UxhSGa5pN6WoYwYSBAkkt-O7xMxUR47VuUB6PfVNkb4,5404
196
- ultralytics/utils/__init__.py,sha256=w6UHjkT0qkDmIr6JgwoGisLusJFpvmpOiegATYend_g,38526
197
+ ultralytics/utils/__init__.py,sha256=FyRZRncXCAGmtFp1Dd4ACUK5zTrp6sOK-zFuG2Nwm1I,38905
197
198
  ultralytics/utils/autobatch.py,sha256=POJb9f8dioI7lPGnCc7bdxt0ncftXZa0bvOkip-XoWk,3969
198
199
  ultralytics/utils/benchmarks.py,sha256=6tdNcBLATllWpmAMUC6TW7DiCx1VKHhnQN4vkoqN3sE,23866
199
200
  ultralytics/utils/checks.py,sha256=hBkhOinWRzhpA5SbY1v-wCMdFeOemORRlmKBXgwoHYo,28498
@@ -222,9 +223,9 @@ ultralytics/utils/callbacks/neptune.py,sha256=5Z3ua5YBTUS56FH8VQKQG1aaIo9fH8GEyz
222
223
  ultralytics/utils/callbacks/raytune.py,sha256=ODVYzy-CoM4Uge0zjkh3Hnh9nF2M0vhDrSenXnvcizw,705
223
224
  ultralytics/utils/callbacks/tensorboard.py,sha256=QEgOVhUqY9akOs5TJIwz1Rvn6l32xWLpOxlwEyWF0B8,4136
224
225
  ultralytics/utils/callbacks/wb.py,sha256=9-fjQIdLjr3b73DTE3rHO171KvbH1VweJ-bmbv-rqTw,6747
225
- ultralytics-8.2.66.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
226
- ultralytics-8.2.66.dist-info/METADATA,sha256=HyQKUxXE05aM42tzp_IJ7EGFptuc-bif23Jtl7sZDUU,41337
227
- ultralytics-8.2.66.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
228
- ultralytics-8.2.66.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
229
- ultralytics-8.2.66.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
230
- ultralytics-8.2.66.dist-info/RECORD,,
226
+ ultralytics-8.2.68.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
227
+ ultralytics-8.2.68.dist-info/METADATA,sha256=Sbvvwn9ey5INu9Iqb5yZz8KtyC4zc56D7ItK9LW1TJ0,41337
228
+ ultralytics-8.2.68.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
229
+ ultralytics-8.2.68.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
230
+ ultralytics-8.2.68.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
231
+ ultralytics-8.2.68.dist-info/RECORD,,