Yolo v8 入门学习之采用 coco128 数据集进行图片检测测试

示例入门代码

from ultralytics import YOLO
import cv2
import matplotlib.pyplot as plt
import matplotlib.image as mpimg

def test():
    # 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('./Magic.jpg')
    res = results[0].plot()
    cv2.imshow("YOLOv8 Detection", res)
    cv2.waitKey(10)
    # Export the model to ONNX format
    # success = model.export(format='onnx')
if __name__ == '__main__':
    test()

检测结果

在这里插入图片描述

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-01 10:32:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-01 10:32:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-02-01 10:32:01       82 阅读
  4. Python语言-面向对象

    2024-02-01 10:32:01       91 阅读

热门阅读

  1. vivado 时钟规划

    2024-02-01 10:32:01       52 阅读
  2. C语言-算法-搜索剪枝与记忆化搜索

    2024-02-01 10:32:01       55 阅读
  3. 【无标题】

    2024-02-01 10:32:01       57 阅读
  4. cx_oracle连接oracle的us7ascii数据集乱码问题

    2024-02-01 10:32:01       53 阅读
  5. datax oracle->pg库 迁移表

    2024-02-01 10:32:01       60 阅读
  6. npm install -g pnpm 安装出现错误

    2024-02-01 10:32:01       53 阅读
  7. npm发布Vue组件

    2024-02-01 10:32:01       44 阅读