ultralytics 8.1.15__py3-none-any.whl → 8.1.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 +1 -1
- ultralytics/cfg/default.yaml +1 -1
- ultralytics/data/converter.py +2 -2
- ultralytics/engine/model.py +83 -33
- ultralytics/models/yolo/detect/val.py +2 -4
- ultralytics/models/yolo/obb/val.py +5 -4
- ultralytics/nn/tasks.py +4 -0
- ultralytics/trackers/utils/gmc.py +10 -10
- ultralytics/utils/downloads.py +1 -0
- ultralytics/utils/metrics.py +14 -8
- ultralytics/utils/plotting.py +1 -1
- {ultralytics-8.1.15.dist-info → ultralytics-8.1.16.dist-info}/METADATA +1 -1
- {ultralytics-8.1.15.dist-info → ultralytics-8.1.16.dist-info}/RECORD +17 -17
- {ultralytics-8.1.15.dist-info → ultralytics-8.1.16.dist-info}/LICENSE +0 -0
- {ultralytics-8.1.15.dist-info → ultralytics-8.1.16.dist-info}/WHEEL +0 -0
- {ultralytics-8.1.15.dist-info → ultralytics-8.1.16.dist-info}/entry_points.txt +0 -0
- {ultralytics-8.1.15.dist-info → ultralytics-8.1.16.dist-info}/top_level.txt +0 -0
ultralytics/__init__.py
CHANGED
ultralytics/cfg/default.yaml
CHANGED
|
@@ -9,7 +9,7 @@ model: # (str, optional) path to model file, i.e. yolov8n.pt, yolov8n.yaml
|
|
|
9
9
|
data: # (str, optional) path to data file, i.e. coco128.yaml
|
|
10
10
|
epochs: 100 # (int) number of epochs to train for
|
|
11
11
|
time: # (float, optional) number of hours to train for, overrides epochs if supplied
|
|
12
|
-
patience:
|
|
12
|
+
patience: 100 # (int) epochs to wait for no observable improvement for early stopping of training
|
|
13
13
|
batch: 16 # (int) number of images per batch (-1 for AutoBatch)
|
|
14
14
|
imgsz: 640 # (int | list) input images size as int for train and val modes, or list[w,h] for predict and export modes
|
|
15
15
|
save: True # (bool) save train checkpoints and predict results
|
ultralytics/data/converter.py
CHANGED
|
@@ -418,8 +418,8 @@ def min_index(arr1, arr2):
|
|
|
418
418
|
Find a pair of indexes with the shortest distance between two arrays of 2D points.
|
|
419
419
|
|
|
420
420
|
Args:
|
|
421
|
-
arr1 (np.
|
|
422
|
-
arr2 (np.
|
|
421
|
+
arr1 (np.ndarray): A NumPy array of shape (N, 2) representing N 2D points.
|
|
422
|
+
arr2 (np.ndarray): A NumPy array of shape (M, 2) representing M 2D points.
|
|
423
423
|
|
|
424
424
|
Returns:
|
|
425
425
|
(tuple): A tuple containing the indexes of the points with the shortest distance in arr1 and arr2 respectively.
|
ultralytics/engine/model.py
CHANGED
|
@@ -5,6 +5,10 @@ import sys
|
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from typing import Union
|
|
7
7
|
|
|
8
|
+
import PIL
|
|
9
|
+
import numpy as np
|
|
10
|
+
import torch
|
|
11
|
+
|
|
8
12
|
from ultralytics.cfg import TASK2DATA, get_cfg, get_save_dir
|
|
9
13
|
from ultralytics.hub.utils import HUB_WEB_ROOT
|
|
10
14
|
from ultralytics.nn.tasks import attempt_load_one_weight, guess_model_task, nn, yaml_model_load
|
|
@@ -78,7 +82,12 @@ class Model(nn.Module):
|
|
|
78
82
|
NotImplementedError: If a specific model task or mode is not supported.
|
|
79
83
|
"""
|
|
80
84
|
|
|
81
|
-
def __init__(
|
|
85
|
+
def __init__(
|
|
86
|
+
self,
|
|
87
|
+
model: Union[str, Path] = "yolov8n.pt",
|
|
88
|
+
task: str = None,
|
|
89
|
+
verbose: bool = False,
|
|
90
|
+
) -> None:
|
|
82
91
|
"""
|
|
83
92
|
Initializes a new instance of the YOLO model class.
|
|
84
93
|
|
|
@@ -135,7 +144,12 @@ class Model(nn.Module):
|
|
|
135
144
|
|
|
136
145
|
self.model_name = model
|
|
137
146
|
|
|
138
|
-
def __call__(
|
|
147
|
+
def __call__(
|
|
148
|
+
self,
|
|
149
|
+
source: Union[str, Path, int, list, tuple, PIL.Image.Image, np.ndarray, torch.Tensor] = None,
|
|
150
|
+
stream: bool = False,
|
|
151
|
+
**kwargs,
|
|
152
|
+
) -> list:
|
|
139
153
|
"""
|
|
140
154
|
An alias for the predict method, enabling the model instance to be callable.
|
|
141
155
|
|
|
@@ -143,8 +157,9 @@ class Model(nn.Module):
|
|
|
143
157
|
with the required arguments for prediction.
|
|
144
158
|
|
|
145
159
|
Args:
|
|
146
|
-
source (str | int | PIL.Image | np.ndarray, optional): The source of the image for making
|
|
147
|
-
Accepts various types, including file paths, URLs, PIL images, and numpy arrays.
|
|
160
|
+
source (str | Path | int | PIL.Image | np.ndarray, optional): The source of the image for making
|
|
161
|
+
predictions. Accepts various types, including file paths, URLs, PIL images, and numpy arrays.
|
|
162
|
+
Defaults to None.
|
|
148
163
|
stream (bool, optional): If True, treats the input source as a continuous stream for predictions.
|
|
149
164
|
Defaults to False.
|
|
150
165
|
**kwargs (dict): Additional keyword arguments for configuring the prediction process.
|
|
@@ -163,7 +178,7 @@ class Model(nn.Module):
|
|
|
163
178
|
return session if session.client.authenticated else None
|
|
164
179
|
|
|
165
180
|
@staticmethod
|
|
166
|
-
def is_triton_model(model):
|
|
181
|
+
def is_triton_model(model: str) -> bool:
|
|
167
182
|
"""Is model a Triton Server URL string, i.e. <scheme>://<netloc>/<endpoint>/<task_name>"""
|
|
168
183
|
from urllib.parse import urlsplit
|
|
169
184
|
|
|
@@ -171,7 +186,7 @@ class Model(nn.Module):
|
|
|
171
186
|
return url.netloc and url.path and url.scheme in {"http", "grpc"}
|
|
172
187
|
|
|
173
188
|
@staticmethod
|
|
174
|
-
def is_hub_model(model):
|
|
189
|
+
def is_hub_model(model: str) -> bool:
|
|
175
190
|
"""Check if the provided model is a HUB model."""
|
|
176
191
|
return any(
|
|
177
192
|
(
|
|
@@ -181,7 +196,7 @@ class Model(nn.Module):
|
|
|
181
196
|
)
|
|
182
197
|
)
|
|
183
198
|
|
|
184
|
-
def _new(self, cfg: str, task=None, model=None, verbose=False):
|
|
199
|
+
def _new(self, cfg: str, task=None, model=None, verbose=False) -> None:
|
|
185
200
|
"""
|
|
186
201
|
Initializes a new model and infers the task type from the model definitions.
|
|
187
202
|
|
|
@@ -202,7 +217,7 @@ class Model(nn.Module):
|
|
|
202
217
|
self.model.args = {**DEFAULT_CFG_DICT, **self.overrides} # combine default and model args (prefer model args)
|
|
203
218
|
self.model.task = self.task
|
|
204
219
|
|
|
205
|
-
def _load(self, weights: str, task=None):
|
|
220
|
+
def _load(self, weights: str, task=None) -> None:
|
|
206
221
|
"""
|
|
207
222
|
Initializes a new model and infers the task type from the model head.
|
|
208
223
|
|
|
@@ -224,7 +239,7 @@ class Model(nn.Module):
|
|
|
224
239
|
self.overrides["model"] = weights
|
|
225
240
|
self.overrides["task"] = self.task
|
|
226
241
|
|
|
227
|
-
def _check_is_pytorch_model(self):
|
|
242
|
+
def _check_is_pytorch_model(self) -> None:
|
|
228
243
|
"""Raises TypeError is model is not a PyTorch model."""
|
|
229
244
|
pt_str = isinstance(self.model, (str, Path)) and Path(self.model).suffix == ".pt"
|
|
230
245
|
pt_module = isinstance(self.model, nn.Module)
|
|
@@ -237,7 +252,7 @@ class Model(nn.Module):
|
|
|
237
252
|
f"argument directly in your inference command, i.e. 'model.predict(source=..., device=0)'"
|
|
238
253
|
)
|
|
239
254
|
|
|
240
|
-
def reset_weights(self):
|
|
255
|
+
def reset_weights(self) -> "Model":
|
|
241
256
|
"""
|
|
242
257
|
Resets the model parameters to randomly initialized values, effectively discarding all training information.
|
|
243
258
|
|
|
@@ -259,7 +274,7 @@ class Model(nn.Module):
|
|
|
259
274
|
p.requires_grad = True
|
|
260
275
|
return self
|
|
261
276
|
|
|
262
|
-
def load(self, weights="yolov8n.pt"):
|
|
277
|
+
def load(self, weights: Union[str, Path] = "yolov8n.pt") -> "Model":
|
|
263
278
|
"""
|
|
264
279
|
Loads parameters from the specified weights file into the model.
|
|
265
280
|
|
|
@@ -281,24 +296,22 @@ class Model(nn.Module):
|
|
|
281
296
|
self.model.load(weights)
|
|
282
297
|
return self
|
|
283
298
|
|
|
284
|
-
def save(self, filename="
|
|
299
|
+
def save(self, filename: Union[str, Path] = "saved_model.pt") -> None:
|
|
285
300
|
"""
|
|
286
301
|
Saves the current model state to a file.
|
|
287
302
|
|
|
288
303
|
This method exports the model's checkpoint (ckpt) to the specified filename.
|
|
289
304
|
|
|
290
305
|
Args:
|
|
291
|
-
filename (str): The name of the file to save the model to. Defaults to '
|
|
306
|
+
filename (str | Path): The name of the file to save the model to. Defaults to 'saved_model.pt'.
|
|
292
307
|
|
|
293
308
|
Raises:
|
|
294
309
|
AssertionError: If the model is not a PyTorch model.
|
|
295
310
|
"""
|
|
296
311
|
self._check_is_pytorch_model()
|
|
297
|
-
import torch
|
|
298
|
-
|
|
299
312
|
torch.save(self.ckpt, filename)
|
|
300
313
|
|
|
301
|
-
def info(self, detailed=False, verbose=True):
|
|
314
|
+
def info(self, detailed: bool = False, verbose: bool = True):
|
|
302
315
|
"""
|
|
303
316
|
Logs or returns model information.
|
|
304
317
|
|
|
@@ -330,7 +343,12 @@ class Model(nn.Module):
|
|
|
330
343
|
self._check_is_pytorch_model()
|
|
331
344
|
self.model.fuse()
|
|
332
345
|
|
|
333
|
-
def embed(
|
|
346
|
+
def embed(
|
|
347
|
+
self,
|
|
348
|
+
source: Union[str, Path, int, list, tuple, PIL.Image.Image, np.ndarray, torch.Tensor] = None,
|
|
349
|
+
stream: bool = False,
|
|
350
|
+
**kwargs,
|
|
351
|
+
) -> list:
|
|
334
352
|
"""
|
|
335
353
|
Generates image embeddings based on the provided source.
|
|
336
354
|
|
|
@@ -353,7 +371,13 @@ class Model(nn.Module):
|
|
|
353
371
|
kwargs["embed"] = [len(self.model.model) - 2] # embed second-to-last layer if no indices passed
|
|
354
372
|
return self.predict(source, stream, **kwargs)
|
|
355
373
|
|
|
356
|
-
def predict(
|
|
374
|
+
def predict(
|
|
375
|
+
self,
|
|
376
|
+
source: Union[str, Path, int, list, tuple, PIL.Image.Image, np.ndarray, torch.Tensor] = None,
|
|
377
|
+
stream: bool = False,
|
|
378
|
+
predictor=None,
|
|
379
|
+
**kwargs,
|
|
380
|
+
) -> list:
|
|
357
381
|
"""
|
|
358
382
|
Performs predictions on the given image source using the YOLO model.
|
|
359
383
|
|
|
@@ -405,7 +429,13 @@ class Model(nn.Module):
|
|
|
405
429
|
self.predictor.set_prompts(prompts)
|
|
406
430
|
return self.predictor.predict_cli(source=source) if is_cli else self.predictor(source=source, stream=stream)
|
|
407
431
|
|
|
408
|
-
def track(
|
|
432
|
+
def track(
|
|
433
|
+
self,
|
|
434
|
+
source: Union[str, Path, int, list, tuple, PIL.Image.Image, np.ndarray, torch.Tensor] = None,
|
|
435
|
+
stream: bool = False,
|
|
436
|
+
persist: bool = False,
|
|
437
|
+
**kwargs,
|
|
438
|
+
) -> list:
|
|
409
439
|
"""
|
|
410
440
|
Conducts object tracking on the specified input source using the registered trackers.
|
|
411
441
|
|
|
@@ -438,7 +468,11 @@ class Model(nn.Module):
|
|
|
438
468
|
kwargs["mode"] = "track"
|
|
439
469
|
return self.predict(source=source, stream=stream, **kwargs)
|
|
440
470
|
|
|
441
|
-
def val(
|
|
471
|
+
def val(
|
|
472
|
+
self,
|
|
473
|
+
validator=None,
|
|
474
|
+
**kwargs,
|
|
475
|
+
):
|
|
442
476
|
"""
|
|
443
477
|
Validates the model using a specified dataset and validation configuration.
|
|
444
478
|
|
|
@@ -471,7 +505,10 @@ class Model(nn.Module):
|
|
|
471
505
|
self.metrics = validator.metrics
|
|
472
506
|
return validator.metrics
|
|
473
507
|
|
|
474
|
-
def benchmark(
|
|
508
|
+
def benchmark(
|
|
509
|
+
self,
|
|
510
|
+
**kwargs,
|
|
511
|
+
):
|
|
475
512
|
"""
|
|
476
513
|
Benchmarks the model across various export formats to evaluate performance.
|
|
477
514
|
|
|
@@ -509,7 +546,10 @@ class Model(nn.Module):
|
|
|
509
546
|
verbose=kwargs.get("verbose"),
|
|
510
547
|
)
|
|
511
548
|
|
|
512
|
-
def export(
|
|
549
|
+
def export(
|
|
550
|
+
self,
|
|
551
|
+
**kwargs,
|
|
552
|
+
):
|
|
513
553
|
"""
|
|
514
554
|
Exports the model to a different format suitable for deployment.
|
|
515
555
|
|
|
@@ -537,7 +577,11 @@ class Model(nn.Module):
|
|
|
537
577
|
args = {**self.overrides, **custom, **kwargs, "mode": "export"} # highest priority args on the right
|
|
538
578
|
return Exporter(overrides=args, _callbacks=self.callbacks)(model=self.model)
|
|
539
579
|
|
|
540
|
-
def train(
|
|
580
|
+
def train(
|
|
581
|
+
self,
|
|
582
|
+
trainer=None,
|
|
583
|
+
**kwargs,
|
|
584
|
+
):
|
|
541
585
|
"""
|
|
542
586
|
Trains the model using the specified dataset and training configuration.
|
|
543
587
|
|
|
@@ -607,7 +651,13 @@ class Model(nn.Module):
|
|
|
607
651
|
self.metrics = getattr(self.trainer.validator, "metrics", None) # TODO: no metrics returned by DDP
|
|
608
652
|
return self.metrics
|
|
609
653
|
|
|
610
|
-
def tune(
|
|
654
|
+
def tune(
|
|
655
|
+
self,
|
|
656
|
+
use_ray=False,
|
|
657
|
+
iterations=10,
|
|
658
|
+
*args,
|
|
659
|
+
**kwargs,
|
|
660
|
+
):
|
|
611
661
|
"""
|
|
612
662
|
Conducts hyperparameter tuning for the model, with an option to use Ray Tune.
|
|
613
663
|
|
|
@@ -640,7 +690,7 @@ class Model(nn.Module):
|
|
|
640
690
|
args = {**self.overrides, **custom, **kwargs, "mode": "train"} # highest priority args on the right
|
|
641
691
|
return Tuner(args=args, _callbacks=self.callbacks)(model=self, iterations=iterations)
|
|
642
692
|
|
|
643
|
-
def _apply(self, fn):
|
|
693
|
+
def _apply(self, fn) -> "Model":
|
|
644
694
|
"""Apply to(), cpu(), cuda(), half(), float() to model tensors that are not parameters or registered buffers."""
|
|
645
695
|
self._check_is_pytorch_model()
|
|
646
696
|
self = super()._apply(fn) # noqa
|
|
@@ -649,7 +699,7 @@ class Model(nn.Module):
|
|
|
649
699
|
return self
|
|
650
700
|
|
|
651
701
|
@property
|
|
652
|
-
def names(self):
|
|
702
|
+
def names(self) -> list:
|
|
653
703
|
"""
|
|
654
704
|
Retrieves the class names associated with the loaded model.
|
|
655
705
|
|
|
@@ -664,7 +714,7 @@ class Model(nn.Module):
|
|
|
664
714
|
return check_class_names(self.model.names) if hasattr(self.model, "names") else None
|
|
665
715
|
|
|
666
716
|
@property
|
|
667
|
-
def device(self):
|
|
717
|
+
def device(self) -> torch.device:
|
|
668
718
|
"""
|
|
669
719
|
Retrieves the device on which the model's parameters are allocated.
|
|
670
720
|
|
|
@@ -688,7 +738,7 @@ class Model(nn.Module):
|
|
|
688
738
|
"""
|
|
689
739
|
return self.model.transforms if hasattr(self.model, "transforms") else None
|
|
690
740
|
|
|
691
|
-
def add_callback(self, event: str, func):
|
|
741
|
+
def add_callback(self, event: str, func) -> None:
|
|
692
742
|
"""
|
|
693
743
|
Adds a callback function for a specified event.
|
|
694
744
|
|
|
@@ -704,7 +754,7 @@ class Model(nn.Module):
|
|
|
704
754
|
"""
|
|
705
755
|
self.callbacks[event].append(func)
|
|
706
756
|
|
|
707
|
-
def clear_callback(self, event: str):
|
|
757
|
+
def clear_callback(self, event: str) -> None:
|
|
708
758
|
"""
|
|
709
759
|
Clears all callback functions registered for a specified event.
|
|
710
760
|
|
|
@@ -718,7 +768,7 @@ class Model(nn.Module):
|
|
|
718
768
|
"""
|
|
719
769
|
self.callbacks[event] = []
|
|
720
770
|
|
|
721
|
-
def reset_callbacks(self):
|
|
771
|
+
def reset_callbacks(self) -> None:
|
|
722
772
|
"""
|
|
723
773
|
Resets all callbacks to their default functions.
|
|
724
774
|
|
|
@@ -729,7 +779,7 @@ class Model(nn.Module):
|
|
|
729
779
|
self.callbacks[event] = [callbacks.default_callbacks[event][0]]
|
|
730
780
|
|
|
731
781
|
@staticmethod
|
|
732
|
-
def _reset_ckpt_args(args):
|
|
782
|
+
def _reset_ckpt_args(args: dict) -> dict:
|
|
733
783
|
"""Reset arguments when loading a PyTorch model."""
|
|
734
784
|
include = {"imgsz", "data", "task", "single_cls"} # only remember these arguments when loading a PyTorch model
|
|
735
785
|
return {k: v for k, v in args.items() if k in include}
|
|
@@ -739,7 +789,7 @@ class Model(nn.Module):
|
|
|
739
789
|
# name = self.__class__.__name__
|
|
740
790
|
# raise AttributeError(f"'{name}' object has no attribute '{attr}'. See valid attributes below.\n{self.__doc__}")
|
|
741
791
|
|
|
742
|
-
def _smart_load(self, key):
|
|
792
|
+
def _smart_load(self, key: str):
|
|
743
793
|
"""Load model/trainer/validator/predictor."""
|
|
744
794
|
try:
|
|
745
795
|
return self.task_map[self.task][key]
|
|
@@ -751,7 +801,7 @@ class Model(nn.Module):
|
|
|
751
801
|
) from e
|
|
752
802
|
|
|
753
803
|
@property
|
|
754
|
-
def task_map(self):
|
|
804
|
+
def task_map(self) -> dict:
|
|
755
805
|
"""
|
|
756
806
|
Map head to model, trainer, validator, and predictor classes.
|
|
757
807
|
|
|
@@ -132,8 +132,7 @@ class DetectionValidator(BaseValidator):
|
|
|
132
132
|
if nl:
|
|
133
133
|
for k in self.stats.keys():
|
|
134
134
|
self.stats[k].append(stat[k])
|
|
135
|
-
|
|
136
|
-
if self.args.plots and self.args.task != "obb":
|
|
135
|
+
if self.args.plots:
|
|
137
136
|
self.confusion_matrix.process_batch(detections=None, gt_bboxes=bbox, gt_cls=cls)
|
|
138
137
|
continue
|
|
139
138
|
|
|
@@ -147,8 +146,7 @@ class DetectionValidator(BaseValidator):
|
|
|
147
146
|
# Evaluate
|
|
148
147
|
if nl:
|
|
149
148
|
stat["tp"] = self._process_batch(predn, bbox, cls)
|
|
150
|
-
|
|
151
|
-
if self.args.plots and self.args.task != "obb":
|
|
149
|
+
if self.args.plots:
|
|
152
150
|
self.confusion_matrix.process_batch(predn, bbox, cls)
|
|
153
151
|
for k in self.stats.keys():
|
|
154
152
|
self.stats[k].append(stat[k])
|
|
@@ -55,10 +55,11 @@ class OBBValidator(DetectionValidator):
|
|
|
55
55
|
Return correct prediction matrix.
|
|
56
56
|
|
|
57
57
|
Args:
|
|
58
|
-
detections (torch.Tensor): Tensor of shape [N,
|
|
59
|
-
Each detection is of the format: x1, y1, x2, y2, conf, class.
|
|
60
|
-
|
|
61
|
-
Each
|
|
58
|
+
detections (torch.Tensor): Tensor of shape [N, 7] representing detections.
|
|
59
|
+
Each detection is of the format: x1, y1, x2, y2, conf, class, angle.
|
|
60
|
+
gt_bboxes (torch.Tensor): Tensor of shape [M, 5] representing rotated boxes.
|
|
61
|
+
Each box is of the format: x1, y1, x2, y2, angle.
|
|
62
|
+
labels (torch.Tensor): Tensor of shape [M] representing labels.
|
|
62
63
|
|
|
63
64
|
Returns:
|
|
64
65
|
(torch.Tensor): Correct prediction matrix of shape [N, 10] for 10 IoU levels.
|
ultralytics/nn/tasks.py
CHANGED
|
@@ -761,6 +761,8 @@ def attempt_load_weights(weights, device=None, inplace=True, fuse=False):
|
|
|
761
761
|
for m in ensemble.modules():
|
|
762
762
|
if hasattr(m, "inplace"):
|
|
763
763
|
m.inplace = inplace
|
|
764
|
+
elif isinstance(m, nn.Upsample) and not hasattr(m, "recompute_scale_factor"):
|
|
765
|
+
m.recompute_scale_factor = None # torch 1.11.0 compatibility
|
|
764
766
|
|
|
765
767
|
# Return model
|
|
766
768
|
if len(ensemble) == 1:
|
|
@@ -794,6 +796,8 @@ def attempt_load_one_weight(weight, device=None, inplace=True, fuse=False):
|
|
|
794
796
|
for m in model.modules():
|
|
795
797
|
if hasattr(m, "inplace"):
|
|
796
798
|
m.inplace = inplace
|
|
799
|
+
elif isinstance(m, nn.Upsample) and not hasattr(m, "recompute_scale_factor"):
|
|
800
|
+
m.recompute_scale_factor = None # torch 1.11.0 compatibility
|
|
797
801
|
|
|
798
802
|
# Return model and ckpt
|
|
799
803
|
return model, ckpt
|
|
@@ -18,9 +18,9 @@ class GMC:
|
|
|
18
18
|
Attributes:
|
|
19
19
|
method (str): The method used for tracking. Options include 'orb', 'sift', 'ecc', 'sparseOptFlow', 'none'.
|
|
20
20
|
downscale (int): Factor by which to downscale the frames for processing.
|
|
21
|
-
prevFrame (np.
|
|
21
|
+
prevFrame (np.ndarray): Stores the previous frame for tracking.
|
|
22
22
|
prevKeyPoints (list): Stores the keypoints from the previous frame.
|
|
23
|
-
prevDescriptors (np.
|
|
23
|
+
prevDescriptors (np.ndarray): Stores the descriptors from the previous frame.
|
|
24
24
|
initializedFirstFrame (bool): Flag to indicate if the first frame has been processed.
|
|
25
25
|
|
|
26
26
|
Methods:
|
|
@@ -82,11 +82,11 @@ class GMC:
|
|
|
82
82
|
Apply object detection on a raw frame using specified method.
|
|
83
83
|
|
|
84
84
|
Args:
|
|
85
|
-
raw_frame (np.
|
|
85
|
+
raw_frame (np.ndarray): The raw frame to be processed.
|
|
86
86
|
detections (list): List of detections to be used in the processing.
|
|
87
87
|
|
|
88
88
|
Returns:
|
|
89
|
-
(np.
|
|
89
|
+
(np.ndarray): Processed frame.
|
|
90
90
|
|
|
91
91
|
Examples:
|
|
92
92
|
>>> gmc = GMC()
|
|
@@ -108,10 +108,10 @@ class GMC:
|
|
|
108
108
|
Apply ECC algorithm to a raw frame.
|
|
109
109
|
|
|
110
110
|
Args:
|
|
111
|
-
raw_frame (np.
|
|
111
|
+
raw_frame (np.ndarray): The raw frame to be processed.
|
|
112
112
|
|
|
113
113
|
Returns:
|
|
114
|
-
(np.
|
|
114
|
+
(np.ndarray): Processed frame.
|
|
115
115
|
|
|
116
116
|
Examples:
|
|
117
117
|
>>> gmc = GMC()
|
|
@@ -154,11 +154,11 @@ class GMC:
|
|
|
154
154
|
Apply feature-based methods like ORB or SIFT to a raw frame.
|
|
155
155
|
|
|
156
156
|
Args:
|
|
157
|
-
raw_frame (np.
|
|
157
|
+
raw_frame (np.ndarray): The raw frame to be processed.
|
|
158
158
|
detections (list): List of detections to be used in the processing.
|
|
159
159
|
|
|
160
160
|
Returns:
|
|
161
|
-
(np.
|
|
161
|
+
(np.ndarray): Processed frame.
|
|
162
162
|
|
|
163
163
|
Examples:
|
|
164
164
|
>>> gmc = GMC()
|
|
@@ -296,10 +296,10 @@ class GMC:
|
|
|
296
296
|
Apply Sparse Optical Flow method to a raw frame.
|
|
297
297
|
|
|
298
298
|
Args:
|
|
299
|
-
raw_frame (np.
|
|
299
|
+
raw_frame (np.ndarray): The raw frame to be processed.
|
|
300
300
|
|
|
301
301
|
Returns:
|
|
302
|
-
(np.
|
|
302
|
+
(np.ndarray): Processed frame.
|
|
303
303
|
|
|
304
304
|
Examples:
|
|
305
305
|
>>> gmc = GMC()
|
ultralytics/utils/downloads.py
CHANGED
|
@@ -26,6 +26,7 @@ GITHUB_ASSETS_NAMES = (
|
|
|
26
26
|
+ [f"FastSAM-{k}.pt" for k in "sx"]
|
|
27
27
|
+ [f"rtdetr-{k}.pt" for k in "lx"]
|
|
28
28
|
+ ["mobile_sam.pt"]
|
|
29
|
+
+ ["calibration_image_sample_data_20x128x128x3_float32.npy.zip"]
|
|
29
30
|
)
|
|
30
31
|
GITHUB_ASSETS_STEMS = [Path(k).stem for k in GITHUB_ASSETS_NAMES]
|
|
31
32
|
|
ultralytics/utils/metrics.py
CHANGED
|
@@ -22,13 +22,13 @@ def bbox_ioa(box1, box2, iou=False, eps=1e-7):
|
|
|
22
22
|
Calculate the intersection over box2 area given box1 and box2. Boxes are in x1y1x2y2 format.
|
|
23
23
|
|
|
24
24
|
Args:
|
|
25
|
-
box1 (np.
|
|
26
|
-
box2 (np.
|
|
25
|
+
box1 (np.ndarray): A numpy array of shape (n, 4) representing n bounding boxes.
|
|
26
|
+
box2 (np.ndarray): A numpy array of shape (m, 4) representing m bounding boxes.
|
|
27
27
|
iou (bool): Calculate the standard iou if True else return inter_area/box2_area.
|
|
28
28
|
eps (float, optional): A small value to avoid division by zero. Defaults to 1e-7.
|
|
29
29
|
|
|
30
30
|
Returns:
|
|
31
|
-
(np.
|
|
31
|
+
(np.ndarray): A numpy array of shape (n, m) representing the intersection over box2 area.
|
|
32
32
|
"""
|
|
33
33
|
|
|
34
34
|
# Get the coordinates of bounding boxes
|
|
@@ -295,7 +295,7 @@ class ConfusionMatrix:
|
|
|
295
295
|
|
|
296
296
|
Attributes:
|
|
297
297
|
task (str): The type of task, either 'detect' or 'classify'.
|
|
298
|
-
matrix (np.
|
|
298
|
+
matrix (np.ndarray): The confusion matrix, with dimensions depending on the task.
|
|
299
299
|
nc (int): The number of classes.
|
|
300
300
|
conf (float): The confidence threshold for detections.
|
|
301
301
|
iou_thres (float): The Intersection over Union threshold.
|
|
@@ -326,9 +326,10 @@ class ConfusionMatrix:
|
|
|
326
326
|
Update confusion matrix for object detection task.
|
|
327
327
|
|
|
328
328
|
Args:
|
|
329
|
-
detections (Array[N, 6]): Detected bounding boxes and their associated information.
|
|
330
|
-
Each row should contain (x1, y1, x2, y2, conf, class)
|
|
331
|
-
|
|
329
|
+
detections (Array[N, 6] | Array[N, 7]): Detected bounding boxes and their associated information.
|
|
330
|
+
Each row should contain (x1, y1, x2, y2, conf, class)
|
|
331
|
+
or with an additional element `angle` when it's obb.
|
|
332
|
+
gt_bboxes (Array[M, 4]| Array[N, 5]): Ground truth bounding boxes with xyxy/xyxyr format.
|
|
332
333
|
gt_cls (Array[M]): The class labels.
|
|
333
334
|
"""
|
|
334
335
|
if gt_cls.shape[0] == 0: # Check if labels is empty
|
|
@@ -347,7 +348,12 @@ class ConfusionMatrix:
|
|
|
347
348
|
detections = detections[detections[:, 4] > self.conf]
|
|
348
349
|
gt_classes = gt_cls.int()
|
|
349
350
|
detection_classes = detections[:, 5].int()
|
|
350
|
-
|
|
351
|
+
is_obb = detections.shape[1] == 7 and gt_bboxes.shape[1] == 5 # with additional `angle` dimension
|
|
352
|
+
iou = (
|
|
353
|
+
batch_probiou(gt_bboxes, torch.cat([detections[:, :4], detections[:, -1:]], dim=-1))
|
|
354
|
+
if is_obb
|
|
355
|
+
else box_iou(gt_bboxes, detections[:, :4])
|
|
356
|
+
)
|
|
351
357
|
|
|
352
358
|
x = torch.where(iou > self.iou_thres)
|
|
353
359
|
if x[0].shape[0]:
|
ultralytics/utils/plotting.py
CHANGED
|
@@ -27,7 +27,7 @@ class Colors:
|
|
|
27
27
|
Attributes:
|
|
28
28
|
palette (list of tuple): List of RGB color values.
|
|
29
29
|
n (int): The number of colors in the palette.
|
|
30
|
-
pose_palette (np.
|
|
30
|
+
pose_palette (np.ndarray): A specific color palette array with dtype np.uint8.
|
|
31
31
|
"""
|
|
32
32
|
|
|
33
33
|
def __init__(self):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ultralytics
|
|
3
|
-
Version: 8.1.
|
|
3
|
+
Version: 8.1.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,8 +1,8 @@
|
|
|
1
|
-
ultralytics/__init__.py,sha256=
|
|
1
|
+
ultralytics/__init__.py,sha256=UDIOvkTSdexqKK4ZGzrbk3tHt5xuV5WcTNNEQRtKFxo,625
|
|
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=OZe3OfyNAeT1lRI7uJVM_Lla91mxGYgJMxrwyT7VP6o,20768
|
|
5
|
-
ultralytics/cfg/default.yaml,sha256=
|
|
5
|
+
ultralytics/cfg/default.yaml,sha256=oplXrRq-jomapPJ1v-4qAjte3WRVjYz0p4dw71jSdgY,8092
|
|
6
6
|
ultralytics/cfg/datasets/Argoverse.yaml,sha256=FyeuJT5CHq_9d4hlfAf0kpZlnbUMO0S--UJ1yIqcdKk,3134
|
|
7
7
|
ultralytics/cfg/datasets/DOTAv1.5.yaml,sha256=YDsyFPI6F6-OQXLBM3hOXo3vADYREwZzmMQfJNdpWyM,1193
|
|
8
8
|
ultralytics/cfg/datasets/DOTAv1.yaml,sha256=dxLUliHvJOW4q4vJRu5qIYVvNfjvXWB7GVh_Fhk--dM,1163
|
|
@@ -60,7 +60,7 @@ ultralytics/data/annotator.py,sha256=evXQzARVerc0hb9ol-n_GrrHf-dlXO4lCMMWEZoJ2UM
|
|
|
60
60
|
ultralytics/data/augment.py,sha256=ORotqUN-qulkHxzoW5hFF_CZDlBhuaqGgAsiPUVIf4I,52000
|
|
61
61
|
ultralytics/data/base.py,sha256=XcgBVEr-9wl58Ka-5gJUMg43LXsBQ6PiCKdHWZTdvEI,13216
|
|
62
62
|
ultralytics/data/build.py,sha256=GuWEGrBr7sYtVOMD00TcJoooq3DYhqOKRvYUKGrGK9w,6293
|
|
63
|
-
ultralytics/data/converter.py,sha256=
|
|
63
|
+
ultralytics/data/converter.py,sha256=DJ5aSk7w-RBKqrrABUoOahP_Lgccn7ujJSmVufOkBps,16503
|
|
64
64
|
ultralytics/data/dataset.py,sha256=f_rF53K_4GLpQDPxT1hvbKHFkBs0HBbEurJyn5wpIsE,16526
|
|
65
65
|
ultralytics/data/loaders.py,sha256=8nFTCTZ9fSn2TX1ALq0BE0CmmqHvKte_CscxsnAVWEQ,21910
|
|
66
66
|
ultralytics/data/split_dota.py,sha256=1q2FZC0SE4deRpXUSbKTbUAjX9VeejUIFM2DBLF8Cco,9961
|
|
@@ -72,7 +72,7 @@ ultralytics/data/explorer/gui/__init__.py,sha256=mHtJuK4hwF8cuV-VHDc7tp6u6D1gHz2
|
|
|
72
72
|
ultralytics/data/explorer/gui/dash.py,sha256=3Vi-k2LpUis-WHZ81Qnzlj71wpTCr4A8YxjUl0-v8T4,10042
|
|
73
73
|
ultralytics/engine/__init__.py,sha256=mHtJuK4hwF8cuV-VHDc7tp6u6D1gHz2Z7JI8grmQDTs,42
|
|
74
74
|
ultralytics/engine/exporter.py,sha256=CtqidWxszJ2k8eeDoIU7TEgyVL1sQ8SF5q2WaeRjIo0,52539
|
|
75
|
-
ultralytics/engine/model.py,sha256=
|
|
75
|
+
ultralytics/engine/model.py,sha256=Lne23YoKskAiLic7ew813lWYN7IR7SB9_C3YvsWHs-k,38699
|
|
76
76
|
ultralytics/engine/predictor.py,sha256=95ujaUYbDtui-s4hloGmJ0yVm9IC05Ck5dyoyNTk0BU,17832
|
|
77
77
|
ultralytics/engine/results.py,sha256=SY3sn2OBMfAFaPoaDKo0Wu-jSi7avISYohjtR_bur9M,30120
|
|
78
78
|
ultralytics/engine/trainer.py,sha256=bbrYE_zafUzBTbz39AlJOozlu8YRAiHbD5jeZmeOPyY,34239
|
|
@@ -121,11 +121,11 @@ ultralytics/models/yolo/classify/val.py,sha256=EP_hjRExXgdI4xojTKvj_YeNdaz_i2CoU
|
|
|
121
121
|
ultralytics/models/yolo/detect/__init__.py,sha256=JR8gZJWn7wMBbh-0j_073nxJVZTMFZVWTOG5Wnvk6w0,229
|
|
122
122
|
ultralytics/models/yolo/detect/predict.py,sha256=_a9vH3DmKFY6eeztFTdj3nkfu_MKG6n7zb5rRKGjs9I,1510
|
|
123
123
|
ultralytics/models/yolo/detect/train.py,sha256=zvxmevSiWNq8rdlGYeM3SZkMCcFh0qFQN9HjwxcGjJw,6306
|
|
124
|
-
ultralytics/models/yolo/detect/val.py,sha256=
|
|
124
|
+
ultralytics/models/yolo/detect/val.py,sha256=YoYXAKXl8TofZgkSq1BtmGfT4YtwtHA7z-8Wmnahlgk,13395
|
|
125
125
|
ultralytics/models/yolo/obb/__init__.py,sha256=txWbPGLY1_M7ZwlLQjrwGjTBOlsv9P3yk5ZEgysTinU,193
|
|
126
126
|
ultralytics/models/yolo/obb/predict.py,sha256=prfDzhwuVHKF6CRwnFVBA-YFI5q7U7NEQwITGHmB2Ow,2037
|
|
127
127
|
ultralytics/models/yolo/obb/train.py,sha256=ay4Z83CyWtw8GeKyhFvfg94iZHUDz0qmCPCAFc2xJhU,1477
|
|
128
|
-
ultralytics/models/yolo/obb/val.py,sha256=
|
|
128
|
+
ultralytics/models/yolo/obb/val.py,sha256=Wml-loYT5Uy4Mx6UmxNOrmURT13DIOBk_rFSs55NTNg,8500
|
|
129
129
|
ultralytics/models/yolo/pose/__init__.py,sha256=OGvxN3LqJot2h8GX1csJ1KErsHnDKsm33Ce6ZBU9Lr4,199
|
|
130
130
|
ultralytics/models/yolo/pose/predict.py,sha256=illk4qyZvybc_XMo9TKT54FIkizx91MYviE5c5OwBTQ,2404
|
|
131
131
|
ultralytics/models/yolo/pose/train.py,sha256=ki8bkT8WfIFjTKf1ofeRDqeIqmk6A8a7AFog7nM-otM,2926
|
|
@@ -136,7 +136,7 @@ ultralytics/models/yolo/segment/train.py,sha256=aOQpDIptZfKSl9mFa6B-3W3QccMRlmBI
|
|
|
136
136
|
ultralytics/models/yolo/segment/val.py,sha256=njiF6RWddS-HOWxVvlk5PXRw6UOgEt_HEOZVPF7rruQ,11745
|
|
137
137
|
ultralytics/nn/__init__.py,sha256=4BPLHY89xEM_al5uK0aOmFgiML6CMGEZbezxOvTjOEs,587
|
|
138
138
|
ultralytics/nn/autobackend.py,sha256=xxCZ0xBoXOJh8ajbhpi8I4jwF1B-7NcVtMXCuhOIoG0,27069
|
|
139
|
-
ultralytics/nn/tasks.py,sha256=
|
|
139
|
+
ultralytics/nn/tasks.py,sha256=SixRxoPcZ9QuyASawg_0-lycq3km2wgYlbJVVl6D_yE,42350
|
|
140
140
|
ultralytics/nn/modules/__init__.py,sha256=-l82xPmubimZ9LmwaF62fQxUBomBfk1ljOZVz96_OF8,2152
|
|
141
141
|
ultralytics/nn/modules/block.py,sha256=wfTkOBePJwazhQSXS2tgwJ8X2AEreA0Ztm7slMD-bSM,20553
|
|
142
142
|
ultralytics/nn/modules/conv.py,sha256=ndUYNL2f9DK41y1vVbtEusMByXy-LMMsBKlcWjRQ9Z8,12722
|
|
@@ -155,7 +155,7 @@ ultralytics/trackers/bot_sort.py,sha256=39AvhYVbT7izF3--rX_e6Lhgb5czTA23gw6AgnNc
|
|
|
155
155
|
ultralytics/trackers/byte_tracker.py,sha256=AQWpI-msOewPqPLnhvMTO_8Pk565IEd_ny6VvQQgMwk,18871
|
|
156
156
|
ultralytics/trackers/track.py,sha256=dl4qu2t3f_ZCUJqJqnrxDDXWfbpPdRFZVE8WGkcRFMg,3091
|
|
157
157
|
ultralytics/trackers/utils/__init__.py,sha256=mHtJuK4hwF8cuV-VHDc7tp6u6D1gHz2Z7JI8grmQDTs,42
|
|
158
|
-
ultralytics/trackers/utils/gmc.py,sha256=
|
|
158
|
+
ultralytics/trackers/utils/gmc.py,sha256=mXRqtlue1nmQU92TOKNH40R6lYFdUrKCYIbiPH6FIu0,13658
|
|
159
159
|
ultralytics/trackers/utils/kalman_filter.py,sha256=JN1sAcfJZy8fTZxc8w3jUJnGQDKtgAL__p4nTR6RM2I,15168
|
|
160
160
|
ultralytics/trackers/utils/matching.py,sha256=c_pthBfu9sWeMVYe-dSecdWcQxUey-mQT2yMVsFH3VQ,5404
|
|
161
161
|
ultralytics/utils/__init__.py,sha256=HbSFvSmkufgfZSfFBCn9liNZLKalwOVxylQrVVzTXVY,36953
|
|
@@ -163,15 +163,15 @@ ultralytics/utils/autobatch.py,sha256=ygZ3f2ByIkcujB89ENcTnGWWnAQw5Pbg6nBuShg-5t
|
|
|
163
163
|
ultralytics/utils/benchmarks.py,sha256=e-AgLZXJ4SZegnnRB_VPK962wQMWjLTRhjfwa_3K3rE,17641
|
|
164
164
|
ultralytics/utils/checks.py,sha256=-fUGq2PVFxBjMIKoi8IqP8h4aB9avJnTOW6wnXfxyS4,27785
|
|
165
165
|
ultralytics/utils/dist.py,sha256=3HeNbY2gp7vYhcvVhsrvTrQXpQmgT8tpmnzApf3eQRA,2267
|
|
166
|
-
ultralytics/utils/downloads.py,sha256=
|
|
166
|
+
ultralytics/utils/downloads.py,sha256=V1vIDPFEoPzFSav3X0OIHVLmeNIikhBLQVMATQA6yy0,21303
|
|
167
167
|
ultralytics/utils/errors.py,sha256=GqP_Jgj_n0paxn8OMhn3DTCgoNkB2WjUcUaqs-M6SQk,816
|
|
168
168
|
ultralytics/utils/files.py,sha256=V1cD9sC3hGd5uNVdOa4uZGySGjnsXC6Lh7mjqI_UDxo,5275
|
|
169
169
|
ultralytics/utils/instance.py,sha256=fPClvPPtTk8VeXWiRv90DrFk1j1lTUKdYJtpZKUDDtA,15575
|
|
170
170
|
ultralytics/utils/loss.py,sha256=af2_eFPSR8S2t7dIh3H24WFkMYkN6mvreDEnOiYeAQc,32581
|
|
171
|
-
ultralytics/utils/metrics.py,sha256=
|
|
171
|
+
ultralytics/utils/metrics.py,sha256=yOGv_Qc0olhEQDk3oAzX_psSabLIOs1JOIAeHmQjBmg,53744
|
|
172
172
|
ultralytics/utils/ops.py,sha256=sT7ORnwgd0Pgy0UzteR6hlw82AmojMwKDXrMaTFgVqE,32931
|
|
173
173
|
ultralytics/utils/patches.py,sha256=2iMWzwBpAjTt0UzaPzFO5JPVoKklUhftuo_3H7xBoDc,2659
|
|
174
|
-
ultralytics/utils/plotting.py,sha256=
|
|
174
|
+
ultralytics/utils/plotting.py,sha256=tp9BOfo-PmiaHMz48r9s_iDVN3a0Ry8a54ghQ-T_cP0,44663
|
|
175
175
|
ultralytics/utils/tal.py,sha256=5ZLwIt-8atPzZQk0uj0w_YFsSRqQV-NfpESUQ945P1s,16017
|
|
176
176
|
ultralytics/utils/torch_utils.py,sha256=IMCVrfZn2Av3k5KUycUxInjxt7pftCCjz5oaRxob24I,25132
|
|
177
177
|
ultralytics/utils/triton.py,sha256=gg1finxno_tY2Ge9PMhmu7PI9wvoFZoiicdT4Bhqv3w,3936
|
|
@@ -187,9 +187,9 @@ ultralytics/utils/callbacks/neptune.py,sha256=5Z3ua5YBTUS56FH8VQKQG1aaIo9fH8GEyz
|
|
|
187
187
|
ultralytics/utils/callbacks/raytune.py,sha256=6OgGNuC35F29lw8Dl_d0lue4-iBR6dqrBVQnIRQDx4E,632
|
|
188
188
|
ultralytics/utils/callbacks/tensorboard.py,sha256=fyhgBgcTmEIifBqxBJkoMZ6yQNBGhSLQBAsy770-RtA,4038
|
|
189
189
|
ultralytics/utils/callbacks/wb.py,sha256=4QI81nHdzgwhXHlmTiRxLqunvkKakLXYUhHTUY1ZeHA,6635
|
|
190
|
-
ultralytics-8.1.
|
|
191
|
-
ultralytics-8.1.
|
|
192
|
-
ultralytics-8.1.
|
|
193
|
-
ultralytics-8.1.
|
|
194
|
-
ultralytics-8.1.
|
|
195
|
-
ultralytics-8.1.
|
|
190
|
+
ultralytics-8.1.16.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
|
|
191
|
+
ultralytics-8.1.16.dist-info/METADATA,sha256=7NBiNyxE8RmV6qC9a-qnSVRyB4wC7h8mRpTpAFgiwYY,40364
|
|
192
|
+
ultralytics-8.1.16.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
193
|
+
ultralytics-8.1.16.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
|
|
194
|
+
ultralytics-8.1.16.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
|
|
195
|
+
ultralytics-8.1.16.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|