ultralytics 8.3.143__py3-none-any.whl → 8.3.145__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 +7 -24
- tests/test_cli.py +1 -1
- tests/test_cuda.py +7 -2
- tests/test_engine.py +7 -8
- tests/test_exports.py +16 -16
- tests/test_integrations.py +1 -1
- tests/test_solutions.py +11 -11
- ultralytics/__init__.py +1 -1
- ultralytics/cfg/__init__.py +16 -13
- ultralytics/data/annotator.py +6 -5
- ultralytics/data/augment.py +127 -126
- ultralytics/data/base.py +54 -51
- ultralytics/data/build.py +47 -23
- ultralytics/data/converter.py +47 -43
- ultralytics/data/dataset.py +51 -50
- ultralytics/data/loaders.py +77 -44
- ultralytics/data/split.py +22 -9
- ultralytics/data/split_dota.py +63 -39
- ultralytics/data/utils.py +59 -39
- ultralytics/engine/exporter.py +79 -27
- ultralytics/engine/model.py +52 -51
- ultralytics/engine/predictor.py +37 -28
- ultralytics/engine/results.py +191 -161
- ultralytics/engine/trainer.py +36 -19
- ultralytics/engine/tuner.py +12 -9
- ultralytics/engine/validator.py +7 -9
- ultralytics/hub/__init__.py +11 -13
- ultralytics/hub/auth.py +22 -2
- ultralytics/hub/google/__init__.py +19 -19
- ultralytics/hub/session.py +37 -51
- ultralytics/hub/utils.py +19 -5
- ultralytics/models/fastsam/model.py +30 -12
- ultralytics/models/fastsam/predict.py +5 -6
- ultralytics/models/fastsam/utils.py +3 -3
- ultralytics/models/fastsam/val.py +10 -6
- ultralytics/models/nas/model.py +9 -5
- ultralytics/models/nas/predict.py +6 -6
- ultralytics/models/nas/val.py +3 -3
- ultralytics/models/rtdetr/model.py +7 -6
- ultralytics/models/rtdetr/predict.py +14 -7
- ultralytics/models/rtdetr/train.py +10 -4
- ultralytics/models/rtdetr/val.py +36 -9
- ultralytics/models/sam/amg.py +30 -12
- ultralytics/models/sam/build.py +22 -22
- ultralytics/models/sam/model.py +10 -9
- ultralytics/models/sam/modules/blocks.py +76 -80
- ultralytics/models/sam/modules/decoders.py +6 -8
- ultralytics/models/sam/modules/encoders.py +23 -26
- ultralytics/models/sam/modules/memory_attention.py +13 -1
- ultralytics/models/sam/modules/sam.py +57 -26
- ultralytics/models/sam/modules/tiny_encoder.py +232 -237
- ultralytics/models/sam/modules/transformer.py +13 -13
- ultralytics/models/sam/modules/utils.py +11 -19
- ultralytics/models/sam/predict.py +114 -101
- ultralytics/models/utils/loss.py +98 -77
- ultralytics/models/utils/ops.py +116 -67
- ultralytics/models/yolo/classify/predict.py +5 -5
- ultralytics/models/yolo/classify/train.py +32 -28
- ultralytics/models/yolo/classify/val.py +7 -8
- ultralytics/models/yolo/detect/predict.py +1 -0
- ultralytics/models/yolo/detect/train.py +15 -14
- ultralytics/models/yolo/detect/val.py +37 -36
- ultralytics/models/yolo/model.py +106 -23
- ultralytics/models/yolo/obb/predict.py +3 -4
- ultralytics/models/yolo/obb/train.py +14 -6
- ultralytics/models/yolo/obb/val.py +29 -23
- ultralytics/models/yolo/pose/predict.py +9 -8
- ultralytics/models/yolo/pose/train.py +24 -16
- ultralytics/models/yolo/pose/val.py +44 -26
- ultralytics/models/yolo/segment/predict.py +5 -5
- ultralytics/models/yolo/segment/train.py +11 -7
- ultralytics/models/yolo/segment/val.py +2 -2
- ultralytics/models/yolo/world/train.py +33 -23
- ultralytics/models/yolo/world/train_world.py +11 -3
- ultralytics/models/yolo/yoloe/predict.py +11 -11
- ultralytics/models/yolo/yoloe/train.py +73 -21
- ultralytics/models/yolo/yoloe/train_seg.py +10 -7
- ultralytics/models/yolo/yoloe/val.py +42 -18
- ultralytics/nn/autobackend.py +59 -15
- ultralytics/nn/modules/__init__.py +4 -4
- ultralytics/nn/modules/activation.py +4 -1
- ultralytics/nn/modules/block.py +178 -111
- ultralytics/nn/modules/conv.py +6 -5
- ultralytics/nn/modules/head.py +469 -121
- ultralytics/nn/modules/transformer.py +147 -58
- ultralytics/nn/tasks.py +227 -20
- ultralytics/nn/text_model.py +30 -33
- ultralytics/solutions/ai_gym.py +4 -6
- ultralytics/solutions/analytics.py +7 -4
- ultralytics/solutions/config.py +10 -10
- ultralytics/solutions/distance_calculation.py +11 -10
- ultralytics/solutions/heatmap.py +2 -2
- ultralytics/solutions/instance_segmentation.py +7 -4
- ultralytics/solutions/object_blurrer.py +3 -3
- ultralytics/solutions/object_counter.py +15 -11
- ultralytics/solutions/object_cropper.py +3 -2
- ultralytics/solutions/parking_management.py +29 -28
- ultralytics/solutions/queue_management.py +6 -6
- ultralytics/solutions/region_counter.py +10 -3
- ultralytics/solutions/security_alarm.py +3 -3
- ultralytics/solutions/similarity_search.py +85 -24
- ultralytics/solutions/solutions.py +189 -79
- ultralytics/solutions/speed_estimation.py +28 -22
- ultralytics/solutions/streamlit_inference.py +17 -12
- ultralytics/solutions/trackzone.py +4 -4
- ultralytics/trackers/basetrack.py +16 -23
- ultralytics/trackers/bot_sort.py +30 -20
- ultralytics/trackers/byte_tracker.py +70 -64
- ultralytics/trackers/track.py +4 -8
- ultralytics/trackers/utils/gmc.py +31 -58
- ultralytics/trackers/utils/kalman_filter.py +37 -37
- ultralytics/trackers/utils/matching.py +1 -1
- ultralytics/utils/__init__.py +105 -89
- ultralytics/utils/autobatch.py +16 -3
- ultralytics/utils/autodevice.py +54 -24
- ultralytics/utils/benchmarks.py +45 -29
- ultralytics/utils/callbacks/base.py +3 -3
- ultralytics/utils/callbacks/clearml.py +9 -9
- ultralytics/utils/callbacks/comet.py +67 -25
- ultralytics/utils/callbacks/dvc.py +7 -10
- ultralytics/utils/callbacks/mlflow.py +2 -5
- ultralytics/utils/callbacks/neptune.py +7 -13
- ultralytics/utils/callbacks/raytune.py +1 -1
- ultralytics/utils/callbacks/tensorboard.py +5 -6
- ultralytics/utils/callbacks/wb.py +14 -14
- ultralytics/utils/checks.py +14 -13
- ultralytics/utils/dist.py +5 -5
- ultralytics/utils/downloads.py +94 -67
- ultralytics/utils/errors.py +5 -5
- ultralytics/utils/export.py +61 -47
- ultralytics/utils/files.py +23 -22
- ultralytics/utils/instance.py +48 -52
- ultralytics/utils/loss.py +78 -40
- ultralytics/utils/metrics.py +186 -130
- ultralytics/utils/ops.py +186 -190
- ultralytics/utils/patches.py +15 -17
- ultralytics/utils/plotting.py +71 -27
- ultralytics/utils/tal.py +21 -15
- ultralytics/utils/torch_utils.py +53 -50
- ultralytics/utils/triton.py +5 -4
- ultralytics/utils/tuner.py +5 -5
- {ultralytics-8.3.143.dist-info → ultralytics-8.3.145.dist-info}/METADATA +2 -2
- ultralytics-8.3.145.dist-info/RECORD +272 -0
- ultralytics-8.3.143.dist-info/RECORD +0 -272
- {ultralytics-8.3.143.dist-info → ultralytics-8.3.145.dist-info}/WHEEL +0 -0
- {ultralytics-8.3.143.dist-info → ultralytics-8.3.145.dist-info}/entry_points.txt +0 -0
- {ultralytics-8.3.143.dist-info → ultralytics-8.3.145.dist-info}/licenses/LICENSE +0 -0
- {ultralytics-8.3.143.dist-info → ultralytics-8.3.145.dist-info}/top_level.txt +0 -0
ultralytics/utils/torch_utils.py
CHANGED
@@ -49,7 +49,7 @@ if WINDOWS and check_version(torch.__version__, "==2.4.0"): # reject version 2.
|
|
49
49
|
|
50
50
|
@contextmanager
|
51
51
|
def torch_distributed_zero_first(local_rank: int):
|
52
|
-
"""
|
52
|
+
"""Ensure all processes in distributed training wait for the local master (rank 0) to complete a task first."""
|
53
53
|
initialized = dist.is_available() and dist.is_initialized()
|
54
54
|
use_ids = initialized and dist.get_backend() == "nccl"
|
55
55
|
|
@@ -61,10 +61,10 @@ def torch_distributed_zero_first(local_rank: int):
|
|
61
61
|
|
62
62
|
|
63
63
|
def smart_inference_mode():
|
64
|
-
"""
|
64
|
+
"""Apply torch.inference_mode() decorator if torch>=1.9.0 else torch.no_grad() decorator."""
|
65
65
|
|
66
66
|
def decorate(fn):
|
67
|
-
"""
|
67
|
+
"""Apply appropriate torch decorator for inference mode based on torch version."""
|
68
68
|
if TORCH_1_9 and torch.is_inference_mode_enabled():
|
69
69
|
return fn # already in inference_mode, act as a pass-through
|
70
70
|
else:
|
@@ -82,7 +82,7 @@ def autocast(enabled: bool, device: str = "cuda"):
|
|
82
82
|
|
83
83
|
Args:
|
84
84
|
enabled (bool): Whether to enable automatic mixed precision.
|
85
|
-
device (str, optional): The device to use for autocast.
|
85
|
+
device (str, optional): The device to use for autocast.
|
86
86
|
|
87
87
|
Returns:
|
88
88
|
(torch.amp.autocast): The appropriate autocast context manager.
|
@@ -136,9 +136,8 @@ def select_device(device="", batch=0, newline=False, verbose=True):
|
|
136
136
|
exception if the requested device(s) are not available.
|
137
137
|
|
138
138
|
Args:
|
139
|
-
device (str | torch.device, optional): Device string or torch.device object.
|
140
|
-
|
141
|
-
the first available GPU, or CPU if no GPU is available.
|
139
|
+
device (str | torch.device, optional): Device string or torch.device object. Options are 'None', 'cpu', or
|
140
|
+
'cuda', or '0' or '0,1,2,3'. Auto-selects the first available GPU, or CPU if no GPU is available.
|
142
141
|
batch (int, optional): Batch size being used in your model.
|
143
142
|
newline (bool, optional): If True, adds a newline at the end of the log string.
|
144
143
|
verbose (bool, optional): If True, logs the device information.
|
@@ -157,7 +156,7 @@ def select_device(device="", batch=0, newline=False, verbose=True):
|
|
157
156
|
>>> select_device("cpu")
|
158
157
|
device(type='cpu')
|
159
158
|
|
160
|
-
|
159
|
+
Notes:
|
161
160
|
Sets the 'CUDA_VISIBLE_DEVICES' environment variable for specifying which GPUs to use.
|
162
161
|
"""
|
163
162
|
if isinstance(device, torch.device) or str(device).startswith(("tpu", "intel")):
|
@@ -243,7 +242,7 @@ def select_device(device="", batch=0, newline=False, verbose=True):
|
|
243
242
|
|
244
243
|
|
245
244
|
def time_sync():
|
246
|
-
"""PyTorch-accurate time."""
|
245
|
+
"""Return PyTorch-accurate time."""
|
247
246
|
if torch.cuda.is_available():
|
248
247
|
torch.cuda.synchronize()
|
249
248
|
return time.time()
|
@@ -320,12 +319,15 @@ def model_info(model, detailed=False, verbose=True, imgsz=640):
|
|
320
319
|
|
321
320
|
Args:
|
322
321
|
model (nn.Module): Model to analyze.
|
323
|
-
detailed (bool, optional): Whether to print detailed layer information.
|
324
|
-
verbose (bool, optional): Whether to print model information.
|
325
|
-
imgsz (int |
|
322
|
+
detailed (bool, optional): Whether to print detailed layer information.
|
323
|
+
verbose (bool, optional): Whether to print model information.
|
324
|
+
imgsz (int | list, optional): Input image size.
|
326
325
|
|
327
326
|
Returns:
|
328
|
-
(
|
327
|
+
n_l (int): Number of layers.
|
328
|
+
n_p (int): Number of parameters.
|
329
|
+
n_g (int): Number of gradients.
|
330
|
+
flops (float): GFLOPs.
|
329
331
|
"""
|
330
332
|
if not verbose:
|
331
333
|
return
|
@@ -410,7 +412,7 @@ def get_flops(model, imgsz=640):
|
|
410
412
|
|
411
413
|
Args:
|
412
414
|
model (nn.Module): The model to calculate FLOPs for.
|
413
|
-
imgsz (int |
|
415
|
+
imgsz (int | list, optional): Input image size.
|
414
416
|
|
415
417
|
Returns:
|
416
418
|
(float): The model FLOPs in billions.
|
@@ -448,7 +450,7 @@ def get_flops_with_torch_profiler(model, imgsz=640):
|
|
448
450
|
|
449
451
|
Args:
|
450
452
|
model (nn.Module): The model to calculate FLOPs for.
|
451
|
-
imgsz (int |
|
453
|
+
imgsz (int | list, optional): Input image size.
|
452
454
|
|
453
455
|
Returns:
|
454
456
|
(float): The model's FLOPs in billions.
|
@@ -491,13 +493,13 @@ def initialize_weights(model):
|
|
491
493
|
|
492
494
|
def scale_img(img, ratio=1.0, same_shape=False, gs=32):
|
493
495
|
"""
|
494
|
-
|
496
|
+
Scale and pad an image tensor, optionally maintaining aspect ratio and padding to gs multiple.
|
495
497
|
|
496
498
|
Args:
|
497
499
|
img (torch.Tensor): Input image tensor.
|
498
|
-
ratio (float, optional): Scaling ratio.
|
499
|
-
same_shape (bool, optional): Whether to maintain the same shape.
|
500
|
-
gs (int, optional): Grid size for padding.
|
500
|
+
ratio (float, optional): Scaling ratio.
|
501
|
+
same_shape (bool, optional): Whether to maintain the same shape.
|
502
|
+
gs (int, optional): Grid size for padding.
|
501
503
|
|
502
504
|
Returns:
|
503
505
|
(torch.Tensor): Scaled and padded image tensor.
|
@@ -514,13 +516,13 @@ def scale_img(img, ratio=1.0, same_shape=False, gs=32):
|
|
514
516
|
|
515
517
|
def copy_attr(a, b, include=(), exclude=()):
|
516
518
|
"""
|
517
|
-
|
519
|
+
Copy attributes from object 'b' to object 'a', with options to include/exclude certain attributes.
|
518
520
|
|
519
521
|
Args:
|
520
|
-
a (
|
521
|
-
b (
|
522
|
-
include (tuple, optional): Attributes to include. If empty, all attributes are included.
|
523
|
-
exclude (tuple, optional): Attributes to exclude.
|
522
|
+
a (Any): Destination object to copy attributes to.
|
523
|
+
b (Any): Source object to copy attributes from.
|
524
|
+
include (tuple, optional): Attributes to include. If empty, all attributes are included.
|
525
|
+
exclude (tuple, optional): Attributes to exclude.
|
524
526
|
"""
|
525
527
|
for k, v in b.__dict__.items():
|
526
528
|
if (len(include) and k not in include) or k.startswith("_") or k in exclude:
|
@@ -546,12 +548,12 @@ def get_latest_opset():
|
|
546
548
|
|
547
549
|
def intersect_dicts(da, db, exclude=()):
|
548
550
|
"""
|
549
|
-
|
551
|
+
Return a dictionary of intersecting keys with matching shapes, excluding 'exclude' keys, using da values.
|
550
552
|
|
551
553
|
Args:
|
552
554
|
da (dict): First dictionary.
|
553
555
|
db (dict): Second dictionary.
|
554
|
-
exclude (tuple, optional): Keys to exclude.
|
556
|
+
exclude (tuple, optional): Keys to exclude.
|
555
557
|
|
556
558
|
Returns:
|
557
559
|
(dict): Dictionary of intersecting keys with matching shapes.
|
@@ -561,7 +563,7 @@ def intersect_dicts(da, db, exclude=()):
|
|
561
563
|
|
562
564
|
def is_parallel(model):
|
563
565
|
"""
|
564
|
-
|
566
|
+
Return True if model is of type DP or DDP.
|
565
567
|
|
566
568
|
Args:
|
567
569
|
model (nn.Module): Model to check.
|
@@ -574,7 +576,7 @@ def is_parallel(model):
|
|
574
576
|
|
575
577
|
def de_parallel(model):
|
576
578
|
"""
|
577
|
-
De-parallelize a model:
|
579
|
+
De-parallelize a model: return single-GPU model if model is of type DP or DDP.
|
578
580
|
|
579
581
|
Args:
|
580
582
|
model (nn.Module): Model to de-parallelize.
|
@@ -587,12 +589,12 @@ def de_parallel(model):
|
|
587
589
|
|
588
590
|
def one_cycle(y1=0.0, y2=1.0, steps=100):
|
589
591
|
"""
|
590
|
-
|
592
|
+
Return a lambda function for sinusoidal ramp from y1 to y2 https://arxiv.org/pdf/1812.01187.pdf.
|
591
593
|
|
592
594
|
Args:
|
593
|
-
y1 (float, optional): Initial value.
|
594
|
-
y2 (float, optional): Final value.
|
595
|
-
steps (int, optional): Number of steps.
|
595
|
+
y1 (float, optional): Initial value.
|
596
|
+
y2 (float, optional): Final value.
|
597
|
+
steps (int, optional): Number of steps.
|
596
598
|
|
597
599
|
Returns:
|
598
600
|
(function): Lambda function for computing the sinusoidal ramp.
|
@@ -605,8 +607,8 @@ def init_seeds(seed=0, deterministic=False):
|
|
605
607
|
Initialize random number generator (RNG) seeds https://pytorch.org/docs/stable/notes/randomness.html.
|
606
608
|
|
607
609
|
Args:
|
608
|
-
seed (int, optional): Random seed.
|
609
|
-
deterministic (bool, optional): Whether to set deterministic algorithms.
|
610
|
+
seed (int, optional): Random seed.
|
611
|
+
deterministic (bool, optional): Whether to set deterministic algorithms.
|
610
612
|
"""
|
611
613
|
random.seed(seed)
|
612
614
|
np.random.seed(seed)
|
@@ -627,7 +629,7 @@ def init_seeds(seed=0, deterministic=False):
|
|
627
629
|
|
628
630
|
|
629
631
|
def unset_deterministic():
|
630
|
-
"""
|
632
|
+
"""Unset all the configurations applied for deterministic training."""
|
631
633
|
torch.use_deterministic_algorithms(False)
|
632
634
|
torch.backends.cudnn.deterministic = False
|
633
635
|
os.environ.pop("CUBLAS_WORKSPACE_CONFIG", None)
|
@@ -660,9 +662,9 @@ class ModelEMA:
|
|
660
662
|
|
661
663
|
Args:
|
662
664
|
model (nn.Module): Model to create EMA for.
|
663
|
-
decay (float, optional): Maximum EMA decay rate.
|
664
|
-
tau (int, optional): EMA decay time constant.
|
665
|
-
updates (int, optional): Initial number of updates.
|
665
|
+
decay (float, optional): Maximum EMA decay rate.
|
666
|
+
tau (int, optional): EMA decay time constant.
|
667
|
+
updates (int, optional): Initial number of updates.
|
666
668
|
"""
|
667
669
|
self.ema = deepcopy(de_parallel(model)).eval() # FP32 EMA
|
668
670
|
self.updates = updates # number of EMA updates
|
@@ -691,12 +693,12 @@ class ModelEMA:
|
|
691
693
|
|
692
694
|
def update_attr(self, model, include=(), exclude=("process_group", "reducer")):
|
693
695
|
"""
|
694
|
-
|
696
|
+
Update attributes and save stripped model with optimizer removed.
|
695
697
|
|
696
698
|
Args:
|
697
699
|
model (nn.Module): Model to update attributes from.
|
698
|
-
include (tuple, optional): Attributes to include.
|
699
|
-
exclude (tuple, optional): Attributes to exclude.
|
700
|
+
include (tuple, optional): Attributes to include.
|
701
|
+
exclude (tuple, optional): Attributes to exclude.
|
700
702
|
"""
|
701
703
|
if self.enabled:
|
702
704
|
copy_attr(self.ema, model, include, exclude)
|
@@ -707,8 +709,9 @@ def strip_optimizer(f: Union[str, Path] = "best.pt", s: str = "", updates: dict
|
|
707
709
|
Strip optimizer from 'f' to finalize training, optionally save as 's'.
|
708
710
|
|
709
711
|
Args:
|
710
|
-
f (str | Path): File path to model to strip the optimizer from.
|
711
|
-
s (str, optional): File path to save the model with stripped optimizer to. If not provided, 'f' will be
|
712
|
+
f (str | Path): File path to model to strip the optimizer from.
|
713
|
+
s (str, optional): File path to save the model with stripped optimizer to. If not provided, 'f' will be
|
714
|
+
overwritten.
|
712
715
|
updates (dict, optional): A dictionary of updates to overlay onto the checkpoint before saving.
|
713
716
|
|
714
717
|
Returns:
|
@@ -764,7 +767,7 @@ def strip_optimizer(f: Union[str, Path] = "best.pt", s: str = "", updates: dict
|
|
764
767
|
|
765
768
|
def convert_optimizer_state_dict_to_fp16(state_dict):
|
766
769
|
"""
|
767
|
-
|
770
|
+
Convert the state_dict of a given optimizer to FP16, focusing on the 'state' key for tensor conversions.
|
768
771
|
|
769
772
|
Args:
|
770
773
|
state_dict (dict): Optimizer state dictionary.
|
@@ -790,7 +793,7 @@ def cuda_memory_usage(device=None):
|
|
790
793
|
Finally, it updates the dictionary with the amount of memory reserved by CUDA on the specified device.
|
791
794
|
|
792
795
|
Args:
|
793
|
-
device (torch.device, optional): The CUDA device to query memory usage for.
|
796
|
+
device (torch.device, optional): The CUDA device to query memory usage for.
|
794
797
|
|
795
798
|
Yields:
|
796
799
|
(dict): A dictionary with a key 'memory' initialized to 0, which will be updated with the reserved memory.
|
@@ -811,11 +814,11 @@ def profile_ops(input, ops, n=10, device=None, max_num_obj=0):
|
|
811
814
|
Ultralytics speed, memory and FLOPs profiler.
|
812
815
|
|
813
816
|
Args:
|
814
|
-
input (torch.Tensor |
|
815
|
-
ops (nn.Module |
|
816
|
-
n (int, optional): Number of iterations to average.
|
817
|
-
device (str | torch.device, optional): Device to profile on.
|
818
|
-
max_num_obj (int, optional): Maximum number of objects for simulation.
|
817
|
+
input (torch.Tensor | list): Input tensor(s) to profile.
|
818
|
+
ops (nn.Module | list): Model or list of operations to profile.
|
819
|
+
n (int, optional): Number of iterations to average.
|
820
|
+
device (str | torch.device, optional): Device to profile on.
|
821
|
+
max_num_obj (int, optional): Maximum number of objects for simulation.
|
819
822
|
|
820
823
|
Returns:
|
821
824
|
(list): Profile results for each operation.
|
ultralytics/utils/triton.py
CHANGED
@@ -11,7 +11,7 @@ class TritonRemoteModel:
|
|
11
11
|
Client for interacting with a remote Triton Inference Server model.
|
12
12
|
|
13
13
|
This class provides a convenient interface for sending inference requests to a Triton Inference Server
|
14
|
-
and processing the responses.
|
14
|
+
and processing the responses. Supports both HTTP and gRPC communication protocols.
|
15
15
|
|
16
16
|
Attributes:
|
17
17
|
endpoint (str): The name of the model on the Triton server.
|
@@ -31,6 +31,7 @@ class TritonRemoteModel:
|
|
31
31
|
Examples:
|
32
32
|
Initialize a Triton client with HTTP
|
33
33
|
>>> model = TritonRemoteModel(url="localhost:8000", endpoint="yolov8", scheme="http")
|
34
|
+
|
34
35
|
Make inference with numpy arrays
|
35
36
|
>>> outputs = model(np.random.rand(1, 3, 640, 640).astype(np.float32))
|
36
37
|
"""
|
@@ -44,8 +45,8 @@ class TritonRemoteModel:
|
|
44
45
|
|
45
46
|
Args:
|
46
47
|
url (str): The URL of the Triton server.
|
47
|
-
endpoint (str): The name of the model on the Triton server.
|
48
|
-
scheme (str): The communication scheme ('http' or 'grpc').
|
48
|
+
endpoint (str, optional): The name of the model on the Triton server.
|
49
|
+
scheme (str, optional): The communication scheme ('http' or 'grpc').
|
49
50
|
|
50
51
|
Examples:
|
51
52
|
>>> model = TritonRemoteModel(url="localhost:8000", endpoint="yolov8", scheme="http")
|
@@ -87,7 +88,7 @@ class TritonRemoteModel:
|
|
87
88
|
|
88
89
|
def __call__(self, *inputs: np.ndarray) -> List[np.ndarray]:
|
89
90
|
"""
|
90
|
-
Call the model with the given inputs.
|
91
|
+
Call the model with the given inputs and return inference results.
|
91
92
|
|
92
93
|
Args:
|
93
94
|
*inputs (np.ndarray): Input data to the model. Each array should match the expected shape and type
|
ultralytics/utils/tuner.py
CHANGED
@@ -17,14 +17,14 @@ def run_ray_tune(
|
|
17
17
|
|
18
18
|
Args:
|
19
19
|
model (YOLO): Model to run the tuner on.
|
20
|
-
space (dict, optional): The hyperparameter search space.
|
20
|
+
space (dict, optional): The hyperparameter search space. If not provided, uses default space.
|
21
21
|
grace_period (int, optional): The grace period in epochs of the ASHA scheduler.
|
22
22
|
gpu_per_trial (int, optional): The number of GPUs to allocate per trial.
|
23
23
|
max_samples (int, optional): The maximum number of trials to run.
|
24
24
|
**train_args (Any): Additional arguments to pass to the `train()` method.
|
25
25
|
|
26
26
|
Returns:
|
27
|
-
(
|
27
|
+
(ray.tune.ResultGrid): A ResultGrid containing the results of the hyperparameter search.
|
28
28
|
|
29
29
|
Examples:
|
30
30
|
>>> from ultralytics import YOLO
|
@@ -88,7 +88,7 @@ def run_ray_tune(
|
|
88
88
|
model_in_store = ray.put(model)
|
89
89
|
|
90
90
|
def _tune(config):
|
91
|
-
"""Train the YOLO model with the specified hyperparameters."""
|
91
|
+
"""Train the YOLO model with the specified hyperparameters and return results."""
|
92
92
|
model_to_train = ray.get(model_in_store) # get the model from ray store for tuning
|
93
93
|
model_to_train.reset_callbacks()
|
94
94
|
config.update(train_args)
|
@@ -98,13 +98,13 @@ def run_ray_tune(
|
|
98
98
|
# Get search space
|
99
99
|
if not space and not train_args.get("resume"):
|
100
100
|
space = default_space
|
101
|
-
LOGGER.warning("
|
101
|
+
LOGGER.warning("Search space not provided, using default search space.")
|
102
102
|
|
103
103
|
# Get dataset
|
104
104
|
data = train_args.get("data", TASK2DATA[task])
|
105
105
|
space["data"] = data
|
106
106
|
if "data" not in train_args:
|
107
|
-
LOGGER.warning(f'
|
107
|
+
LOGGER.warning(f'Data not provided, using default "data={data}".')
|
108
108
|
|
109
109
|
# Define the trainable function with allocated resources
|
110
110
|
trainable_with_resources = tune.with_resources(_tune, {"cpu": NUM_THREADS, "gpu": gpu_per_trial or 0})
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ultralytics
|
3
|
-
Version: 8.3.
|
3
|
+
Version: 8.3.145
|
4
4
|
Summary: Ultralytics YOLO 🚀 for SOTA object detection, multi-object tracking, instance segmentation, pose estimation and image classification.
|
5
5
|
Author-email: Glenn Jocher <glenn.jocher@ultralytics.com>, Jing Qiu <jing.qiu@ultralytics.com>
|
6
6
|
Maintainer-email: Ultralytics <hello@ultralytics.com>
|
@@ -55,7 +55,7 @@ Requires-Dist: coverage[toml]; extra == "dev"
|
|
55
55
|
Requires-Dist: mkdocs>=1.6.0; extra == "dev"
|
56
56
|
Requires-Dist: mkdocs-material>=9.5.9; extra == "dev"
|
57
57
|
Requires-Dist: mkdocstrings[python]; extra == "dev"
|
58
|
-
Requires-Dist: mkdocs-ultralytics-plugin>=0.1.
|
58
|
+
Requires-Dist: mkdocs-ultralytics-plugin>=0.1.19; extra == "dev"
|
59
59
|
Requires-Dist: mkdocs-macros-plugin>=1.0.5; extra == "dev"
|
60
60
|
Provides-Extra: export
|
61
61
|
Requires-Dist: onnx<1.18.0,>=1.12.0; extra == "export"
|