yolo train data=coco128.yaml model=yolov8n.pt epochs=10 lr0=0.01 --device='0,1'
yolo task=detect mode=train model=yolov8x.yaml data=mydata.yaml epochs=10 batch=16
yolo task=segment mode=predict model=yolov8x-seg.pt source='/kaggle/input/personpng/1.jpg'
以上参数解释如下:
实际运行:
yolo train data=/home/jxft/datasets/hyd-action.yaml model=/home/jxft/datasets/yolov8/yolov8n.pt epochs=100 lr0=0.01
from ultralytics import YOLO
# Create a new YOLO model from scratch
model = YOLO('yolov8n.yaml')
# Load a pretrained YOLO model (recommended for training)
model = YOLO('yolov8n.pt')
# Train the model using the 'coco128.yaml' dataset for 3 epochs
results = model.train(data='coco128.yaml', epochs=3)
# Evaluate the model's performance on the validation set
results = model.val()
# Perform object detection on an image using the model
results = model('https://ultralytics.com/images/bus.jpg')
# Export the model to ONNX format
success = model.export(format='onnx')
训练参数:
workers = 1
batch = 8
data_name = "TrafficSign"
model = YOLO(abs_path('./weights/yolov5nu.pt', path_type='current'), task='detect') # 加载预训练的YOLOv8模型
results = model.train( # 开始训练模型
data=data_path, # 指定训练数据的配置文件路径
device='cpu', # 指定使用CPU进行训练
workers=workers, # 指定使用2个工作进程加载数据
imgsz=640, # 指定输入图像的大小为640x640
epochs=100, # 指定训练100个epoch
batch=batch, # 指定每个批次的大小为8
name='train_v5_' + data_name # 指定训练任务的名称
)