Skip to content

Commit e7876e1

Browse files
glenn-jochersthemeowdh031200pre-commit-ci[bot]dependabot[bot]
authored
ultralytics 8.0.59 new MLFlow and feature updates (ultralytics#1720)
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: St. HeMeow <[email protected]> Co-authored-by: Danny Kim <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Torge Kummerow <[email protected]> Co-authored-by: dankernel <[email protected]> Co-authored-by: Burhan <[email protected]> Co-authored-by: Roshanlal <[email protected]> Co-authored-by: Lorenzo Mammana <[email protected]> Co-authored-by: Yonghye Kwon <[email protected]>
1 parent ccb6419 commit e7876e1

File tree

29 files changed

+326
-160
lines changed

29 files changed

+326
-160
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
push:
88
branches: [main]
99
pull_request:
10-
branches: [main, updates]
10+
branches: [main]
1111
schedule:
1212
- cron: '0 0 * * *' # runs at 00:00 UTC every day
1313

.github/workflows/links.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ name: Check Broken links
55

66
on:
77
push:
8-
branches: [na]
8+
branches: [main]
99
pull_request:
10-
branches: [na]
10+
branches: [main]
1111
workflow_dispatch:
1212
schedule:
1313
- cron: '0 0 * * *' # runs at 00:00 UTC every day

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
stale:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/stale@v7
12+
- uses: actions/stale@v8
1313
with:
1414
repo-token: ${{ secrets.GITHUB_TOKEN }}
1515

docs/modes/predict.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ operations are cached, meaning they're only calculated once per object, and thos
152152
```python
153153
results = model(inputs)
154154
masks = results[0].masks # Masks object
155-
masks.segments # bounding coordinates of masks, List[segment] * N
155+
masks.xy # x, y segments (pixels), List[segment] * N
156+
masks.xyn # x, y segments (normalized), List[segment] * N
156157
masks.data # raw masks tensor, (N, H, W) or masks.masks
157158
```
158159

@@ -185,3 +186,47 @@ masks, classification logits, etc.) found in the results object
185186
- `show_conf (bool)`: Show confidence
186187
- `line_width (Float)`: The line width of boxes. Automatically scaled to img size if not provided
187188
- `font_size (Float)`: The font size of . Automatically scaled to img size if not provided
189+
190+
## Streaming Source `for`-loop
191+
192+
Here's a Python script using OpenCV (cv2) and YOLOv8 to run inference on video frames. This script assumes you have already installed the necessary packages (opencv-python and ultralytics).
193+
194+
!!! example "Streaming for-loop"
195+
196+
```python
197+
import cv2
198+
from ultralytics import YOLO
199+
200+
# Load the YOLOv8 model
201+
model = YOLO('yolov8n.pt')
202+
203+
# Open the video file
204+
video_path = "path/to/your/video/file.mp4"
205+
cap = cv2.VideoCapture(video_path)
206+
207+
# Loop through the video frames
208+
while cap.isOpened():
209+
# Read a frame from the video
210+
success, frame = cap.read()
211+
212+
if success:
213+
# Run YOLOv8 inference on the frame
214+
results = model(frame)
215+
216+
# Visualize the results on the frame
217+
annotated_frame = results[0].plot()
218+
219+
# Display the annotated frame
220+
cv2.imshow("YOLOv8 Inference", annotated_frame)
221+
222+
# Break the loop if 'q' is pressed
223+
if cv2.waitKey(1) & 0xFF == ord("q"):
224+
break
225+
else:
226+
# Break the loop if the end of the video is reached
227+
break
228+
229+
# Release the video capture object and close the display window
230+
cap.release()
231+
cv2.destroyAllWindows()
232+
```

docs/modes/train.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ task.
7373
| `deterministic` | `True` | whether to enable deterministic mode |
7474
| `single_cls` | `False` | train multi-class data as single-class |
7575
| `image_weights` | `False` | use weighted image selection for training |
76-
| `rect` | `False` | support rectangular training |
76+
| `rect` | `False` | rectangular training with each batch collated for minimum padding |
7777
| `cos_lr` | `False` | use cosine learning rate scheduler |
7878
| `close_mosaic` | `10` | disable mosaic augmentation for final 10 epochs |
7979
| `resume` | `False` | resume training from last checkpoint |

docs/modes/val.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ validation dataset and to detect and prevent overfitting.
6262
| `device` | `None` | device to run on, i.e. cuda device=0/1/2/3 or device=cpu |
6363
| `dnn` | `False` | use OpenCV DNN for ONNX inference |
6464
| `plots` | `False` | show plots during training |
65-
| `rect` | `False` | support rectangular evaluation |
65+
| `rect` | `False` | rectangular val with each batch collated for minimum padding |
6666
| `split` | `val` | dataset split to use for validation, i.e. 'val', 'test' or 'train' |
6767

6868
## Export Formats

docs/usage/callbacks.md

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -12,75 +12,74 @@ In this example, we want to return the original frame with each result object. H
1212

1313
```python
1414
def on_predict_batch_end(predictor):
15-
# results -> List[batch_size]
15+
# Retrieve the batch data
1616
_, _, im0s, _, _ = predictor.batch
17+
18+
# Ensure that im0s is a list
1719
im0s = im0s if isinstance(im0s, list) else [im0s]
20+
21+
# Combine the prediction results with the corresponding frames
1822
predictor.results = zip(predictor.results, im0s)
1923

24+
# Create a YOLO model instance
2025
model = YOLO(f'yolov8n.pt')
26+
27+
# Add the custom callback to the model
2128
model.add_callback("on_predict_batch_end", on_predict_batch_end)
29+
30+
# Iterate through the results and frames
2231
for (result, frame) in model.track/predict():
2332
pass
2433
```
2534

2635
## All callbacks
2736

28-
Here are all supported callbacks.
29-
30-
### Trainer
31-
32-
`on_pretrain_routine_start`
33-
34-
`on_pretrain_routine_end`
35-
36-
`on_train_start`
37-
38-
`on_train_epoch_start`
39-
40-
`on_train_batch_start`
41-
42-
`optimizer_step`
43-
44-
`on_before_zero_grad`
45-
46-
`on_train_batch_end`
47-
48-
`on_train_epoch_end`
49-
50-
`on_fit_epoch_end`
51-
52-
`on_model_save`
53-
54-
`on_train_end`
55-
56-
`on_params_update`
57-
58-
`teardown`
59-
60-
### Validator
61-
62-
`on_val_start`
63-
64-
`on_val_batch_start`
37+
Here are all supported callbacks. See callbacks [source code](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/yolo/utils/callbacks/base.py) for additional details.
6538

66-
`on_val_batch_end`
6739

68-
`on_val_end`
40+
### Trainer Callbacks
6941

70-
### Predictor
42+
| Callback | Description |
43+
|-----------------------------|---------------------------------------------------------|
44+
| `on_pretrain_routine_start` | Triggered at the beginning of pre-training routine |
45+
| `on_pretrain_routine_end` | Triggered at the end of pre-training routine |
46+
| `on_train_start` | Triggered when the training starts |
47+
| `on_train_epoch_start` | Triggered at the start of each training epoch |
48+
| `on_train_batch_start` | Triggered at the start of each training batch |
49+
| `optimizer_step` | Triggered during the optimizer step |
50+
| `on_before_zero_grad` | Triggered before gradients are zeroed |
51+
| `on_train_batch_end` | Triggered at the end of each training batch |
52+
| `on_train_epoch_end` | Triggered at the end of each training epoch |
53+
| `on_fit_epoch_end` | Triggered at the end of each fit epoch |
54+
| `on_model_save` | Triggered when the model is saved |
55+
| `on_train_end` | Triggered when the training process ends |
56+
| `on_params_update` | Triggered when model parameters are updated |
57+
| `teardown` | Triggered when the training process is being cleaned up |
7158

72-
`on_predict_start`
7359

74-
`on_predict_batch_start`
60+
### Validator Callbacks
7561

76-
`on_predict_postprocess_end`
62+
| Callback | Description |
63+
|----------------------|-------------------------------------------------|
64+
| `on_val_start` | Triggered when the validation starts |
65+
| `on_val_batch_start` | Triggered at the start of each validation batch |
66+
| `on_val_batch_end` | Triggered at the end of each validation batch |
67+
| `on_val_end` | Triggered when the validation ends |
7768

78-
`on_predict_batch_end`
7969

80-
`on_predict_end`
70+
### Predictor Callbacks
8171

82-
### Exporter
72+
| Callback | Description |
73+
|------------------------------|---------------------------------------------------|
74+
| `on_predict_start` | Triggered when the prediction process starts |
75+
| `on_predict_batch_start` | Triggered at the start of each prediction batch |
76+
| `on_predict_postprocess_end` | Triggered at the end of prediction postprocessing |
77+
| `on_predict_batch_end` | Triggered at the end of each prediction batch |
78+
| `on_predict_end` | Triggered when the prediction process ends |
8379

84-
`on_export_start`
80+
### Exporter Callbacks
8581

86-
`on_export_end`
82+
| Callback | Description |
83+
|-------------------|------------------------------------------|
84+
| `on_export_start` | Triggered when the export process starts |
85+
| `on_export_end` | Triggered when the export process ends |

docs/usage/cfg.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ YOLOv8 'yolo' CLI commands use the following syntax:
1212
yolo TASK MODE ARGS
1313
```
1414

15+
=== "Python"
16+
17+
```python
18+
from ultralytics import YOLO
19+
20+
# Load a YOLOv8 model from a pre-trained weights file
21+
model = YOLO('yolov8n.pt')
22+
23+
# Run MODE mode using the custom arguments ARGS (guess TASK)
24+
model.MODE(ARGS)
25+
```
26+
1527
Where:
1628

1729
- `TASK` (optional) is one of `[detect, segment, classify, pose]`. If it is not passed explicitly YOLOv8 will try to
@@ -36,6 +48,8 @@ differ in the type of output they produce and the specific problem they are desi
3648
|--------|------------|-------------------------------------------------|
3749
| `task` | `'detect'` | YOLO task, i.e. detect, segment, classify, pose |
3850

51+
[Tasks Guide](../tasks/index.md){ .md-button .md-button--primary}
52+
3953
#### Modes
4054

4155
YOLO models can be used in different modes depending on the specific problem you are trying to solve. These modes
@@ -52,14 +66,11 @@ include:
5266
|--------|-----------|---------------------------------------------------------------|
5367
| `mode` | `'train'` | YOLO mode, i.e. train, val, predict, export, track, benchmark |
5468

55-
### Training
69+
[Modes Guide](../modes/index.md){ .md-button .md-button--primary}
70+
71+
## Train
5672

57-
Training settings for YOLO models refer to the various hyperparameters and configurations used to train the model on a
58-
dataset. These settings can affect the model's performance, speed, and accuracy. Some common YOLO training settings
59-
include the batch size, learning rate, momentum, and weight decay. Other factors that may affect the training process
60-
include the choice of optimizer, the choice of loss function, and the size and composition of the training dataset. It
61-
is important to carefully tune and experiment with these settings to achieve the best possible performance for a given
62-
task.
73+
The training settings for YOLO models encompass various hyperparameters and configurations used during the training process. These settings influence the model's performance, speed, and accuracy. Key training settings include batch size, learning rate, momentum, and weight decay. Additionally, the choice of optimizer, loss function, and training dataset composition can impact the training process. Careful tuning and experimentation with these settings are crucial for optimizing performance.
6374

6475
| Key | Value | Description |
6576
|-------------------|----------|-----------------------------------------------------------------------------|
@@ -84,7 +95,7 @@ task.
8495
| `deterministic` | `True` | whether to enable deterministic mode |
8596
| `single_cls` | `False` | train multi-class data as single-class |
8697
| `image_weights` | `False` | use weighted image selection for training |
87-
| `rect` | `False` | support rectangular training |
98+
| `rect` | `False` | rectangular training with each batch collated for minimum padding |
8899
| `cos_lr` | `False` | use cosine learning rate scheduler |
89100
| `close_mosaic` | `10` | disable mosaic augmentation for final 10 epochs |
90101
| `resume` | `False` | resume training from last checkpoint |
@@ -107,15 +118,11 @@ task.
107118
| `dropout` | `0.0` | use dropout regularization (classify train only) |
108119
| `val` | `True` | validate/test during training |
109120

110-
### Prediction
121+
[Train Guide](../modes/train.md){ .md-button .md-button--primary}
111122

112-
Prediction settings for YOLO models refer to the various hyperparameters and configurations used to make predictions
113-
with the model on new data. These settings can affect the model's performance, speed, and accuracy. Some common YOLO
114-
prediction settings include the confidence threshold, non-maximum suppression (NMS) threshold, and the number of classes
115-
to consider. Other factors that may affect the prediction process include the size and format of the input data, the
116-
presence of additional features such as masks or multiple labels per box, and the specific task the model is being used
117-
for. It is important to carefully tune and experiment with these settings to achieve the best possible performance for a
118-
given task.
123+
## Predict
124+
125+
The prediction settings for YOLO models encompass a range of hyperparameters and configurations that influence the model's performance, speed, and accuracy during inference on new data. Careful tuning and experimentation with these settings are essential to achieve optimal performance for a specific task. Key settings include the confidence threshold, Non-Maximum Suppression (NMS) threshold, and the number of classes considered. Additional factors affecting the prediction process are input data size and format, the presence of supplementary features such as masks or multiple labels per box, and the particular task the model is employed for.
119126

120127
| Key | Value | Description |
121128
|------------------|------------------------|----------------------------------------------------------|
@@ -141,15 +148,11 @@ given task.
141148
| `classes` | `None` | filter results by class, i.e. class=0, or class=[0,2,3] |
142149
| `boxes` | `True` | Show boxes in segmentation predictions |
143150

144-
### Validation
151+
[Predict Guide](../modes/predict.md){ .md-button .md-button--primary}
152+
153+
## Val
145154

146-
Validation settings for YOLO models refer to the various hyperparameters and configurations used to
147-
evaluate the model's performance on a validation dataset. These settings can affect the model's performance, speed, and
148-
accuracy. Some common YOLO validation settings include the batch size, the frequency with which validation is performed
149-
during training, and the metrics used to evaluate the model's performance. Other factors that may affect the validation
150-
process include the size and composition of the validation dataset and the specific task the model is being used for. It
151-
is important to carefully tune and experiment with these settings to ensure that the model is performing well on the
152-
validation dataset and to detect and prevent overfitting.
155+
The val (validation) settings for YOLO models involve various hyperparameters and configurations used to evaluate the model's performance on a validation dataset. These settings influence the model's performance, speed, and accuracy. Common YOLO validation settings include batch size, validation frequency during training, and performance evaluation metrics. Other factors affecting the validation process include the validation dataset's size and composition, as well as the specific task the model is employed for. Careful tuning and experimentation with these settings are crucial to ensure optimal performance on the validation dataset and detect and prevent overfitting.
153156

154157
| Key | Value | Description |
155158
|---------------|---------|--------------------------------------------------------------------|
@@ -162,19 +165,14 @@ validation dataset and to detect and prevent overfitting.
162165
| `device` | `None` | device to run on, i.e. cuda device=0/1/2/3 or device=cpu |
163166
| `dnn` | `False` | use OpenCV DNN for ONNX inference |
164167
| `plots` | `False` | show plots during training |
165-
| `rect` | `False` | support rectangular evaluation |
168+
| `rect` | `False` | rectangular val with each batch collated for minimum padding |
166169
| `split` | `val` | dataset split to use for validation, i.e. 'val', 'test' or 'train' |
167170

168-
### Export
171+
[Val Guide](../modes/val.md){ .md-button .md-button--primary}
169172

170-
Export settings for YOLO models refer to the various configurations and options used to save or
171-
export the model for use in other environments or platforms. These settings can affect the model's performance, size,
172-
and compatibility with different systems. Some common YOLO export settings include the format of the exported model
173-
file (e.g. ONNX, TensorFlow SavedModel), the device on which the model will be run (e.g. CPU, GPU), and the presence of
174-
additional features such as masks or multiple labels per box. Other factors that may affect the export process include
175-
the specific task the model is being used for and the requirements or constraints of the target environment or platform.
176-
It is important to carefully consider and configure these settings to ensure that the exported model is optimized for
177-
the intended use case and can be used effectively in the target environment.
173+
## Export
174+
175+
Export settings for YOLO models encompass configurations and options related to saving or exporting the model for use in different environments or platforms. These settings can impact the model's performance, size, and compatibility with various systems. Key export settings include the exported model file format (e.g., ONNX, TensorFlow SavedModel), the target device (e.g., CPU, GPU), and additional features such as masks or multiple labels per box. The export process may also be affected by the model's specific task and the requirements or constraints of the destination environment or platform. It is crucial to thoughtfully configure these settings to ensure the exported model is optimized for the intended use case and functions effectively in the target environment.
178176

179177
| Key | Value | Description |
180178
|-------------|-----------------|------------------------------------------------------|
@@ -190,7 +188,9 @@ the intended use case and can be used effectively in the target environment.
190188
| `workspace` | `4` | TensorRT: workspace size (GB) |
191189
| `nms` | `False` | CoreML: add NMS |
192190

193-
### Augmentation
191+
[Export Guide](../modes/export.md){ .md-button .md-button--primary}
192+
193+
## Augmentation
194194

195195
Augmentation settings for YOLO models refer to the various transformations and modifications
196196
applied to the training data to increase the diversity and size of the dataset. These settings can affect the model's
@@ -217,7 +217,7 @@ ensure that the augmented dataset is diverse and representative enough to train
217217
| `mixup` | 0.0 | image mixup (probability) |
218218
| `copy_paste` | 0.0 | segment copy-paste (probability) |
219219

220-
### Logging, checkpoints, plotting and file management
220+
## Logging, checkpoints, plotting and file management
221221

222222
Logging, checkpoints, plotting, and file management are important considerations when training a YOLO model.
223223

0 commit comments

Comments
 (0)