Get started quickly with YOLOv8 target detection!

1. Introduction to YOLOv8

YOLOv8 is a cutting-edge, state-of-the-art (SOTA) model that builds on the success of previous YOLO versions, introducing new features and improvements that further boost performance and flexibility. YOLOv8 is designed to be fast, accurate, and easy to use, making it an excellent choice for a variety of object detection and tracking, instance segmentation, image classification, and pose estimation tasks.
insert image description here

2. Environment installation

conda create -n yolov8 python=3.7
conda activate yolov8
conda install pytorch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0 cudatoolkit=11.0 -c pytorch
pip install ultralytics

3. Rapid training and testing

  • Specify training data: /ultralytics-main/ultralytics/datasets/mydata.yaml
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: /data/  # dataset root dir
train: mytrain.txt  # train images (relative to 'path') 128 images
val: myval.txt  # val images (relative to 'path') 128 images
test:  # test images (optional)

# Classes
names:
  0: xx
  1: xx
  2: xx
  3: xx
  4: xx
  5: xx
  6: xx
  7: xx
  8: xx
  • train
from ultralytics import YOLO

# Load a model
model = YOLO("yolov8m.yaml")  # build a new model from scratch
model = YOLO("yolov8m.pt")  # load a pretrained model (recommended for training)

# Use the model
model.train(data="mydata.yaml", epochs=80)  # train the model
  • test
from ultralytics import YOLO

# Load a model
model = YOLO("yolov8m.yaml")
model = YOLO("/mnt/Project/ultralytics-main/runs/detect/train_yolov8m/best.pt")
results = model.predict(source="/test_path/", save=True, save_txt=True, save_conf=True)

4. Model

  • The detection, segmentation and pose models of YOLOv8 are pre-trained on the COCO dataset, while the classification model is pre-trained on the ImageNet dataset. On first use, models are automatically downloaded from the latest Ultralytics release.

  • YOLOv8 provides a total of 5 models of different sizes to facilitate developers to balance performance and accuracy. The following takes the target detection model of YOLOv8 as an example:
    insert image description here

  • The segmentation model of YOLOv8 also provides a choice of models of 5 different sizes:
    insert image description here

  • Related github link: https://github.com/ultralytics/ultralytics/blob/main/README.zh-CN.md

Guess you like

Origin blog.csdn.net/wjinjie/article/details/130013031