【计算机视觉】YOLOv8参数讲解
  tuO6pNMYWTyk 2023年11月02日 26 0

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 设置和超参数对模型的性能、速度和准确性起着至关重要的作用。 这些设置和超参数可以影响模型开发过程各个阶段的模型行为,包括训练、验证和预测。

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 模型可用于各种任务,包括检测、分割、分类和姿势。 这些任务的不同之处在于它们产生的输出类型以及它们旨在解决的具体问题。

检测:用于识别和定位图像或视频中感兴趣的对象或区域。

分割:用于将图像或视频划分为对应于不同对象或类别的区域或像素。

分类:用于预测输入图像的类标签。 姿势:用于识别图像或视频中的对象并估计其关键点。

Key

Value

Description

task

'detect'

YOLO task, i.e. detect, segment, classify, pose

Modes

YOLO 模型可以根据您要解决的具体问题以不同的模式使用。

这些模式包括:

训练:用于在自定义数据集上训练 YOLOv8 模型。

Val:用于在训练后验证 YOLOv8 模型。

预测:使用经过训练的 YOLOv8 模型对新图像或视频进行预测。

导出:用于将 YOLOv8 模型导出为可用于部署的格式。

Track:用于使用 YOLOv8 模型实时跟踪对象。

基准:用于对 YOLOv8 导出(ONNX、TensorRT 等)速度和准确性进行基准测试。

Key

Value

Description

mode

'train'

YOLO mode, i.e. train, val, predict, export, track, benchmark

Train

YOLO 模型的训练设置包含训练过程中使用的各种超参数和配置。 这些设置会影响模型的性能、速度和准确性。 关键的训练设置包括批量大小、学习率、动量和权重衰减。 此外,优化器、损失函数和训练数据集组成的选择也会影响训练过程。 仔细调整和试验这些设置对于优化性能至关重要。

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 模型的预测设置包含一系列超参数和配置,这些超参数和配置会影响模型在推理新数据期间的性能、速度和准确性。 仔细调整和试验这些设置对于实现特定任务的最佳性能至关重要。 关键设置包括置信度阈值、非极大值抑制 (NMS) 阈值和考虑的类别数量。 影响预测过程的其他因素包括输入数据的大小和格式、是否存在补充特征(例如每个框的掩码或多个标签)以及模型所执行的特定任务。

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(验证)设置涉及各种超参数和配置,用于评估模型在验证数据集上的性能。 这些设置会影响模型的性能、速度和准确性。 常见的 YOLO 验证设置包括批量大小、训练期间的验证频率以及性能评估指标。 影响验证过程的其他因素包括验证数据集的大小和组成,以及模型所用于的特定任务。 对这些设置进行仔细调整和实验对于确保验证数据集的最佳性能以及检测和防止过度拟合至关重要。

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 模型的导出设置包含与保存或导出模型以在不同环境或平台中使用相关的配置和选项。 这些设置可能会影响模型的性能、大小以及与各种系统的兼容性。 关键导出设置包括导出的模型文件格式(例如 ONNX、TensorFlow SavedModel)、目标设备(例如 CPU、GPU)以及其他功能,例如掩模或每个框多个标签。 导出过程还可能受到模型的特定任务以及目标环境或平台的要求或约束的影响。 仔细配置这些设置以确保导出的模型针对预期用例进行优化并在目标环境中有效运行至关重要。

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 模型的增强设置是指应用于训练数据的各种转换和修改,以增加数据集的多样性和大小。 这些设置会影响模型的性能、速度和准确性。 一些常见的 YOLO 增强设置包括所应用的变换的类型和强度(例如随机翻转、旋转、裁剪、颜色变化)、应用每个变换的概率以及是否存在附加功能,例如每个框的掩模或多个标签 。 可能影响增强过程的其他因素包括原始数据集的大小和组成以及模型所用于的特定任务。 仔细调整和试验这些设置非常重要,以确保增强数据集具有足够的多样性和代表性,足以训练高性能模型。

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

训练 YOLO 模型时,日志记录、检查点、绘图和文件管理是重要的考虑因素。

日志记录:在训练期间记录各种指标和统计数据通常很有帮助,以跟踪模型的进度并诊断可能出现的任何问题。 这可以使用 TensorBoard 等日志库或通过将日志消息写入文件来完成。

检查点:在训练期间定期保存模型的检查点是一个很好的做法。 如果训练过程中断或者您想尝试不同的训练配置,您可以从之前的点恢复训练。

绘图:可视化模型的性能和训练进度有助于理解模型的行为方式并识别潜在问题。 这可以使用 matplotlib 等绘图库或使用 TensorBoard 等日志记录库生成绘图来完成。

文件管理:管理训练过程中生成的各种文件(例如模型检查点、日志文件和绘图)可能具有挑战性。 拥有清晰且有组织的文件结构来跟踪这些文件并使其易于根据需要访问和分析它们非常重要。

有效的日志记录、检查点、绘图和文件管理可以帮助您跟踪模型的进度,并更轻松地调试和优化训练过程。

Key

Value

Description

project

'runs'

project name

name

'exp'

experiment name. exp gets automatically incremented if not specified, i.e, expexp2 ...

exist_ok

False

whether to overwrite existing experiment

plots

False

save plots during train/val

save

False

save train checkpoints and predict results

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
tuO6pNMYWTyk