参考博客:【保姆级教程|YOLOv8改进】【3】使用FasterBlock替换C2f中的Bottleneck_yolo 修改c2f中bottleblock模块-CSDN博客
在ultralytics/cfg/datasets/ 下新建data.yaml
path: D:/Desktop/fire_smoke_dataset(1)
train: D:/Desktop/fire_smoke_dataset(1)/images/train
val: D:/Desktop/fire_smoke_dataset(1)/images/val
nc : 2
names:
0: fire
1: smoke
main.py训练:
#coding:utf-8
from ultralytics import YOLO
model = YOLO("ultralytics/cfg/models/v8/c2f_Faster_yolov8.yaml").load('yolov8n.pt')
# Use the model
if __name__ == '__main__':
# Use the model
results = model.train(data='ultralytics/cfg/datasets/data.yaml', epochs=100, batch=4,device='0',workers=1,amp=False) # 训练模型
# 将模型转为onnx格式
# success = model.export(format='onnx')
训练结果:
与没有改进的结果相比:
效果不好。