ultralytics 8.3.197__py3-none-any.whl → 8.3.198__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.
Files changed (42) hide show
  1. tests/test_engine.py +9 -1
  2. ultralytics/__init__.py +1 -1
  3. ultralytics/cfg/__init__.py +0 -1
  4. ultralytics/cfg/default.yaml +96 -94
  5. ultralytics/cfg/trackers/botsort.yaml +16 -17
  6. ultralytics/cfg/trackers/bytetrack.yaml +9 -11
  7. ultralytics/data/augment.py +1 -1
  8. ultralytics/data/dataset.py +1 -1
  9. ultralytics/engine/exporter.py +35 -35
  10. ultralytics/engine/predictor.py +1 -2
  11. ultralytics/engine/results.py +1 -1
  12. ultralytics/engine/trainer.py +5 -5
  13. ultralytics/engine/tuner.py +54 -32
  14. ultralytics/models/sam/modules/decoders.py +3 -3
  15. ultralytics/models/sam/modules/sam.py +5 -5
  16. ultralytics/models/sam/predict.py +11 -11
  17. ultralytics/models/yolo/classify/train.py +2 -7
  18. ultralytics/models/yolo/classify/val.py +2 -2
  19. ultralytics/models/yolo/detect/predict.py +1 -1
  20. ultralytics/models/yolo/detect/train.py +1 -6
  21. ultralytics/models/yolo/detect/val.py +4 -4
  22. ultralytics/models/yolo/obb/val.py +3 -3
  23. ultralytics/models/yolo/pose/predict.py +1 -1
  24. ultralytics/models/yolo/pose/train.py +0 -6
  25. ultralytics/models/yolo/pose/val.py +2 -2
  26. ultralytics/models/yolo/segment/predict.py +2 -2
  27. ultralytics/models/yolo/segment/train.py +0 -5
  28. ultralytics/models/yolo/segment/val.py +9 -7
  29. ultralytics/models/yolo/yoloe/val.py +1 -1
  30. ultralytics/nn/modules/block.py +1 -1
  31. ultralytics/nn/tasks.py +2 -2
  32. ultralytics/utils/checks.py +1 -1
  33. ultralytics/utils/metrics.py +6 -6
  34. ultralytics/utils/nms.py +5 -13
  35. ultralytics/utils/plotting.py +22 -36
  36. ultralytics/utils/torch_utils.py +9 -5
  37. {ultralytics-8.3.197.dist-info → ultralytics-8.3.198.dist-info}/METADATA +1 -1
  38. {ultralytics-8.3.197.dist-info → ultralytics-8.3.198.dist-info}/RECORD +42 -42
  39. {ultralytics-8.3.197.dist-info → ultralytics-8.3.198.dist-info}/WHEEL +0 -0
  40. {ultralytics-8.3.197.dist-info → ultralytics-8.3.198.dist-info}/entry_points.txt +0 -0
  41. {ultralytics-8.3.197.dist-info → ultralytics-8.3.198.dist-info}/licenses/LICENSE +0 -0
  42. {ultralytics-8.3.197.dist-info → ultralytics-8.3.198.dist-info}/top_level.txt +0 -0
tests/test_engine.py CHANGED
@@ -67,7 +67,15 @@ def test_detect():
67
67
 
68
68
  def test_segment():
69
69
  """Test image segmentation training, validation, and prediction pipelines using YOLO models."""
70
- overrides = {"data": "coco8-seg.yaml", "model": "yolo11n-seg.yaml", "imgsz": 32, "epochs": 1, "save": False}
70
+ overrides = {
71
+ "data": "coco8-seg.yaml",
72
+ "model": "yolo11n-seg.yaml",
73
+ "imgsz": 32,
74
+ "epochs": 1,
75
+ "save": False,
76
+ "mask_ratio": 1,
77
+ "overlap_mask": False,
78
+ }
71
79
  cfg = get_cfg(DEFAULT_CFG)
72
80
  cfg.data = "coco8-seg.yaml"
73
81
  cfg.imgsz = 32
ultralytics/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
2
 
3
- __version__ = "8.3.197"
3
+ __version__ = "8.3.198"
4
4
 
5
5
  import os
6
6
 
@@ -237,7 +237,6 @@ CFG_BOOL_KEYS = frozenset(
237
237
  "nms",
238
238
  "profile",
239
239
  "multi_scale",
240
- "compile",
241
240
  }
242
241
  )
243
242
 
@@ -7,122 +7,124 @@ task: detect # (str) YOLO task, i.e. detect, segment, classify, pose, obb
7
7
  mode: train # (str) YOLO mode, i.e. train, val, predict, export, track, benchmark
8
8
 
9
9
  # Train settings -------------------------------------------------------------------------------------------------------
10
- model: # (str, optional) path to model file, i.e. yolov8n.pt, yolov8n.yaml
10
+ model: # (str, optional) path to model file, i.e. yolov8n.pt or yolov8n.yaml
11
11
  data: # (str, optional) path to data file, i.e. coco8.yaml
12
12
  epochs: 100 # (int) number of epochs to train for
13
- time: # (float, optional) number of hours to train for, overrides epochs if supplied
14
- patience: 100 # (int) epochs to wait for no observable improvement for early stopping of training
15
- batch: 16 # (int) number of images per batch (-1 for AutoBatch)
16
- imgsz: 640 # (int | list) input images size as int for train and val modes, or list[h,w] for predict and export modes
13
+ time: # (float, optional) max hours to train; overrides epochs if set
14
+ patience: 100 # (int) early stop after N epochs without val improvement
15
+ batch: 16 # (int) batch size; use -1 for AutoBatch
16
+ imgsz: 640 # (int | list) train/val use int (square); predict/export may use [h,w]
17
17
  save: True # (bool) save train checkpoints and predict results
18
- save_period: -1 # (int) Save checkpoint every x epochs (disabled if < 1)
19
- cache: False # (bool) True/ram, disk or False. Use cache for data loading
20
- device: # (int | str | list) device: CUDA device=0 or [0,1,2,3] or "cpu/mps" or -1 or [-1,-1] to auto-select idle GPUs
21
- workers: 8 # (int) number of worker threads for data loading (per RANK if DDP)
22
- project: # (str, optional) project name
23
- name: # (str, optional) experiment name, results saved to 'project/name' directory
24
- exist_ok: False # (bool) whether to overwrite existing experiment
25
- pretrained: True # (bool | str) whether to use a pretrained model (bool) or a model to load weights from (str)
26
- optimizer: auto # (str) optimizer to use, choices=[SGD, Adam, Adamax, AdamW, NAdam, RAdam, RMSProp, auto]
27
- verbose: True # (bool) whether to print verbose output
18
+ save_period: -1 # (int) save checkpoint every N epochs; disabled if < 1
19
+ cache: False # (bool | str) cache images in RAM (True/'ram') or on 'disk' to speed dataloading; False disables
20
+ device: # (int | str | list) device: 0 or [0,1,2,3] for CUDA, 'cpu'/'mps', or -1/[-1,-1] to auto-select idle GPUs
21
+ workers: 8 # (int) dataloader workers (per RANK if DDP)
22
+ project: # (str, optional) project name for results root
23
+ name: # (str, optional) experiment name; results in 'project/name'
24
+ exist_ok: False # (bool) overwrite existing 'project/name' if True
25
+ pretrained: True # (bool | str) use pretrained weights (bool) or load weights from path (str)
26
+ optimizer: auto # (str) optimizer: SGD, Adam, Adamax, AdamW, NAdam, RAdam, RMSProp, or auto
27
+ verbose: True # (bool) print verbose logs during training/val
28
28
  seed: 0 # (int) random seed for reproducibility
29
- deterministic: True # (bool) whether to enable deterministic mode
30
- single_cls: False # (bool) train multi-class data as single-class
31
- rect: False # (bool) rectangular training if mode='train' or rectangular validation if mode='val'
32
- cos_lr: False # (bool) use cosine learning rate scheduler
33
- close_mosaic: 10 # (int) disable mosaic augmentation for final epochs (0 to disable)
34
- resume: False # (bool) resume training from last checkpoint
35
- amp: True # (bool) Automatic Mixed Precision (AMP) training, choices=[True, False], True runs AMP check
36
- fraction: 1.0 # (float) dataset fraction to train on (default is 1.0, all images in train set)
37
- profile: False # (bool) profile ONNX and TensorRT speeds during training for loggers
38
- freeze: # (int | list, optional) freeze first n layers, or freeze list of layer indices during training
39
- multi_scale: False # (bool) Whether to use multiscale during training
40
- compile: False # (bool) Run torch.compile() on the model before train/val/predict
29
+ deterministic: True # (bool) enable deterministic ops; reproducible but may be slower
30
+ single_cls: False # (bool) treat all classes as a single class
31
+ rect: False # (bool) rectangular batches for train; rectangular batching for val when mode='val'
32
+ cos_lr: False # (bool) cosine learning rate scheduler
33
+ close_mosaic: 10 # (int) disable mosaic augmentation for final N epochs (0 to keep enabled)
34
+ resume: False # (bool) resume training from last checkpoint in the run dir
35
+ amp: True # (bool) Automatic Mixed Precision (AMP) training; True runs AMP capability check
36
+ fraction: 1.0 # (float) fraction of training dataset to use (1.0 = all)
37
+ profile: False # (bool) profile ONNX/TensorRT speeds during training for loggers
38
+ freeze: # (int | list, optional) freeze first N layers (int) or specific layer indices (list)
39
+ multi_scale: False # (bool) multiscale training by varying image size
40
+ compile: False # (bool | str) enable torch.compile() backend='inductor'; True="default", False=off, or "default|reduce-overhead|max-autotune"
41
+
41
42
  # Segmentation
42
- overlap_mask: True # (bool) merge object masks into a single image mask during training (segment train only)
43
- mask_ratio: 4 # (int) mask downsample ratio (segment train only)
43
+ overlap_mask: True # (bool) merge instance masks into one mask during training (segment only)
44
+ mask_ratio: 4 # (int) mask downsample ratio (segment only)
45
+
44
46
  # Classification
45
- dropout: 0.0 # (float) use dropout regularization (classify train only)
47
+ dropout: 0.0 # (float) dropout for classification head (classify only)
46
48
 
47
49
  # Val/Test settings ----------------------------------------------------------------------------------------------------
48
- val: True # (bool) validate/test during training
49
- split: val # (str) dataset split to use for validation, i.e. 'val', 'test' or 'train'
50
- save_json: False # (bool) save results to JSON file
51
- conf: # (float, optional) object confidence threshold for detection (default 0.25 predict, 0.001 val)
52
- iou: 0.7 # (float) intersection over union (IoU) threshold for NMS
50
+ val: True # (bool) run validation/testing during training
51
+ split: val # (str) dataset split to evaluate: 'val', 'test' or 'train'
52
+ save_json: False # (bool) save results to COCO JSON for external evaluation
53
+ conf: # (float, optional) confidence threshold; defaults: predict=0.25, val=0.001
54
+ iou: 0.7 # (float) IoU threshold used for NMS
53
55
  max_det: 300 # (int) maximum number of detections per image
54
- half: False # (bool) use half precision (FP16)
56
+ half: False # (bool) use half precision (FP16) if supported
55
57
  dnn: False # (bool) use OpenCV DNN for ONNX inference
56
58
  plots: True # (bool) save plots and images during train/val
57
59
 
58
60
  # Predict settings -----------------------------------------------------------------------------------------------------
59
- source: # (str, optional) source directory for images or videos
60
- vid_stride: 1 # (int) video frame-rate stride
61
- stream_buffer: False # (bool) buffer all streaming frames (True) or return the most recent frame (False)
62
- visualize: False # (bool) visualize model features (predict) or visualize TP, FP, FN (val)
63
- augment: False # (bool) apply image augmentation to prediction sources
61
+ source: # (str, optional) path/dir/URL/stream for images or videos; e.g. 'ultralytics/assets' or '0' for webcam
62
+ vid_stride: 1 # (int) read every Nth frame for video sources
63
+ stream_buffer: False # (bool) True buffers all frames; False keeps the most recent frame for low-latency streams
64
+ visualize: False # (bool) visualize model features (predict) or TP/FP/FN confusion (val)
65
+ augment: False # (bool) apply test-time augmentation during prediction
64
66
  agnostic_nms: False # (bool) class-agnostic NMS
65
- classes: # (int | list[int], optional) filter results by class, i.e. classes=0, or classes=[0,2,3]
66
- retina_masks: False # (bool) use high-resolution segmentation masks
67
- embed: # (list[int], optional) return feature vectors/embeddings from given layers
67
+ classes: # (int | list[int], optional) filter by class id(s), e.g. 0 or [0,2,3]
68
+ retina_masks: False # (bool) use high-resolution segmentation masks (segment)
69
+ embed: # (list[int], optional) return feature embeddings from given layer indices
68
70
 
69
71
  # Visualize settings ---------------------------------------------------------------------------------------------------
70
- show: False # (bool) show predicted images and videos if environment allows
71
- save_frames: False # (bool) save predicted individual video frames
72
- save_txt: False # (bool) save results as .txt file
73
- save_conf: False # (bool) save results with confidence scores
74
- save_crop: False # (bool) save cropped images with results
75
- show_labels: True # (bool) show prediction labels, i.e. 'person'
76
- show_conf: True # (bool) show prediction confidence, i.e. '0.99'
77
- show_boxes: True # (bool) show prediction boxes
78
- line_width: # (int, optional) line width of the bounding boxes. Scaled to image size if None.
72
+ show: False # (bool) show images/videos in a window if supported
73
+ save_frames: False # (bool) save individual frames from video predictions
74
+ save_txt: False # (bool) save results as .txt files (xywh format)
75
+ save_conf: False # (bool) save confidence scores with results
76
+ save_crop: False # (bool) save cropped prediction regions to files
77
+ show_labels: True # (bool) draw class labels on images, e.g. 'person'
78
+ show_conf: True # (bool) draw confidence values on images, e.g. '0.99'
79
+ show_boxes: True # (bool) draw bounding boxes on images
80
+ line_width: # (int, optional) line width of boxes; auto-scales with image size if not set
79
81
 
80
82
  # Export settings ------------------------------------------------------------------------------------------------------
81
- format: torchscript # (str) format to export to, choices at https://docs.ultralytics.com/modes/export/#export-formats
82
- keras: False # (bool) use Kera=s
83
- optimize: False # (bool) TorchScript: optimize for mobile
84
- int8: False # (bool) CoreML/TF INT8 quantization
85
- dynamic: False # (bool) ONNX/TF/TensorRT: dynamic axes
86
- simplify: True # (bool) ONNX: simplify model using `onnxslim`
87
- opset: # (int, optional) ONNX: opset version
88
- workspace: # (float, optional) TensorRT: workspace size (GiB), `None` will let TensorRT auto-allocate memory
89
- nms: False # (bool) CoreML: add NMS
83
+ format: torchscript # (str) target format, e.g. torchscript|onnx|openvino|engine|coreml|saved_model|pb|tflite|edgetpu|tfjs|paddle|mnn|ncnn|imx|rknn
84
+ keras: False # (bool) TF SavedModel only (format=saved_model); enable Keras layers during export
85
+ optimize: False # (bool) TorchScript only; apply mobile optimizations to the scripted model
86
+ int8: False # (bool) INT8/PTQ where supported (openvino, tflite, tfjs, engine, imx); needs calibration data/fraction
87
+ dynamic: False # (bool) dynamic shapes for torchscript, onnx, openvino, engine; enable variable image sizes
88
+ simplify: True # (bool) ONNX/engine only; run graph simplifier for cleaner ONNX before runtime conversion
89
+ opset: # (int, optional) ONNX/engine only; opset version for export; leave unset to use a tested default
90
+ workspace: # (float, optional) engine (TensorRT) only; workspace size in GiB, e.g. 4
91
+ nms: False # (bool) fuse NMS into exported model when backend supports; if True, conf/iou apply (agnostic_nms except coreml)
90
92
 
91
93
  # Hyperparameters ------------------------------------------------------------------------------------------------------
92
- lr0: 0.01 # (float) initial learning rate (i.e. SGD=1E-2, Adam=1E-3)
93
- lrf: 0.01 # (float) final learning rate (lr0 * lrf)
94
- momentum: 0.937 # (float) SGD momentum/Adam beta1
95
- weight_decay: 0.0005 # (float) optimizer weight decay 5e-4
96
- warmup_epochs: 3.0 # (float) warmup epochs (fractions ok)
97
- warmup_momentum: 0.8 # (float) warmup initial momentum
98
- warmup_bias_lr: 0.1 # (float) warmup initial bias lr
94
+ lr0: 0.01 # (float) initial learning rate (SGD=1e-2, Adam/AdamW=1e-3)
95
+ lrf: 0.01 # (float) final LR fraction; final LR = lr0 * lrf
96
+ momentum: 0.937 # (float) SGD momentum or Adam beta1
97
+ weight_decay: 0.0005 # (float) weight decay (L2 regularization)
98
+ warmup_epochs: 3.0 # (float) warmup epochs (fractions allowed)
99
+ warmup_momentum: 0.8 # (float) initial momentum during warmup
100
+ warmup_bias_lr: 0.1 # (float) bias learning rate during warmup
99
101
  box: 7.5 # (float) box loss gain
100
- cls: 0.5 # (float) cls loss gain (scale with pixels)
101
- dfl: 1.5 # (float) dfl loss gain
102
- pose: 12.0 # (float) pose loss gain
103
- kobj: 1.0 # (float) keypoint obj loss gain
104
- nbs: 64 # (int) nominal batch size
105
- hsv_h: 0.015 # (float) image HSV-Hue augmentation (fraction)
106
- hsv_s: 0.7 # (float) image HSV-Saturation augmentation (fraction)
107
- hsv_v: 0.4 # (float) image HSV-Value augmentation (fraction)
108
- degrees: 0.0 # (float) image rotation (+/- deg)
109
- translate: 0.1 # (float) image translation (+/- fraction)
110
- scale: 0.5 # (float) image scale (+/- gain)
111
- shear: 0.0 # (float) image shear (+/- deg)
112
- perspective: 0.0 # (float) image perspective (+/- fraction), range 0-0.001
113
- flipud: 0.0 # (float) image flip up-down (probability)
114
- fliplr: 0.5 # (float) image flip left-right (probability)
115
- bgr: 0.0 # (float) image channel BGR (probability)
116
- mosaic: 1.0 # (float) image mosaic (probability)
117
- mixup: 0.0 # (float) image mixup (probability)
118
- cutmix: 0.0 # (float) image cutmix (probability)
119
- copy_paste: 0.0 # (float) segment copy-paste (probability)
120
- copy_paste_mode: "flip" # (str) the method to do copy_paste augmentation (flip, mixup)
121
- auto_augment: randaugment # (str) auto augmentation policy for classification (randaugment, autoaugment, augmix)
122
- erasing: 0.4 # (float) probability of random erasing during classification training (0-0.9), 0 means no erasing, must be less than 1.0.
102
+ cls: 0.5 # (float) classification loss gain
103
+ dfl: 1.5 # (float) distribution focal loss gain
104
+ pose: 12.0 # (float) pose loss gain (pose tasks)
105
+ kobj: 1.0 # (float) keypoint objectness loss gain (pose tasks)
106
+ nbs: 64 # (int) nominal batch size used for loss normalization
107
+ hsv_h: 0.015 # (float) HSV hue augmentation fraction
108
+ hsv_s: 0.7 # (float) HSV saturation augmentation fraction
109
+ hsv_v: 0.4 # (float) HSV value (brightness) augmentation fraction
110
+ degrees: 0.0 # (float) rotation degrees (+/-)
111
+ translate: 0.1 # (float) translation fraction (+/-)
112
+ scale: 0.5 # (float) scale gain (+/-)
113
+ shear: 0.0 # (float) shear degrees (+/-)
114
+ perspective: 0.0 # (float) perspective fraction (00.001 typical)
115
+ flipud: 0.0 # (float) vertical flip probability
116
+ fliplr: 0.5 # (float) horizontal flip probability
117
+ bgr: 0.0 # (float) RGB↔BGR channel swap probability
118
+ mosaic: 1.0 # (float) mosaic augmentation probability
119
+ mixup: 0.0 # (float) MixUp augmentation probability
120
+ cutmix: 0.0 # (float) CutMix augmentation probability
121
+ copy_paste: 0.0 # (float) segmentation copy-paste probability
122
+ copy_paste_mode: flip # (str) copy-paste strategy for segmentation: flip or mixup
123
+ auto_augment: randaugment # (str) classification auto augmentation policy: randaugment, autoaugment, augmix
124
+ erasing: 0.4 # (float) random erasing probability for classification (00.9), <1.0
123
125
 
124
126
  # Custom config.yaml ---------------------------------------------------------------------------------------------------
125
- cfg: # (str, optional) for overriding defaults.yaml
127
+ cfg: # (str, optional) path to a config.yaml that overrides defaults
126
128
 
127
129
  # Tracker settings ------------------------------------------------------------------------------------------------------
128
- tracker: botsort.yaml # (str) tracker type, choices=[botsort.yaml, bytetrack.yaml]
130
+ tracker: botsort.yaml # (str) tracker config file: botsort.yaml or bytetrack.yaml
@@ -1,22 +1,21 @@
1
1
  # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
2
 
3
- # Default Ultralytics settings for BoT-SORT tracker when using mode="track"
4
- # For documentation and examples see https://docs.ultralytics.com/modes/track/
5
- # For BoT-SORT source code see https://github.com/NirAharon/BoT-SORT
3
+ # BoT-SORT tracker defaults for mode="track"
4
+ # Docs: https://docs.ultralytics.com/modes/track/
6
5
 
7
- tracker_type: botsort # tracker type, ['botsort', 'bytetrack']
8
- track_high_thresh: 0.25 # threshold for the first association
9
- track_low_thresh: 0.1 # threshold for the second association
10
- new_track_thresh: 0.25 # threshold for init new track if the detection does not match any tracks
11
- track_buffer: 30 # buffer to calculate the time when to remove tracks
12
- match_thresh: 0.8 # threshold for matching tracks
13
- fuse_score: True # Whether to fuse confidence scores with the iou distances before matching
14
- # min_box_area: 10 # threshold for min box areas(for tracker evaluation, not used for now)
6
+ tracker_type: botsort # (str) Tracker backend: botsort|bytetrack; choose botsort to enable BoT-SORT features
7
+ track_high_thresh: 0.25 # (float) First-stage match threshold; raise for cleaner tracks, lower to keep more
8
+ track_low_thresh: 0.1 # (float) Second-stage threshold for low-score matches; balances recovery vs drift
9
+ new_track_thresh: 0.25 # (float) Start a new track if no match this; higher reduces false tracks
10
+ track_buffer: 30 # (int) Frames to keep lost tracks alive; higher handles occlusion, increases ID switches risk
11
+ match_thresh: 0.8 # (float) Association similarity threshold (IoU/cost); tune with detector quality
12
+ fuse_score: True # (bool) Fuse detection score with motion/IoU for matching; stabilizes weak detections
13
+
14
+ # BoT-SORT specifics
15
+ gmc_method: sparseOptFlow # (str) Global motion compensation: sparseOptFlow|orb|none; helps moving camera scenes
15
16
 
16
- # BoT-SORT settings
17
- gmc_method: sparseOptFlow # method of global motion compensation
18
17
  # ReID model related thresh
19
- proximity_thresh: 0.5 # minimum IoU for valid match with ReID
20
- appearance_thresh: 0.8 # minimum appearance similarity for ReID
21
- with_reid: False
22
- model: auto # uses native features if detector is YOLO else yolo11n-cls.pt
18
+ proximity_thresh: 0.5 # (float) Min IoU to consider tracks proximate for ReID; higher is stricter
19
+ appearance_thresh: 0.8 # (float) Min appearance similarity for ReID; raise to avoid identity swaps
20
+ with_reid: False # (bool) Enable ReID model use; needs extra model and compute
21
+ model: auto # (str) ReID model name/path; "auto" uses detector features if available
@@ -1,14 +1,12 @@
1
1
  # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
2
 
3
- # Default Ultralytics settings for ByteTrack tracker when using mode="track"
4
- # For documentation and examples see https://docs.ultralytics.com/modes/track/
5
- # For ByteTrack source code see https://github.com/ifzhang/ByteTrack
3
+ # ByteTrack tracker defaults for mode="track"
4
+ # Docs: https://docs.ultralytics.com/modes/track/
6
5
 
7
- tracker_type: bytetrack # tracker type, ['botsort', 'bytetrack']
8
- track_high_thresh: 0.25 # threshold for the first association
9
- track_low_thresh: 0.1 # threshold for the second association
10
- new_track_thresh: 0.25 # threshold for init new track if the detection does not match any tracks
11
- track_buffer: 30 # buffer to calculate the time when to remove tracks
12
- match_thresh: 0.8 # threshold for matching tracks
13
- fuse_score: True # Whether to fuse confidence scores with the iou distances before matching
14
- # min_box_area: 10 # threshold for min box areas(for tracker evaluation, not used for now)
6
+ tracker_type: bytetrack # (str) Tracker backend: botsort|bytetrack; choose bytetrack for the classic baseline
7
+ track_high_thresh: 0.25 # (float) First-stage match threshold; raise for cleaner tracks, lower to keep more
8
+ track_low_thresh: 0.1 # (float) Second-stage threshold for low-score matches; balances recovery vs drift
9
+ new_track_thresh: 0.25 # (float) Start a new track if no match this; higher reduces false tracks
10
+ track_buffer: 30 # (int) Frames to keep lost tracks alive; higher handles occlusion, increases ID switches risk
11
+ match_thresh: 0.8 # (float) Association similarity threshold (IoU/cost); tune with detector quality
12
+ fuse_score: True # (bool) Fuse detection score with motion/IoU for matching; stabilizes weak detections
@@ -2382,7 +2382,7 @@ class LoadVisualPrompt:
2382
2382
  # assert len(cls_unique) == cls_unique[-1] + 1, (
2383
2383
  # f"Expected a continuous range of class indices, but got {cls_unique}"
2384
2384
  # )
2385
- visuals = torch.zeros(len(cls_unique), *masksz)
2385
+ visuals = torch.zeros(cls_unique.shape[0], *masksz)
2386
2386
  for idx, mask in zip(inverse_indices, masks):
2387
2387
  visuals[idx] = torch.logical_or(visuals[idx], mask)
2388
2388
  return visuals
@@ -172,7 +172,7 @@ class YOLODataset(BaseDataset):
172
172
  cache, exists = load_dataset_cache_file(cache_path), True # attempt to load a *.cache file
173
173
  assert cache["version"] == DATASET_CACHE_VERSION # matches current version
174
174
  assert cache["hash"] == get_hash(self.label_files + self.im_files) # identical hash
175
- except (FileNotFoundError, AssertionError, AttributeError):
175
+ except (FileNotFoundError, AssertionError, AttributeError, ModuleNotFoundError):
176
176
  cache, exists = self.cache_labels(cache_path), False # run cache ops
177
177
 
178
178
  # Display cache
@@ -194,9 +194,9 @@ def try_export(inner_func):
194
194
  dt = 0.0
195
195
  try:
196
196
  with Profile() as dt:
197
- f, model = inner_func(*args, **kwargs)
197
+ f = inner_func(*args, **kwargs)
198
198
  LOGGER.info(f"{prefix} export success ✅ {dt.t:.1f}s, saved as '{f}' ({file_size(f):.1f} MB)")
199
- return f, model
199
+ return f
200
200
  except Exception as e:
201
201
  LOGGER.error(f"{prefix} export failure {dt.t:.1f}s: {e}")
202
202
  raise e
@@ -486,36 +486,36 @@ class Exporter:
486
486
  # Exports
487
487
  f = [""] * len(fmts) # exported filenames
488
488
  if jit or ncnn: # TorchScript
489
- f[0], _ = self.export_torchscript()
489
+ f[0] = self.export_torchscript()
490
490
  if engine: # TensorRT required before ONNX
491
- f[1], _ = self.export_engine(dla=dla)
491
+ f[1] = self.export_engine(dla=dla)
492
492
  if onnx: # ONNX
493
- f[2], _ = self.export_onnx()
493
+ f[2] = self.export_onnx()
494
494
  if xml: # OpenVINO
495
- f[3], _ = self.export_openvino()
495
+ f[3] = self.export_openvino()
496
496
  if coreml: # CoreML
497
- f[4], _ = self.export_coreml()
497
+ f[4] = self.export_coreml()
498
498
  if is_tf_format: # TensorFlow formats
499
499
  self.args.int8 |= edgetpu
500
500
  f[5], keras_model = self.export_saved_model()
501
501
  if pb or tfjs: # pb prerequisite to tfjs
502
- f[6], _ = self.export_pb(keras_model=keras_model)
502
+ f[6] = self.export_pb(keras_model=keras_model)
503
503
  if tflite:
504
- f[7], _ = self.export_tflite()
504
+ f[7] = self.export_tflite()
505
505
  if edgetpu:
506
- f[8], _ = self.export_edgetpu(tflite_model=Path(f[5]) / f"{self.file.stem}_full_integer_quant.tflite")
506
+ f[8] = self.export_edgetpu(tflite_model=Path(f[5]) / f"{self.file.stem}_full_integer_quant.tflite")
507
507
  if tfjs:
508
- f[9], _ = self.export_tfjs()
508
+ f[9] = self.export_tfjs()
509
509
  if paddle: # PaddlePaddle
510
- f[10], _ = self.export_paddle()
510
+ f[10] = self.export_paddle()
511
511
  if mnn: # MNN
512
- f[11], _ = self.export_mnn()
512
+ f[11] = self.export_mnn()
513
513
  if ncnn: # NCNN
514
- f[12], _ = self.export_ncnn()
514
+ f[12] = self.export_ncnn()
515
515
  if imx:
516
- f[13], _ = self.export_imx()
516
+ f[13] = self.export_imx()
517
517
  if rknn:
518
- f[14], _ = self.export_rknn()
518
+ f[14] = self.export_rknn()
519
519
 
520
520
  # Finish
521
521
  f = [str(x) for x in f if x] # filter out '' and None
@@ -580,7 +580,7 @@ class Exporter:
580
580
  optimize_for_mobile(ts)._save_for_lite_interpreter(str(f), _extra_files=extra_files)
581
581
  else:
582
582
  ts.save(str(f), _extra_files=extra_files)
583
- return f, None
583
+ return f
584
584
 
585
585
  @try_export
586
586
  def export_onnx(self, prefix=colorstr("ONNX:")):
@@ -639,7 +639,7 @@ class Exporter:
639
639
  meta.key, meta.value = k, str(v)
640
640
 
641
641
  onnx.save(model_onnx, f)
642
- return f, model_onnx
642
+ return f
643
643
 
644
644
  @try_export
645
645
  def export_openvino(self, prefix=colorstr("OpenVINO:")):
@@ -708,13 +708,13 @@ class Exporter:
708
708
  ignored_scope=ignored_scope,
709
709
  )
710
710
  serialize(quantized_ov_model, fq_ov)
711
- return fq, None
711
+ return fq
712
712
 
713
713
  f = str(self.file).replace(self.file.suffix, f"_openvino_model{os.sep}")
714
714
  f_ov = str(Path(f) / self.file.with_suffix(".xml").name)
715
715
 
716
716
  serialize(ov_model, f_ov)
717
- return f, None
717
+ return f
718
718
 
719
719
  @try_export
720
720
  def export_paddle(self, prefix=colorstr("PaddlePaddle:")):
@@ -738,12 +738,12 @@ class Exporter:
738
738
 
739
739
  pytorch2paddle(module=self.model, save_dir=f, jit_type="trace", input_examples=[self.im]) # export
740
740
  YAML.save(Path(f) / "metadata.yaml", self.metadata) # add metadata.yaml
741
- return f, None
741
+ return f
742
742
 
743
743
  @try_export
744
744
  def export_mnn(self, prefix=colorstr("MNN:")):
745
745
  """Export YOLO model to MNN format using MNN https://github.com/alibaba/MNN."""
746
- f_onnx, _ = self.export_onnx() # get onnx model first
746
+ f_onnx = self.export_onnx() # get onnx model first
747
747
 
748
748
  check_requirements("MNN>=2.9.6")
749
749
  import MNN # noqa
@@ -763,7 +763,7 @@ class Exporter:
763
763
  convert_scratch = Path(self.file.parent / ".__convert_external_data.bin")
764
764
  if convert_scratch.exists():
765
765
  convert_scratch.unlink()
766
- return f, None
766
+ return f
767
767
 
768
768
  @try_export
769
769
  def export_ncnn(self, prefix=colorstr("NCNN:")):
@@ -831,7 +831,7 @@ class Exporter:
831
831
  Path(f_debug).unlink(missing_ok=True)
832
832
 
833
833
  YAML.save(f / "metadata.yaml", self.metadata) # add metadata.yaml
834
- return str(f), None
834
+ return str(f)
835
835
 
836
836
  @try_export
837
837
  def export_coreml(self, prefix=colorstr("CoreML:")):
@@ -910,13 +910,13 @@ class Exporter:
910
910
  )
911
911
  f = f.with_suffix(".mlmodel")
912
912
  ct_model.save(str(f))
913
- return f, ct_model
913
+ return f
914
914
 
915
915
  @try_export
916
916
  def export_engine(self, dla=None, prefix=colorstr("TensorRT:")):
917
917
  """Export YOLO model to TensorRT format https://developer.nvidia.com/tensorrt."""
918
918
  assert self.im.device.type != "cpu", "export running on CPU but must be on GPU, i.e. use 'device=0'"
919
- f_onnx, _ = self.export_onnx() # run before TRT import https://github.com/ultralytics/ultralytics/issues/7016
919
+ f_onnx = self.export_onnx() # run before TRT import https://github.com/ultralytics/ultralytics/issues/7016
920
920
 
921
921
  try:
922
922
  import tensorrt as trt # noqa
@@ -946,7 +946,7 @@ class Exporter:
946
946
  prefix=prefix,
947
947
  )
948
948
 
949
- return f, None
949
+ return f
950
950
 
951
951
  @try_export
952
952
  def export_saved_model(self, prefix=colorstr("TensorFlow SavedModel:")):
@@ -991,7 +991,7 @@ class Exporter:
991
991
 
992
992
  # Export to ONNX
993
993
  self.args.simplify = True
994
- f_onnx, _ = self.export_onnx()
994
+ f_onnx = self.export_onnx()
995
995
 
996
996
  # Export to TF
997
997
  np_data = None
@@ -1051,7 +1051,7 @@ class Exporter:
1051
1051
  frozen_func = convert_variables_to_constants_v2(m)
1052
1052
  frozen_func.graph.as_graph_def()
1053
1053
  tf.io.write_graph(graph_or_graph_def=frozen_func.graph, logdir=str(f.parent), name=f.name, as_text=False)
1054
- return f, None
1054
+ return f
1055
1055
 
1056
1056
  @try_export
1057
1057
  def export_tflite(self, prefix=colorstr("TensorFlow Lite:")):
@@ -1067,7 +1067,7 @@ class Exporter:
1067
1067
  f = saved_model / f"{self.file.stem}_float16.tflite" # fp32 in/out
1068
1068
  else:
1069
1069
  f = saved_model / f"{self.file.stem}_float32.tflite"
1070
- return str(f), None
1070
+ return str(f)
1071
1071
 
1072
1072
  @try_export
1073
1073
  def export_edgetpu(self, tflite_model="", prefix=colorstr("Edge TPU:")):
@@ -1102,7 +1102,7 @@ class Exporter:
1102
1102
  LOGGER.info(f"{prefix} running '{cmd}'")
1103
1103
  subprocess.run(cmd, shell=True)
1104
1104
  self._add_tflite_metadata(f)
1105
- return f, None
1105
+ return f
1106
1106
 
1107
1107
  @try_export
1108
1108
  def export_tfjs(self, prefix=colorstr("TensorFlow.js:")):
@@ -1135,7 +1135,7 @@ class Exporter:
1135
1135
 
1136
1136
  # Add metadata
1137
1137
  YAML.save(Path(f) / "metadata.yaml", self.metadata) # add metadata.yaml
1138
- return f, None
1138
+ return f
1139
1139
 
1140
1140
  @try_export
1141
1141
  def export_rknn(self, prefix=colorstr("RKNN:")):
@@ -1151,7 +1151,7 @@ class Exporter:
1151
1151
 
1152
1152
  from rknn.api import RKNN
1153
1153
 
1154
- f, _ = self.export_onnx()
1154
+ f = self.export_onnx()
1155
1155
  export_path = Path(f"{Path(f).stem}_rknn_model")
1156
1156
  export_path.mkdir(exist_ok=True)
1157
1157
 
@@ -1162,7 +1162,7 @@ class Exporter:
1162
1162
  f = f.replace(".onnx", f"-{self.args.name}.rknn")
1163
1163
  rknn.export_rknn(f"{export_path / f}")
1164
1164
  YAML.save(export_path / "metadata.yaml", self.metadata)
1165
- return export_path, None
1165
+ return export_path
1166
1166
 
1167
1167
  @try_export
1168
1168
  def export_imx(self, prefix=colorstr("IMX:")):
@@ -1339,7 +1339,7 @@ class Exporter:
1339
1339
  with open(f / "labels.txt", "w", encoding="utf-8") as file:
1340
1340
  file.writelines([f"{name}\n" for _, name in self.model.names.items()])
1341
1341
 
1342
- return f, None
1342
+ return f
1343
1343
 
1344
1344
  def _add_tflite_metadata(self, file):
1345
1345
  """Add metadata to *.tflite models per https://ai.google.dev/edge/litert/models/metadata."""
@@ -409,8 +409,7 @@ class BasePredictor:
409
409
  if hasattr(self.model, "imgsz") and not getattr(self.model, "dynamic", False):
410
410
  self.args.imgsz = self.model.imgsz # reuse imgsz from export metadata
411
411
  self.model.eval()
412
- if self.args.compile:
413
- self.model = attempt_compile(self.model, device=self.device)
412
+ self.model = attempt_compile(self.model, device=self.device, mode=self.args.compile)
414
413
 
415
414
  def write_results(self, i: int, p: Path, im: torch.Tensor, s: list[str]) -> str:
416
415
  """
@@ -900,7 +900,7 @@ class Boxes(BaseTensor):
900
900
  Args:
901
901
  boxes (torch.Tensor | np.ndarray): A tensor or numpy array with detection boxes of shape
902
902
  (num_boxes, 6) or (num_boxes, 7). Columns should contain
903
- [x1, y1, x2, y2, confidence, class, (optional) track_id].
903
+ [x1, y1, x2, y2, (optional) track_id, confidence, class].
904
904
  orig_shape (tuple[int, int]): The original image shape as (height, width). Used for normalization.
905
905
 
906
906
  Attributes:
@@ -42,6 +42,7 @@ from ultralytics.utils.autobatch import check_train_batch_size
42
42
  from ultralytics.utils.checks import check_amp, check_file, check_imgsz, check_model_file_from_stem, print_args
43
43
  from ultralytics.utils.dist import ddp_cleanup, generate_ddp_command
44
44
  from ultralytics.utils.files import get_latest_run
45
+ from ultralytics.utils.plotting import plot_results
45
46
  from ultralytics.utils.torch_utils import (
46
47
  TORCH_2_4,
47
48
  EarlyStopping,
@@ -261,8 +262,7 @@ class BaseTrainer:
261
262
  self.model.criterion = self.model.init_criterion()
262
263
 
263
264
  # Compile model
264
- if self.args.compile:
265
- self.model = attempt_compile(self.model, device=self.device)
265
+ self.model = attempt_compile(self.model, device=self.device, mode=self.args.compile)
266
266
 
267
267
  # Freeze layers
268
268
  freeze_list = (
@@ -414,7 +414,7 @@ class BaseTrainer:
414
414
  batch = self.preprocess_batch(batch)
415
415
  # decouple inference and loss calculations for torch.compile convenience
416
416
  preds = self.model(batch["img"])
417
- loss, self.loss_items = self.model.loss(batch, preds)
417
+ loss, self.loss_items = unwrap_model(self.model).loss(batch, preds)
418
418
  self.loss = loss.sum()
419
419
  if RANK != -1:
420
420
  self.loss *= world_size
@@ -743,8 +743,8 @@ class BaseTrainer:
743
743
  f.write(s + ("%.6g," * n % tuple([self.epoch + 1, t] + vals)).rstrip(",") + "\n")
744
744
 
745
745
  def plot_metrics(self):
746
- """Plot and display metrics visually."""
747
- pass
746
+ """Plot metrics from a CSV file."""
747
+ plot_results(file=self.csv, on_plot=self.on_plot) # save results.png
748
748
 
749
749
  def on_plot(self, name, data=None):
750
750
  """Register plots (e.g. to be consumed in callbacks)."""