🔄Update: [Lab-4] yolov8n Train

This commit is contained in:
2025-11-05 19:00:47 +08:00
parent 8f9aa11e99
commit b5a0d5f1f3
3 changed files with 19 additions and 1 deletions
+3
View File
@@ -2,3 +2,6 @@
*/img
*/data
model
runs
datasets
yolov8n.pt
View File
+15
View File
@@ -0,0 +1,15 @@
from ultralytics import YOLO
# 1. 加载一个预训练模型(小规模模型,适合实验)
# 可选模型: YOLOv8n, YOLOv8s, YOLOv8m, YOLOv8l, YOLOv8x (nano, small, medium, large, xlarge)
model = YOLO('yolov8n.pt')
# 2. 训练模型
results = model.train(
data='coco128.yaml', # 数据集配置文件,YOLOv8会自动识别并下载
epochs=50, # 训练轮次,建议50-100轮以观察效果
imgsz=640, # 输入图像大小
batch=16, # 批次大小,根据GPU内存调整(CPU可设为-1)
name='yolov8n_coco128_exp1', # 实验名称,用于保存结果
device='cpu' # 使用CPU训练,如果有GPU且环境配置好,可改为 device=0 或 'cuda'
)