前言
在使用深度学习模型时,从先前保存的状态恢复训练是一项至关重要的功能。这在各种情况下都能派上用场,比如当训练过程意外中断时,或者当你希望用新数据或更多的历时继续训练模型时。
恢复训练时,Ultralytics YOLO 会加载上次保存模型的权重,并恢复优化器状态、学习率调度器和历时编号。这样,您就可以从上次中断的地方无缝地继续训练过程。
如何恢复训练
Ultralytics YOLO 您可以通过设置 resume 参数 True 在调用 train 方法的路径,并指定 .pt 文件,其中包含经过部分训练的模型权重。
Python
from ultralytics import YOLO
# Load a model
model = YOLO("path/to/last.pt") # load a partially trained model
# Resume training
results = model.train(resume=True)
CLI
# Resume an interrupted training
yolo train resume model=path/to/last.pt
效果图
如下图,启动之后Epoch从231批次继续训练