ultralytics 8.3.89__py3-none-any.whl → 8.3.90__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.
- tests/conftest.py +2 -2
- tests/test_cli.py +13 -11
- tests/test_cuda.py +10 -1
- tests/test_integrations.py +1 -5
- tests/test_python.py +16 -16
- tests/test_solutions.py +9 -9
- ultralytics/__init__.py +1 -1
- ultralytics/cfg/__init__.py +3 -1
- ultralytics/cfg/models/11/yolo11-cls.yaml +5 -5
- ultralytics/cfg/models/11/yolo11-obb.yaml +5 -5
- ultralytics/cfg/models/11/yolo11-pose.yaml +5 -5
- ultralytics/cfg/models/11/yolo11-seg.yaml +5 -5
- ultralytics/cfg/models/11/yolo11.yaml +5 -5
- ultralytics/cfg/models/v8/yolov8-ghost-p2.yaml +5 -5
- ultralytics/cfg/models/v8/yolov8-ghost-p6.yaml +5 -5
- ultralytics/cfg/models/v8/yolov8-ghost.yaml +5 -5
- ultralytics/cfg/models/v8/yolov8-obb.yaml +5 -5
- ultralytics/cfg/models/v8/yolov8-p6.yaml +5 -5
- ultralytics/cfg/models/v8/yolov8-rtdetr.yaml +5 -5
- ultralytics/cfg/models/v8/yolov8-world.yaml +5 -5
- ultralytics/cfg/models/v8/yolov8-worldv2.yaml +5 -5
- ultralytics/cfg/models/v8/yolov8.yaml +5 -5
- ultralytics/cfg/models/v9/yolov9c-seg.yaml +1 -1
- ultralytics/cfg/models/v9/yolov9c.yaml +1 -1
- ultralytics/cfg/models/v9/yolov9e-seg.yaml +1 -1
- ultralytics/cfg/models/v9/yolov9e.yaml +1 -1
- ultralytics/cfg/models/v9/yolov9m.yaml +1 -1
- ultralytics/cfg/models/v9/yolov9s.yaml +1 -1
- ultralytics/cfg/models/v9/yolov9t.yaml +1 -1
- ultralytics/data/annotator.py +9 -14
- ultralytics/data/base.py +118 -30
- ultralytics/data/build.py +63 -24
- ultralytics/data/converter.py +5 -5
- ultralytics/data/dataset.py +207 -53
- ultralytics/data/loaders.py +1 -0
- ultralytics/data/split_dota.py +39 -12
- ultralytics/data/utils.py +13 -19
- ultralytics/engine/exporter.py +19 -17
- ultralytics/engine/model.py +67 -88
- ultralytics/engine/predictor.py +106 -21
- ultralytics/engine/trainer.py +32 -23
- ultralytics/engine/tuner.py +21 -18
- ultralytics/engine/validator.py +75 -41
- ultralytics/hub/__init__.py +12 -13
- ultralytics/hub/auth.py +9 -12
- ultralytics/hub/session.py +76 -21
- ultralytics/hub/utils.py +19 -17
- ultralytics/models/fastsam/model.py +20 -11
- ultralytics/models/fastsam/predict.py +36 -16
- ultralytics/models/fastsam/utils.py +5 -5
- ultralytics/models/fastsam/val.py +6 -6
- ultralytics/models/nas/model.py +22 -11
- ultralytics/models/nas/predict.py +9 -4
- ultralytics/models/nas/val.py +5 -5
- ultralytics/models/rtdetr/model.py +20 -11
- ultralytics/models/rtdetr/predict.py +18 -15
- ultralytics/models/rtdetr/train.py +20 -16
- ultralytics/models/rtdetr/val.py +42 -6
- ultralytics/models/sam/__init__.py +1 -1
- ultralytics/models/sam/amg.py +50 -4
- ultralytics/models/sam/model.py +8 -14
- ultralytics/models/sam/modules/decoders.py +18 -21
- ultralytics/models/sam/modules/encoders.py +25 -46
- ultralytics/models/sam/modules/memory_attention.py +19 -15
- ultralytics/models/sam/modules/sam.py +18 -25
- ultralytics/models/sam/modules/tiny_encoder.py +19 -29
- ultralytics/models/sam/modules/transformer.py +35 -57
- ultralytics/models/sam/modules/utils.py +15 -15
- ultralytics/models/sam/predict.py +0 -3
- ultralytics/models/utils/loss.py +87 -36
- ultralytics/models/utils/ops.py +26 -31
- ultralytics/models/yolo/classify/predict.py +24 -3
- ultralytics/models/yolo/classify/train.py +77 -10
- ultralytics/models/yolo/classify/val.py +40 -15
- ultralytics/models/yolo/detect/predict.py +23 -10
- ultralytics/models/yolo/detect/train.py +85 -15
- ultralytics/models/yolo/detect/val.py +145 -21
- ultralytics/models/yolo/model.py +1 -2
- ultralytics/models/yolo/obb/predict.py +12 -4
- ultralytics/models/yolo/obb/train.py +7 -0
- ultralytics/models/yolo/obb/val.py +25 -7
- ultralytics/models/yolo/pose/predict.py +22 -6
- ultralytics/models/yolo/pose/train.py +17 -1
- ultralytics/models/yolo/pose/val.py +46 -21
- ultralytics/models/yolo/segment/predict.py +22 -8
- ultralytics/models/yolo/segment/train.py +6 -0
- ultralytics/models/yolo/segment/val.py +100 -14
- ultralytics/models/yolo/world/train.py +38 -8
- ultralytics/models/yolo/world/train_world.py +39 -10
- ultralytics/nn/autobackend.py +28 -14
- ultralytics/nn/modules/__init__.py +3 -0
- ultralytics/nn/modules/activation.py +12 -3
- ultralytics/nn/modules/block.py +587 -84
- ultralytics/nn/modules/conv.py +418 -54
- ultralytics/nn/modules/head.py +3 -4
- ultralytics/nn/modules/transformer.py +320 -34
- ultralytics/nn/modules/utils.py +17 -3
- ultralytics/nn/tasks.py +221 -69
- ultralytics/solutions/ai_gym.py +2 -2
- ultralytics/solutions/analytics.py +4 -4
- ultralytics/solutions/heatmap.py +4 -4
- ultralytics/solutions/instance_segmentation.py +10 -4
- ultralytics/solutions/object_blurrer.py +2 -2
- ultralytics/solutions/object_counter.py +2 -2
- ultralytics/solutions/object_cropper.py +2 -2
- ultralytics/solutions/parking_management.py +9 -9
- ultralytics/solutions/queue_management.py +1 -1
- ultralytics/solutions/region_counter.py +2 -2
- ultralytics/solutions/security_alarm.py +7 -7
- ultralytics/solutions/solutions.py +7 -4
- ultralytics/solutions/speed_estimation.py +2 -2
- ultralytics/solutions/streamlit_inference.py +6 -6
- ultralytics/solutions/trackzone.py +9 -2
- ultralytics/solutions/vision_eye.py +4 -4
- ultralytics/trackers/basetrack.py +1 -1
- ultralytics/trackers/bot_sort.py +23 -22
- ultralytics/trackers/byte_tracker.py +4 -4
- ultralytics/trackers/track.py +2 -1
- ultralytics/trackers/utils/gmc.py +26 -27
- ultralytics/trackers/utils/kalman_filter.py +31 -29
- ultralytics/trackers/utils/matching.py +7 -7
- ultralytics/utils/__init__.py +32 -27
- ultralytics/utils/autobatch.py +5 -5
- ultralytics/utils/benchmarks.py +111 -18
- ultralytics/utils/callbacks/base.py +3 -3
- ultralytics/utils/callbacks/clearml.py +11 -11
- ultralytics/utils/callbacks/comet.py +35 -22
- ultralytics/utils/callbacks/dvc.py +11 -10
- ultralytics/utils/callbacks/hub.py +8 -8
- ultralytics/utils/callbacks/mlflow.py +1 -1
- ultralytics/utils/callbacks/neptune.py +12 -10
- ultralytics/utils/callbacks/raytune.py +1 -1
- ultralytics/utils/callbacks/tensorboard.py +6 -6
- ultralytics/utils/callbacks/wb.py +16 -16
- ultralytics/utils/checks.py +116 -35
- ultralytics/utils/dist.py +15 -2
- ultralytics/utils/downloads.py +13 -9
- ultralytics/utils/files.py +12 -13
- ultralytics/utils/instance.py +112 -45
- ultralytics/utils/loss.py +28 -33
- ultralytics/utils/metrics.py +246 -181
- ultralytics/utils/ops.py +61 -53
- ultralytics/utils/patches.py +8 -6
- ultralytics/utils/plotting.py +64 -45
- ultralytics/utils/tal.py +88 -57
- ultralytics/utils/torch_utils.py +181 -33
- ultralytics/utils/triton.py +13 -3
- ultralytics/utils/tuner.py +8 -16
- {ultralytics-8.3.89.dist-info → ultralytics-8.3.90.dist-info}/METADATA +1 -1
- ultralytics-8.3.90.dist-info/RECORD +250 -0
- ultralytics-8.3.89.dist-info/RECORD +0 -250
- {ultralytics-8.3.89.dist-info → ultralytics-8.3.90.dist-info}/LICENSE +0 -0
- {ultralytics-8.3.89.dist-info → ultralytics-8.3.90.dist-info}/WHEEL +0 -0
- {ultralytics-8.3.89.dist-info → ultralytics-8.3.90.dist-info}/entry_points.txt +0 -0
- {ultralytics-8.3.89.dist-info → ultralytics-8.3.90.dist-info}/top_level.txt +0 -0
@@ -16,20 +16,19 @@ class GMC:
|
|
16
16
|
SIFT, ECC, and Sparse Optical Flow. It also supports downscaling of frames for computational efficiency.
|
17
17
|
|
18
18
|
Attributes:
|
19
|
-
method (str): The method
|
19
|
+
method (str): The tracking method to use. Options include 'orb', 'sift', 'ecc', 'sparseOptFlow', 'none'.
|
20
20
|
downscale (int): Factor by which to downscale the frames for processing.
|
21
|
-
prevFrame (np.ndarray):
|
22
|
-
prevKeyPoints (List):
|
23
|
-
prevDescriptors (np.ndarray):
|
24
|
-
initializedFirstFrame (bool): Flag
|
21
|
+
prevFrame (np.ndarray): Previous frame for tracking.
|
22
|
+
prevKeyPoints (List): Keypoints from the previous frame.
|
23
|
+
prevDescriptors (np.ndarray): Descriptors from the previous frame.
|
24
|
+
initializedFirstFrame (bool): Flag indicating if the first frame has been processed.
|
25
25
|
|
26
26
|
Methods:
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
reset_params: Resets the internal parameters of the GMC object.
|
27
|
+
apply: Apply the chosen method to a raw frame and optionally use provided detections.
|
28
|
+
apply_ecc: Apply the ECC algorithm to a raw frame.
|
29
|
+
apply_features: Apply feature-based methods like ORB or SIFT to a raw frame.
|
30
|
+
apply_sparseoptflow: Apply the Sparse Optical Flow method to a raw frame.
|
31
|
+
reset_params: Reset the internal parameters of the GMC object.
|
33
32
|
|
34
33
|
Examples:
|
35
34
|
Create a GMC object and apply it to a frame
|
@@ -46,7 +45,7 @@ class GMC:
|
|
46
45
|
Initialize a Generalized Motion Compensation (GMC) object with tracking method and downscale factor.
|
47
46
|
|
48
47
|
Args:
|
49
|
-
method (str): The method
|
48
|
+
method (str): The tracking method to use. Options include 'orb', 'sift', 'ecc', 'sparseOptFlow', 'none'.
|
50
49
|
downscale (int): Downscale factor for processing frames.
|
51
50
|
|
52
51
|
Examples:
|
@@ -82,14 +81,14 @@ class GMC:
|
|
82
81
|
elif self.method in {"none", "None", None}:
|
83
82
|
self.method = None
|
84
83
|
else:
|
85
|
-
raise ValueError(f"Error: Unknown GMC method:{method}")
|
84
|
+
raise ValueError(f"Error: Unknown GMC method: {method}")
|
86
85
|
|
87
86
|
self.prevFrame = None
|
88
87
|
self.prevKeyPoints = None
|
89
88
|
self.prevDescriptors = None
|
90
89
|
self.initializedFirstFrame = False
|
91
90
|
|
92
|
-
def apply(self, raw_frame: np.
|
91
|
+
def apply(self, raw_frame: np.ndarray, detections: list = None) -> np.ndarray:
|
93
92
|
"""
|
94
93
|
Apply object detection on a raw frame using the specified method.
|
95
94
|
|
@@ -98,14 +97,14 @@ class GMC:
|
|
98
97
|
detections (List | None): List of detections to be used in the processing.
|
99
98
|
|
100
99
|
Returns:
|
101
|
-
(np.ndarray):
|
100
|
+
(np.ndarray): Transformation matrix with shape (2, 3).
|
102
101
|
|
103
102
|
Examples:
|
104
103
|
>>> gmc = GMC(method="sparseOptFlow")
|
105
104
|
>>> raw_frame = np.random.rand(480, 640, 3)
|
106
|
-
>>>
|
107
|
-
>>> print(
|
108
|
-
(
|
105
|
+
>>> transformation_matrix = gmc.apply(raw_frame)
|
106
|
+
>>> print(transformation_matrix.shape)
|
107
|
+
(2, 3)
|
109
108
|
"""
|
110
109
|
if self.method in {"orb", "sift"}:
|
111
110
|
return self.apply_features(raw_frame, detections)
|
@@ -116,7 +115,7 @@ class GMC:
|
|
116
115
|
else:
|
117
116
|
return np.eye(2, 3)
|
118
117
|
|
119
|
-
def apply_ecc(self, raw_frame: np.
|
118
|
+
def apply_ecc(self, raw_frame: np.ndarray) -> np.ndarray:
|
120
119
|
"""
|
121
120
|
Apply the ECC (Enhanced Correlation Coefficient) algorithm to a raw frame for motion compensation.
|
122
121
|
|
@@ -124,7 +123,7 @@ class GMC:
|
|
124
123
|
raw_frame (np.ndarray): The raw frame to be processed, with shape (H, W, C).
|
125
124
|
|
126
125
|
Returns:
|
127
|
-
(np.ndarray):
|
126
|
+
(np.ndarray): Transformation matrix with shape (2, 3).
|
128
127
|
|
129
128
|
Examples:
|
130
129
|
>>> gmc = GMC(method="ecc")
|
@@ -161,7 +160,7 @@ class GMC:
|
|
161
160
|
|
162
161
|
return H
|
163
162
|
|
164
|
-
def apply_features(self, raw_frame: np.
|
163
|
+
def apply_features(self, raw_frame: np.ndarray, detections: list = None) -> np.ndarray:
|
165
164
|
"""
|
166
165
|
Apply feature-based methods like ORB or SIFT to a raw frame.
|
167
166
|
|
@@ -170,13 +169,13 @@ class GMC:
|
|
170
169
|
detections (List | None): List of detections to be used in the processing.
|
171
170
|
|
172
171
|
Returns:
|
173
|
-
(np.ndarray):
|
172
|
+
(np.ndarray): Transformation matrix with shape (2, 3).
|
174
173
|
|
175
174
|
Examples:
|
176
175
|
>>> gmc = GMC(method="orb")
|
177
176
|
>>> raw_frame = np.random.randint(0, 255, (480, 640, 3), dtype=np.uint8)
|
178
|
-
>>>
|
179
|
-
>>> print(
|
177
|
+
>>> transformation_matrix = gmc.apply_features(raw_frame)
|
178
|
+
>>> print(transformation_matrix.shape)
|
180
179
|
(2, 3)
|
181
180
|
"""
|
182
181
|
height, width, _ = raw_frame.shape
|
@@ -304,7 +303,7 @@ class GMC:
|
|
304
303
|
|
305
304
|
return H
|
306
305
|
|
307
|
-
def apply_sparseoptflow(self, raw_frame: np.
|
306
|
+
def apply_sparseoptflow(self, raw_frame: np.ndarray) -> np.ndarray:
|
308
307
|
"""
|
309
308
|
Apply Sparse Optical Flow method to a raw frame.
|
310
309
|
|
@@ -312,7 +311,7 @@ class GMC:
|
|
312
311
|
raw_frame (np.ndarray): The raw frame to be processed, with shape (H, W, C).
|
313
312
|
|
314
313
|
Returns:
|
315
|
-
(np.ndarray):
|
314
|
+
(np.ndarray): Transformation matrix with shape (2, 3).
|
316
315
|
|
317
316
|
Examples:
|
318
317
|
>>> gmc = GMC()
|
@@ -355,7 +354,7 @@ class GMC:
|
|
355
354
|
currPoints = np.array(currPoints)
|
356
355
|
|
357
356
|
# Find rigid matrix
|
358
|
-
if (prevPoints.shape[0] > 4) and (prevPoints.shape[0] ==
|
357
|
+
if (prevPoints.shape[0] > 4) and (prevPoints.shape[0] == currPoints.shape[0]):
|
359
358
|
H, _ = cv2.estimateAffinePartial2D(prevPoints, currPoints, cv2.RANSAC)
|
360
359
|
|
361
360
|
if self.downscale > 1.0:
|
@@ -57,12 +57,11 @@ class KalmanFilterXYAH:
|
|
57
57
|
self._motion_mat[i, ndim + i] = dt
|
58
58
|
self._update_mat = np.eye(ndim, 2 * ndim)
|
59
59
|
|
60
|
-
# Motion and observation uncertainty are chosen relative to the current state estimate
|
61
|
-
# the amount of uncertainty in the model.
|
60
|
+
# Motion and observation uncertainty are chosen relative to the current state estimate
|
62
61
|
self._std_weight_position = 1.0 / 20
|
63
62
|
self._std_weight_velocity = 1.0 / 160
|
64
63
|
|
65
|
-
def initiate(self, measurement: np.ndarray)
|
64
|
+
def initiate(self, measurement: np.ndarray):
|
66
65
|
"""
|
67
66
|
Create a track from an unassociated measurement.
|
68
67
|
|
@@ -71,8 +70,8 @@ class KalmanFilterXYAH:
|
|
71
70
|
and height h.
|
72
71
|
|
73
72
|
Returns:
|
74
|
-
(
|
75
|
-
|
73
|
+
(np.ndarray): Mean vector (8-dimensional) of the new track. Unobserved velocities are initialized to 0 mean.
|
74
|
+
(np.ndarray): Covariance matrix (8x8 dimensional) of the new track.
|
76
75
|
|
77
76
|
Examples:
|
78
77
|
>>> kf = KalmanFilterXYAH()
|
@@ -96,7 +95,7 @@ class KalmanFilterXYAH:
|
|
96
95
|
covariance = np.diag(np.square(std))
|
97
96
|
return mean, covariance
|
98
97
|
|
99
|
-
def predict(self, mean: np.ndarray, covariance: np.ndarray)
|
98
|
+
def predict(self, mean: np.ndarray, covariance: np.ndarray):
|
100
99
|
"""
|
101
100
|
Run Kalman filter prediction step.
|
102
101
|
|
@@ -105,8 +104,8 @@ class KalmanFilterXYAH:
|
|
105
104
|
covariance (np.ndarray): The 8x8-dimensional covariance matrix of the object state at the previous time step.
|
106
105
|
|
107
106
|
Returns:
|
108
|
-
(
|
109
|
-
|
107
|
+
(np.ndarray): Mean vector of the predicted state. Unobserved velocities are initialized to 0 mean.
|
108
|
+
(np.ndarray): Covariance matrix of the predicted state.
|
110
109
|
|
111
110
|
Examples:
|
112
111
|
>>> kf = KalmanFilterXYAH()
|
@@ -133,7 +132,7 @@ class KalmanFilterXYAH:
|
|
133
132
|
|
134
133
|
return mean, covariance
|
135
134
|
|
136
|
-
def project(self, mean: np.ndarray, covariance: np.ndarray)
|
135
|
+
def project(self, mean: np.ndarray, covariance: np.ndarray):
|
137
136
|
"""
|
138
137
|
Project state distribution to measurement space.
|
139
138
|
|
@@ -142,7 +141,8 @@ class KalmanFilterXYAH:
|
|
142
141
|
covariance (np.ndarray): The state's covariance matrix (8x8 dimensional).
|
143
142
|
|
144
143
|
Returns:
|
145
|
-
(
|
144
|
+
(np.ndarray): Projected mean of the given state estimate.
|
145
|
+
(np.ndarray): Projected covariance matrix of the given state estimate.
|
146
146
|
|
147
147
|
Examples:
|
148
148
|
>>> kf = KalmanFilterXYAH()
|
@@ -162,7 +162,7 @@ class KalmanFilterXYAH:
|
|
162
162
|
covariance = np.linalg.multi_dot((self._update_mat, covariance, self._update_mat.T))
|
163
163
|
return mean, covariance + innovation_cov
|
164
164
|
|
165
|
-
def multi_predict(self, mean: np.ndarray, covariance: np.ndarray)
|
165
|
+
def multi_predict(self, mean: np.ndarray, covariance: np.ndarray):
|
166
166
|
"""
|
167
167
|
Run Kalman filter prediction step for multiple object states (Vectorized version).
|
168
168
|
|
@@ -171,9 +171,8 @@ class KalmanFilterXYAH:
|
|
171
171
|
covariance (np.ndarray): The Nx8x8 covariance matrix of the object states at the previous time step.
|
172
172
|
|
173
173
|
Returns:
|
174
|
-
(
|
175
|
-
|
176
|
-
are initialized to 0 mean.
|
174
|
+
(np.ndarray): Mean matrix of the predicted states with shape (N, 8).
|
175
|
+
(np.ndarray): Covariance matrix of the predicted states with shape (N, 8, 8).
|
177
176
|
|
178
177
|
Examples:
|
179
178
|
>>> mean = np.random.rand(10, 8) # 10 object states
|
@@ -203,7 +202,7 @@ class KalmanFilterXYAH:
|
|
203
202
|
|
204
203
|
return mean, covariance
|
205
204
|
|
206
|
-
def update(self, mean: np.ndarray, covariance: np.ndarray, measurement: np.ndarray)
|
205
|
+
def update(self, mean: np.ndarray, covariance: np.ndarray, measurement: np.ndarray):
|
207
206
|
"""
|
208
207
|
Run Kalman filter correction step.
|
209
208
|
|
@@ -214,7 +213,8 @@ class KalmanFilterXYAH:
|
|
214
213
|
position, a the aspect ratio, and h the height of the bounding box.
|
215
214
|
|
216
215
|
Returns:
|
217
|
-
(
|
216
|
+
(np.ndarray): Measurement-corrected state mean.
|
217
|
+
(np.ndarray): Measurement-corrected state covariance.
|
218
218
|
|
219
219
|
Examples:
|
220
220
|
>>> kf = KalmanFilterXYAH()
|
@@ -317,7 +317,7 @@ class KalmanFilterXYWH(KalmanFilterXYAH):
|
|
317
317
|
>>> print(covariance)
|
318
318
|
"""
|
319
319
|
|
320
|
-
def initiate(self, measurement: np.ndarray)
|
320
|
+
def initiate(self, measurement: np.ndarray):
|
321
321
|
"""
|
322
322
|
Create track from unassociated measurement.
|
323
323
|
|
@@ -325,8 +325,8 @@ class KalmanFilterXYWH(KalmanFilterXYAH):
|
|
325
325
|
measurement (np.ndarray): Bounding box coordinates (x, y, w, h) with center position (x, y), width, and height.
|
326
326
|
|
327
327
|
Returns:
|
328
|
-
(
|
329
|
-
|
328
|
+
(np.ndarray): Mean vector (8 dimensional) of the new track. Unobserved velocities are initialized to 0 mean.
|
329
|
+
(np.ndarray): Covariance matrix (8x8 dimensional) of the new track.
|
330
330
|
|
331
331
|
Examples:
|
332
332
|
>>> kf = KalmanFilterXYWH()
|
@@ -361,7 +361,7 @@ class KalmanFilterXYWH(KalmanFilterXYAH):
|
|
361
361
|
covariance = np.diag(np.square(std))
|
362
362
|
return mean, covariance
|
363
363
|
|
364
|
-
def predict(self, mean, covariance)
|
364
|
+
def predict(self, mean, covariance):
|
365
365
|
"""
|
366
366
|
Run Kalman filter prediction step.
|
367
367
|
|
@@ -370,8 +370,8 @@ class KalmanFilterXYWH(KalmanFilterXYAH):
|
|
370
370
|
covariance (np.ndarray): The 8x8-dimensional covariance matrix of the object state at the previous time step.
|
371
371
|
|
372
372
|
Returns:
|
373
|
-
(
|
374
|
-
|
373
|
+
(np.ndarray): Mean vector of the predicted state. Unobserved velocities are initialized to 0 mean.
|
374
|
+
(np.ndarray): Covariance matrix of the predicted state.
|
375
375
|
|
376
376
|
Examples:
|
377
377
|
>>> kf = KalmanFilterXYWH()
|
@@ -398,7 +398,7 @@ class KalmanFilterXYWH(KalmanFilterXYAH):
|
|
398
398
|
|
399
399
|
return mean, covariance
|
400
400
|
|
401
|
-
def project(self, mean, covariance)
|
401
|
+
def project(self, mean, covariance):
|
402
402
|
"""
|
403
403
|
Project state distribution to measurement space.
|
404
404
|
|
@@ -407,7 +407,8 @@ class KalmanFilterXYWH(KalmanFilterXYAH):
|
|
407
407
|
covariance (np.ndarray): The state's covariance matrix (8x8 dimensional).
|
408
408
|
|
409
409
|
Returns:
|
410
|
-
(
|
410
|
+
(np.ndarray): Projected mean of the given state estimate.
|
411
|
+
(np.ndarray): Projected covariance matrix of the given state estimate.
|
411
412
|
|
412
413
|
Examples:
|
413
414
|
>>> kf = KalmanFilterXYWH()
|
@@ -427,7 +428,7 @@ class KalmanFilterXYWH(KalmanFilterXYAH):
|
|
427
428
|
covariance = np.linalg.multi_dot((self._update_mat, covariance, self._update_mat.T))
|
428
429
|
return mean, covariance + innovation_cov
|
429
430
|
|
430
|
-
def multi_predict(self, mean, covariance)
|
431
|
+
def multi_predict(self, mean, covariance):
|
431
432
|
"""
|
432
433
|
Run Kalman filter prediction step (Vectorized version).
|
433
434
|
|
@@ -436,8 +437,8 @@ class KalmanFilterXYWH(KalmanFilterXYAH):
|
|
436
437
|
covariance (np.ndarray): The Nx8x8 covariance matrix of the object states at the previous time step.
|
437
438
|
|
438
439
|
Returns:
|
439
|
-
(
|
440
|
-
|
440
|
+
(np.ndarray): Mean matrix of the predicted states with shape (N, 8).
|
441
|
+
(np.ndarray): Covariance matrix of the predicted states with shape (N, 8, 8).
|
441
442
|
|
442
443
|
Examples:
|
443
444
|
>>> mean = np.random.rand(5, 8) # 5 objects with 8-dimensional state vectors
|
@@ -468,7 +469,7 @@ class KalmanFilterXYWH(KalmanFilterXYAH):
|
|
468
469
|
|
469
470
|
return mean, covariance
|
470
471
|
|
471
|
-
def update(self, mean, covariance, measurement)
|
472
|
+
def update(self, mean, covariance, measurement):
|
472
473
|
"""
|
473
474
|
Run Kalman filter correction step.
|
474
475
|
|
@@ -479,7 +480,8 @@ class KalmanFilterXYWH(KalmanFilterXYAH):
|
|
479
480
|
position, w the width, and h the height of the bounding box.
|
480
481
|
|
481
482
|
Returns:
|
482
|
-
(
|
483
|
+
(np.ndarray): Measurement-corrected state mean.
|
484
|
+
(np.ndarray): Measurement-corrected state covariance.
|
483
485
|
|
484
486
|
Examples:
|
485
487
|
>>> kf = KalmanFilterXYWH()
|
@@ -66,11 +66,11 @@ def iou_distance(atracks: list, btracks: list) -> np.ndarray:
|
|
66
66
|
Compute cost based on Intersection over Union (IoU) between tracks.
|
67
67
|
|
68
68
|
Args:
|
69
|
-
atracks (
|
70
|
-
btracks (
|
69
|
+
atracks (List[STrack] | List[np.ndarray]): List of tracks 'a' or bounding boxes.
|
70
|
+
btracks (List[STrack] | List[np.ndarray]): List of tracks 'b' or bounding boxes.
|
71
71
|
|
72
72
|
Returns:
|
73
|
-
(np.ndarray): Cost matrix computed based on IoU.
|
73
|
+
(np.ndarray): Cost matrix computed based on IoU with shape (len(atracks), len(btracks)).
|
74
74
|
|
75
75
|
Examples:
|
76
76
|
Compute IoU distance between two sets of tracks
|
@@ -106,8 +106,8 @@ def embedding_distance(tracks: list, detections: list, metric: str = "cosine") -
|
|
106
106
|
Compute distance between tracks and detections based on embeddings.
|
107
107
|
|
108
108
|
Args:
|
109
|
-
tracks (
|
110
|
-
detections (
|
109
|
+
tracks (List[STrack]): List of tracks, where each track contains embedding features.
|
110
|
+
detections (List[BaseTrack]): List of detections, where each detection contains embedding features.
|
111
111
|
metric (str): Metric for distance computation. Supported metrics include 'cosine', 'euclidean', etc.
|
112
112
|
|
113
113
|
Returns:
|
@@ -133,11 +133,11 @@ def embedding_distance(tracks: list, detections: list, metric: str = "cosine") -
|
|
133
133
|
|
134
134
|
def fuse_score(cost_matrix: np.ndarray, detections: list) -> np.ndarray:
|
135
135
|
"""
|
136
|
-
|
136
|
+
Fuse cost matrix with detection scores to produce a single similarity matrix.
|
137
137
|
|
138
138
|
Args:
|
139
139
|
cost_matrix (np.ndarray): The matrix containing cost values for assignments, with shape (N, M).
|
140
|
-
detections (
|
140
|
+
detections (List[BaseTrack]): List of detections, each containing a score attribute.
|
141
141
|
|
142
142
|
Returns:
|
143
143
|
(np.ndarray): Fused similarity matrix with shape (N, M).
|
ultralytics/utils/__init__.py
CHANGED
@@ -304,17 +304,24 @@ def plt_settings(rcparams=None, backend="Agg"):
|
|
304
304
|
"""
|
305
305
|
Decorator to temporarily set rc parameters and the backend for a plotting function.
|
306
306
|
|
307
|
-
Example:
|
308
|
-
decorator: @plt_settings({"font.size": 12})
|
309
|
-
context manager: with plt_settings({"font.size": 12}):
|
310
|
-
|
311
307
|
Args:
|
312
|
-
rcparams (dict): Dictionary of rc parameters to set.
|
308
|
+
rcparams (dict, optional): Dictionary of rc parameters to set.
|
313
309
|
backend (str, optional): Name of the backend to use. Defaults to 'Agg'.
|
314
310
|
|
315
311
|
Returns:
|
316
|
-
(Callable): Decorated function with temporarily set rc parameters and backend.
|
317
|
-
|
312
|
+
(Callable): Decorated function with temporarily set rc parameters and backend.
|
313
|
+
|
314
|
+
Examples:
|
315
|
+
>>> @plt_settings({"font.size": 12})
|
316
|
+
>>> def plot_function():
|
317
|
+
... plt.figure()
|
318
|
+
... plt.plot([1, 2, 3])
|
319
|
+
... plt.show()
|
320
|
+
|
321
|
+
>>> with plt_settings({"font.size": 12}):
|
322
|
+
... plt.figure()
|
323
|
+
... plt.plot([1, 2, 3])
|
324
|
+
... plt.show()
|
318
325
|
"""
|
319
326
|
if rcparams is None:
|
320
327
|
rcparams = {"font.size": 11}
|
@@ -357,6 +364,9 @@ def set_logging(name="LOGGING_NAME", verbose=True):
|
|
357
364
|
name (str): Name of the logger. Defaults to "LOGGING_NAME".
|
358
365
|
verbose (bool): Flag to set logging level to INFO if True, ERROR otherwise. Defaults to True.
|
359
366
|
|
367
|
+
Returns:
|
368
|
+
(logging.Logger): Configured logger object.
|
369
|
+
|
360
370
|
Examples:
|
361
371
|
>>> set_logging(name="ultralytics", verbose=True)
|
362
372
|
>>> logger = logging.getLogger("ultralytics")
|
@@ -376,7 +386,7 @@ def set_logging(name="LOGGING_NAME", verbose=True):
|
|
376
386
|
|
377
387
|
class CustomFormatter(logging.Formatter):
|
378
388
|
def format(self, record):
|
379
|
-
"""
|
389
|
+
"""Format log records with UTF-8 encoding for Windows compatibility."""
|
380
390
|
return emojis(super().format(record))
|
381
391
|
|
382
392
|
try:
|
@@ -420,9 +430,10 @@ def emojis(string=""):
|
|
420
430
|
|
421
431
|
class ThreadingLocked:
|
422
432
|
"""
|
423
|
-
A decorator class for ensuring thread-safe execution of a function or method.
|
424
|
-
|
425
|
-
to
|
433
|
+
A decorator class for ensuring thread-safe execution of a function or method.
|
434
|
+
|
435
|
+
This class can be used as a decorator to make sure that if the decorated function is called from multiple threads,
|
436
|
+
only one thread at a time will be able to execute the function.
|
426
437
|
|
427
438
|
Attributes:
|
428
439
|
lock (threading.Lock): A lock object used to manage access to the decorated function.
|
@@ -435,7 +446,7 @@ class ThreadingLocked:
|
|
435
446
|
"""
|
436
447
|
|
437
448
|
def __init__(self):
|
438
|
-
"""
|
449
|
+
"""Initialize the decorator class with a threading lock."""
|
439
450
|
self.lock = threading.Lock()
|
440
451
|
|
441
452
|
def __call__(self, f):
|
@@ -536,8 +547,7 @@ DEFAULT_CFG = IterableSimpleNamespace(**DEFAULT_CFG_DICT)
|
|
536
547
|
|
537
548
|
def read_device_model() -> str:
|
538
549
|
"""
|
539
|
-
Reads the device model information from the system and caches it for quick access.
|
540
|
-
is_raspberrypi().
|
550
|
+
Reads the device model information from the system and caches it for quick access.
|
541
551
|
|
542
552
|
Returns:
|
543
553
|
(str): Kernel release information.
|
@@ -619,7 +629,7 @@ def is_docker() -> bool:
|
|
619
629
|
|
620
630
|
def is_raspberrypi() -> bool:
|
621
631
|
"""
|
622
|
-
Determines if the Python environment is running on a Raspberry Pi
|
632
|
+
Determines if the Python environment is running on a Raspberry Pi.
|
623
633
|
|
624
634
|
Returns:
|
625
635
|
(bool): True if running on a Raspberry Pi, False otherwise.
|
@@ -629,7 +639,7 @@ def is_raspberrypi() -> bool:
|
|
629
639
|
|
630
640
|
def is_jetson() -> bool:
|
631
641
|
"""
|
632
|
-
Determines if the Python environment is running on an NVIDIA Jetson device
|
642
|
+
Determines if the Python environment is running on an NVIDIA Jetson device.
|
633
643
|
|
634
644
|
Returns:
|
635
645
|
(bool): True if running on an NVIDIA Jetson device, False otherwise.
|
@@ -709,8 +719,7 @@ def is_github_action_running() -> bool:
|
|
709
719
|
|
710
720
|
def get_git_dir():
|
711
721
|
"""
|
712
|
-
Determines whether the current file is part of a git repository and if so, returns the repository root directory.
|
713
|
-
the current file is not part of a git repository, returns None.
|
722
|
+
Determines whether the current file is part of a git repository and if so, returns the repository root directory.
|
714
723
|
|
715
724
|
Returns:
|
716
725
|
(Path | None): Git root directory if found or None if not found.
|
@@ -722,8 +731,7 @@ def get_git_dir():
|
|
722
731
|
|
723
732
|
def is_git_dir():
|
724
733
|
"""
|
725
|
-
Determines whether the current file is part of a git repository.
|
726
|
-
repository, returns None.
|
734
|
+
Determines whether the current file is part of a git repository.
|
727
735
|
|
728
736
|
Returns:
|
729
737
|
(bool): True if current file is part of a git repository.
|
@@ -1004,8 +1012,10 @@ def threaded(func):
|
|
1004
1012
|
|
1005
1013
|
def set_sentry():
|
1006
1014
|
"""
|
1007
|
-
Initialize the Sentry SDK for error tracking and reporting.
|
1008
|
-
|
1015
|
+
Initialize the Sentry SDK for error tracking and reporting.
|
1016
|
+
|
1017
|
+
Only used if sentry_sdk package is installed and sync=True in settings. Run 'yolo settings' to see and update
|
1018
|
+
settings.
|
1009
1019
|
|
1010
1020
|
Conditions required to send errors (ALL conditions must be met or no errors will be reported):
|
1011
1021
|
- sentry_sdk package is installed
|
@@ -1016,11 +1026,6 @@ def set_sentry():
|
|
1016
1026
|
- running with rank -1 or 0
|
1017
1027
|
- online environment
|
1018
1028
|
- CLI used to run package (checked with 'yolo' as the name of the main CLI command)
|
1019
|
-
|
1020
|
-
The function also configures Sentry SDK to ignore KeyboardInterrupt and FileNotFoundError exceptions and to exclude
|
1021
|
-
events with 'out of memory' in their exception message.
|
1022
|
-
|
1023
|
-
Additionally, the function sets custom tags and user information for Sentry events.
|
1024
1029
|
"""
|
1025
1030
|
if (
|
1026
1031
|
not SETTINGS["sync"]
|
ultralytics/utils/autobatch.py
CHANGED
@@ -25,7 +25,7 @@ def check_train_batch_size(model, imgsz=640, amp=True, batch=-1, max_num_obj=1):
|
|
25
25
|
Returns:
|
26
26
|
(int): Optimal batch size computed using the autobatch() function.
|
27
27
|
|
28
|
-
|
28
|
+
Notes:
|
29
29
|
If 0.0 < batch < 1.0, it's used as the fraction of GPU memory to use.
|
30
30
|
Otherwise, a default fraction of 0.6 is used.
|
31
31
|
"""
|
@@ -40,10 +40,10 @@ def autobatch(model, imgsz=640, fraction=0.60, batch_size=DEFAULT_CFG.batch, max
|
|
40
40
|
Automatically estimate the best YOLO batch size to use a fraction of the available CUDA memory.
|
41
41
|
|
42
42
|
Args:
|
43
|
-
model (torch.nn.
|
44
|
-
imgsz (int, optional): The image size used as input for the YOLO model.
|
45
|
-
fraction (float, optional): The fraction of available CUDA memory to use.
|
46
|
-
batch_size (int, optional): The default batch size to use if an error is detected.
|
43
|
+
model (torch.nn.Module): YOLO model to compute batch size for.
|
44
|
+
imgsz (int, optional): The image size used as input for the YOLO model.
|
45
|
+
fraction (float, optional): The fraction of available CUDA memory to use.
|
46
|
+
batch_size (int, optional): The default batch size to use if an error is detected.
|
47
47
|
max_num_obj (int, optional): The maximum number of objects from dataset.
|
48
48
|
|
49
49
|
Returns:
|