comments | description | keywords |
---|---|---|
true |
Master YOLOv8 settings and hyperparameters for improved model performance. Learn to use YOLO CLI commands, adjust training settings, and optimize YOLO tasks & modes. |
YOLOv8, settings, hyperparameters, YOLO CLI commands, YOLO tasks, YOLO modes, Ultralytics documentation, model optimization, YOLOv8 training |
YOLO 設(shè)置和超參數(shù)對模型的性能、速度和準(zhǔn)確性起著至關(guān)重要的作用。 這些設(shè)置和超參數(shù)可以影響模型開發(fā)過程各個階段的模型行為,包括訓(xùn)練、驗證和預(yù)測。
YOLOv8 yolo CLI 命令使用以下語法:
=== "CLI"
```bash
yolo TASK MODE ARGS
```
=== "Python"
```python
from ultralytics import YOLO
# Load a YOLOv8 model from a pre-trained weights file
model = YOLO('yolov8n.pt')
# Run MODE mode using the custom arguments ARGS (guess TASK)
model.MODE(ARGS)
```
Where:
-
TASK
?(optional) is one of?[detect, segment, classify, pose]
. If it is not passed explicitly YOLOv8 will try to guess the?TASK
?from the model type. -
MODE
?(required) is one of?[train, val, predict, export, track, benchmark]
-
ARGS
?(optional) are any number of custom?arg=value
?pairs like?imgsz=320
?that override defaults.
一、Tasks
YOLO 模型可用于各種任務(wù),包括檢測、分割、分類和姿勢。 這些任務(wù)的不同之處在于它們產(chǎn)生的輸出類型以及它們旨在解決的具體問題。
檢測:用于識別和定位圖像或視頻中感興趣的對象或區(qū)域。
分段:用于將圖像或視頻劃分為對應(yīng)于不同對象或類別的區(qū)域或像素。
分類:用于預(yù)測輸入圖像的類標(biāo)簽。
姿勢:用于識別圖像或視頻中的對象并估計其關(guān)鍵點。
Key | Value | Description |
---|---|---|
task |
'detect' |
YOLO task, i.e. detect, segment, classify, pose |
二、Modes
YOLO 模型可以根據(jù)您要解決的具體問題以不同的模式使用。
這些模式包括:
訓(xùn)練:用于在自定義數(shù)據(jù)集上訓(xùn)練 YOLOv8 模型。
Val:用于在訓(xùn)練后驗證 YOLOv8 模型。
預(yù)測:使用經(jīng)過訓(xùn)練的 YOLOv8 模型對新圖像或視頻進(jìn)行預(yù)測。
導(dǎo)出:用于將 YOLOv8 模型導(dǎo)出為可用于部署的格式。
Track:用于使用 YOLOv8 模型實時跟蹤對象。
基準(zhǔn):用于對 YOLOv8 導(dǎo)出(ONNX、TensorRT 等)速度和準(zhǔn)確性進(jìn)行基準(zhǔn)測試。
Key | Value | Description |
---|---|---|
mode |
'train' |
YOLO mode, i.e. train, val, predict, export, track, benchmark |
三、Train
YOLO 模型的訓(xùn)練設(shè)置包含訓(xùn)練過程中使用的各種超參數(shù)和配置。 這些設(shè)置會影響模型的性能、速度和準(zhǔn)確性。
關(guān)鍵的訓(xùn)練設(shè)置包括批量大小、學(xué)習(xí)率、動量和權(quán)重衰減。 此外,優(yōu)化器、損失函數(shù)和訓(xùn)練數(shù)據(jù)集組成的選擇也會影響訓(xùn)練過程。 仔細(xì)調(diào)整和試驗這些設(shè)置對于優(yōu)化性能至關(guān)重要。
Key | Value | Description |
---|---|---|
model |
None |
path to model file, i.e. yolov8n.pt, yolov8n.yaml |
data |
None |
path to data file, i.e. coco128.yaml |
epochs |
100 |
number of epochs to train for |
patience |
50 |
epochs to wait for no observable improvement for early stopping of training |
batch |
16 |
number of images per batch (-1 for AutoBatch) |
imgsz |
640 |
size of input images as integer or w,h |
save |
True |
save train checkpoints and predict results |
save_period |
-1 |
Save checkpoint every x epochs (disabled if < 1) |
cache |
False |
True/ram, disk or False. Use cache for data loading |
device |
None |
device to run on, i.e. cuda device=0 or device=0,1,2,3 or device=cpu |
workers |
8 |
number of worker threads for data loading (per RANK if DDP) |
project |
None |
project name |
name |
None |
experiment name |
exist_ok |
False |
whether to overwrite existing experiment |
pretrained |
True |
(bool or str) whether to use a pretrained model (bool) or a model to load weights from (str) |
optimizer |
'auto' |
optimizer to use, choices=[SGD, Adam, Adamax, AdamW, NAdam, RAdam, RMSProp, auto] |
verbose |
False |
whether to print verbose output |
seed |
0 |
random seed for reproducibility |
deterministic |
True |
whether to enable deterministic mode |
single_cls |
False |
train multi-class data as single-class |
rect |
False |
rectangular training with each batch collated for minimum padding |
cos_lr |
False |
use cosine learning rate scheduler |
close_mosaic |
10 |
(int) disable mosaic augmentation for final epochs (0 to disable) |
resume |
False |
resume training from last checkpoint |
amp |
True |
Automatic Mixed Precision (AMP) training, choices=[True, False] |
fraction |
1.0 |
dataset fraction to train on (default is 1.0, all images in train set) |
profile |
False |
profile ONNX and TensorRT speeds during training for loggers |
freeze |
None |
(int or list, optional) freeze first n layers, or freeze list of layer indices during training |
lr0 |
0.01 |
initial learning rate (i.e. SGD=1E-2, Adam=1E-3) |
lrf |
0.01 |
final learning rate (lr0 * lrf) |
momentum |
0.937 |
SGD momentum/Adam beta1 |
weight_decay |
0.0005 |
optimizer weight decay 5e-4 |
warmup_epochs |
3.0 |
warmup epochs (fractions ok) |
warmup_momentum |
0.8 |
warmup initial momentum |
warmup_bias_lr |
0.1 |
warmup initial bias lr |
box |
7.5 |
box loss gain |
cls |
0.5 |
cls loss gain (scale with pixels) |
dfl |
1.5 |
dfl loss gain |
pose |
12.0 |
pose loss gain (pose-only) |
kobj |
2.0 |
keypoint obj loss gain (pose-only) |
label_smoothing |
0.0 |
label smoothing (fraction) |
nbs |
64 |
nominal batch size |
overlap_mask |
True |
masks should overlap during training (segment train only) |
mask_ratio |
4 |
mask downsample ratio (segment train only) |
dropout |
0.0 |
use dropout regularization (classify train only) |
val |
True |
validate/test during training |
四、Predict
YOLO 模型的預(yù)測設(shè)置包含一系列超參數(shù)和配置,這些超參數(shù)和配置會影響模型在推理新數(shù)據(jù)期間的性能、速度和準(zhǔn)確性。 仔細(xì)調(diào)整和試驗這些設(shè)置對于實現(xiàn)特定任務(wù)的最佳性能至關(guān)重要。 關(guān)鍵設(shè)置包括置信度閾值、非極大值抑制 (NMS) 閾值和考慮的類別數(shù)量。 影響預(yù)測過程的其他因素包括輸入數(shù)據(jù)的大小和格式、是否存在補充特征(例如每個框的掩碼或多個標(biāo)簽)以及模型所執(zhí)行的特定任務(wù)。
Key | Value | Description |
---|---|---|
source |
'ultralytics/assets' |
source directory for images or videos |
conf |
0.25 |
object confidence threshold for detection |
iou |
0.7 |
intersection over union (IoU) threshold for NMS |
half |
False |
use half precision (FP16) |
device |
None |
device to run on, i.e. cuda device=0/1/2/3 or device=cpu |
show |
False |
show results if possible |
save |
False |
save images with results |
save_txt |
False |
save results as .txt file |
save_conf |
False |
save results with confidence scores |
save_crop |
False |
save cropped images with results |
show_labels |
True |
show object labels in plots |
show_conf |
True |
show object confidence scores in plots |
max_det |
300 |
maximum number of detections per image |
vid_stride |
False |
video frame-rate stride |
stream_buffer |
bool |
buffer all streaming frames (True) or return the most recent frame (False) |
line_width |
None |
The line width of the bounding boxes. If None, it is scaled to the image size. |
visualize |
False |
visualize model features |
augment |
False |
apply image augmentation to prediction sources |
agnostic_nms |
False |
class-agnostic NMS |
retina_masks |
False |
use high-resolution segmentation masks |
classes |
None |
filter results by class, i.e. classes=0, or classes=[0,2,3] |
boxes |
True |
Show boxes in segmentation predictions |
五、Val
YOLO 模型的 val(驗證)設(shè)置涉及各種超參數(shù)和配置,用于評估模型在驗證數(shù)據(jù)集上的性能。 這些設(shè)置會影響模型的性能、速度和準(zhǔn)確性。 常見的 YOLO 驗證設(shè)置包括批量大小、訓(xùn)練期間的驗證頻率以及性能評估指標(biāo)。 影響驗證過程的其他因素包括驗證數(shù)據(jù)集的大小和組成,以及模型所用于的特定任務(wù)。 對這些設(shè)置進(jìn)行仔細(xì)調(diào)整和實驗對于確保驗證數(shù)據(jù)集的最佳性能以及檢測和防止過度擬合至關(guān)重要。
Key | Value | Description |
---|---|---|
save_json |
False |
save results to JSON file |
save_hybrid |
False |
save hybrid version of labels (labels + additional predictions) |
conf |
0.001 |
object confidence threshold for detection |
iou |
0.6 |
intersection over union (IoU) threshold for NMS |
max_det |
300 |
maximum number of detections per image |
half |
True |
use half precision (FP16) |
device |
None |
device to run on, i.e. cuda device=0/1/2/3 or device=cpu |
dnn |
False |
use OpenCV DNN for ONNX inference |
plots |
False |
show plots during training |
rect |
False |
rectangular val with each batch collated for minimum padding |
split |
val |
dataset split to use for validation, i.e. 'val', 'test' or 'train' |
六、Export
YOLO 模型的導(dǎo)出設(shè)置包含與保存或?qū)С瞿P鸵栽诓煌h(huán)境或平臺中使用相關(guān)的配置和選項。 這些設(shè)置可能會影響模型的性能、大小以及與各種系統(tǒng)的兼容性。 關(guān)鍵導(dǎo)出設(shè)置包括導(dǎo)出的模型文件格式(例如 ONNX、TensorFlow SavedModel)、目標(biāo)設(shè)備(例如 CPU、GPU)以及其他功能,例如掩?;蛎總€框多個標(biāo)簽。 導(dǎo)出過程還可能受到模型的特定任務(wù)以及目標(biāo)環(huán)境或平臺的要求或約束的影響。 仔細(xì)配置這些設(shè)置以確保導(dǎo)出的模型針對預(yù)期用例進(jìn)行優(yōu)化并在目標(biāo)環(huán)境中有效運行至關(guān)重要。
Key | Value | Description |
---|---|---|
format |
'torchscript' |
format to export to |
imgsz |
640 |
image size as scalar or (h, w) list, i.e. (640, 480) |
keras |
False |
use Keras for TF SavedModel export |
optimize |
False |
TorchScript: optimize for mobile |
half |
False |
FP16 quantization |
int8 |
False |
INT8 quantization |
dynamic |
False |
ONNX/TF/TensorRT: dynamic axes |
simplify |
False |
ONNX: simplify model |
opset |
None |
ONNX: opset version (optional, defaults to latest) |
workspace |
4 |
TensorRT: workspace size (GB) |
nms |
False |
CoreML: add NMS |
七、Augmentation
YOLO 模型的增強設(shè)置是指應(yīng)用于訓(xùn)練數(shù)據(jù)的各種轉(zhuǎn)換和修改,以增加數(shù)據(jù)集的多樣性和大小。 這些設(shè)置會影響模型的性能、速度和準(zhǔn)確性。 一些常見的 YOLO 增強設(shè)置包括所應(yīng)用的變換的類型和強度(例如隨機翻轉(zhuǎn)、旋轉(zhuǎn)、裁剪、顏色變化)、應(yīng)用每個變換的概率以及是否存在附加功能,例如每個框的掩?;蚨鄠€標(biāo)簽 。 可能影響增強過程的其他因素包括原始數(shù)據(jù)集的大小和組成以及模型所用于的特定任務(wù)。 仔細(xì)調(diào)整和試驗這些設(shè)置非常重要,以確保增強數(shù)據(jù)集具有足夠的多樣性和代表性,足以訓(xùn)練高性能模型。
Key | Value | Description |
---|---|---|
hsv_h |
0.015 |
image HSV-Hue augmentation (fraction) |
hsv_s |
0.7 |
image HSV-Saturation augmentation (fraction) |
hsv_v |
0.4 |
image HSV-Value augmentation (fraction) |
degrees |
0.0 |
image rotation (+/- deg) |
translate |
0.1 |
image translation (+/- fraction) |
scale |
0.5 |
image scale (+/- gain) |
shear |
0.0 |
image shear (+/- deg) |
perspective |
0.0 |
image perspective (+/- fraction), range 0-0.001 |
flipud |
0.0 |
image flip up-down (probability) |
fliplr |
0.5 |
image flip left-right (probability) |
mosaic |
1.0 |
image mosaic (probability) |
mixup |
0.0 |
image mixup (probability) |
copy_paste |
0.0 |
segment copy-paste (probability) |
八、Logging, checkpoints, plotting and file management
訓(xùn)練 YOLO 模型時,日志記錄、檢查點、繪圖和文件管理是重要的考慮因素。
日志記錄:在訓(xùn)練期間記錄各種指標(biāo)和統(tǒng)計數(shù)據(jù)通常很有幫助,以跟蹤模型的進(jìn)度并診斷可能出現(xiàn)的任何問題。 這可以使用 TensorBoard 等日志庫或通過將日志消息寫入文件來完成。
檢查點:在訓(xùn)練期間定期保存模型的檢查點是一個很好的做法。 如果訓(xùn)練過程中斷或者您想嘗試不同的訓(xùn)練配置,您可以從之前的點恢復(fù)訓(xùn)練。
繪圖:可視化模型的性能和訓(xùn)練進(jìn)度有助于理解模型的行為方式并識別潛在問題。 這可以使用 matplotlib 等繪圖庫或使用 TensorBoard 等日志記錄庫生成繪圖來完成。
文件管理:管理訓(xùn)練過程中生成的各種文件(例如模型檢查點、日志文件和繪圖)可能具有挑戰(zhàn)性。 擁有清晰且有組織的文件結(jié)構(gòu)來跟蹤這些文件并使其易于根據(jù)需要訪問和分析它們非常重要。文章來源:http://www.zghlxwxcb.cn/news/detail-752605.html
有效的日志記錄、檢查點、繪圖和文件管理可以幫助您跟蹤模型的進(jìn)度,并更輕松地調(diào)試和優(yōu)化訓(xùn)練過程。文章來源地址http://www.zghlxwxcb.cn/news/detail-752605.html
Key | Value | Description |
---|---|---|
project |
'runs' |
project name |
name |
'exp' |
experiment name.?exp ?gets automatically incremented if not specified, i.e,?exp ,?exp2 ?... |
exist_ok |
False |
whether to overwrite existing experiment |
plots |
False |
save plots during train/val |
save |
False |
save train checkpoints and predict results |
到了這里,關(guān)于【計算機視覺】YOLOv8參數(shù)詳解(全面詳細(xì)、重點突出、大白話闡述小白也能看懂)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!