【目标检测】YOLOV8实战入门(三)模型训练


train模式用于在自定义数据集上训练YOLOv8模型。在此模式下,使用指定的数据集和超参数训练模型。训练过程涉及优化模型的参数,以便它可以准确预测图像中对象的类别和位置。
Note:YOLOv8数据集,如COCO、VOC、ImageNet和许多其他数据集在首次使用时自动下载,即yolo train data=coco.yaml

model = YOLO('yolov8n.yaml')
# 利用官方提供的数据集配置文件进行训练,如COCO、VOC、ImageNet和许多其他数据集,在首次使用时自动下载
results = model.train(data='coco128.yaml', epochs=3)

# 不提供数据集配置文件,根据预训练文件中提供的相关信息进行训练
model = YOLO('yolov8n.pt') 
model.train(epochs=5)

# 恢复上次中断的训练
model = YOLO("last.pt")
model.train(resume=True)

YOLOv8模型的训练设置是指用于在数据集上训练模型的各种超参数和配置。这些设置会影响模型的性能、速度和准确性。一些YOLOv8的常见训练设置包括批量大小、学习率、动量和权重衰减。其他可能影响训练过程的因素包括优化器的选择、loss函数的选择以及训练集的大小和组成。仔细调整和试验这些设置以实现给定任务的最佳性能非常重要。

相关参数如下:

KeyValueDescription
modelNonepath to model file, i.e. yolov8n.pt, yolov8n.yaml
dataNonepath to data file, i.e. coco128.yaml
epochs100number of epochs to train for
patience50epochs to wait for no observable improvement for early stopping of training
batch16number of images per batch (-1 for AutoBatch)
imgsz640size of input images as integer or w,h
saveTruesave train checkpoints and predict results
save_period-1Save checkpoint every x epochs (disabled if < 1)
cacheFalseTrue/ram, disk or False. Use cache for data loading
deviceNonedevice to run on, i.e. cuda device=0 or device=0,1,2,3 or device=cpu
workers8number of worker threads for data loading (per RANK if DDP)
projectNoneproject name
nameNoneexperiment name
exist_okFalsewhether to overwrite existing experiment
pretrainedFalsewhether to use a pretrained model
optimizer'SGD'optimizer to use, choices=[‘SGD’, ‘Adam’, ‘AdamW’, ‘RMSProp’]
verboseFalsewhether to print verbose output
seed0random seed for reproducibility
deterministicTruewhether to enable deterministic mode
single_clsFalsetrain multi-class data as single-class
rectFalserectangular training with each batch collated for minimum padding
cos_lrFalseuse cosine learning rate scheduler
close_mosaic0(int) disable mosaic augmentation for final epochs
resumeFalseresume training from last checkpoint
ampTrueAutomatic Mixed Precision (AMP) training, choices=[True, False]
lr00.01initial learning rate (i.e. SGD=1E-2, Adam=1E-3)
lrf0.01final learning rate (lr0 * lrf)
momentum0.937SGD momentum/Adam beta1
weight_decay0.0005optimizer weight decay 5e-4
warmup_epochs3.0warmup epochs (fractions ok)
warmup_momentum0.8warmup initial momentum
warmup_bias_lr0.1warmup initial bias lr
box7.5box loss gain
cls0.5cls loss gain (scale with pixels)
dfl1.5dfl loss gain
pose12.0pose loss gain (pose-only)
kobj2.0keypoint obj loss gain (pose-only)
label_smoothing0.0label smoothing (fraction)
nbs64nominal batch size
overlap_maskTruemasks should overlap during training (segment train only)
mask_ratio4mask downsample ratio (segment train only)
dropout0.0use dropout regularization (classify train only)
valTruevalidate/test during training
  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

卖报的大地主

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值