本机依赖:

VisualStudio 2022 cuda11.7

cuda 11.7.0

cudnn 8.9.6

cmake 3.26.0

conda 23.11.0

labelme 5.4.1

numpy 1.24.3

torch 1.13.1+cu117
torchaudio 0.13.1+cu117
torchvision 0.14.1+cu117

前言

本文基于ultralytics

1 环境安装

1.1 虚拟环境

conda create -n yolov8 python=3.8
activate yolov8

1.2 Pytorch

PyTorch 要求因操作系统和 CUDA 要求而异

在官网上找寻适合自己cuda版本的torch口令安装

pytorch:Previous PyTorch Versions | PyTorch

conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.7 -c pytorch -c nvidia

1.3 Ultralytics

1.3.1 安装

yolov8有两种安装方式,一种可直接安装U神的库:

pip install ultralytics
git clone https://github.com/ultralytics/ultralytics.git

1.3.2 语法

安装Ultralytics后就可以使用 yolo ,语法:

yolo TASK MODE ARGS

Where   TASK (optional) is one of [detect, segment, classify]
        MODE (required) is one of [train, val, predict, export, track]
        ARGS (optional) are any number of custom 'arg=value' pairs like 'imgsz=320' that override defaults.

1.3.3 验证

cd ultralytics
yolo task=segment mode=predict model=yolov8s-seg.pt source='ultralytics/assets/bus.jpg' show=True
(yolov8) D:\GraduationDesign\YOLOv8\ultralytics>yolo task=segment mode=predict model=yolov8s-seg.pt source='ultralytics/assets/bus.jpg' show=True
Downloading https://github.com/ultralytics/assets/releases/download/v8.1.0/yolov8s-seg.pt to 'yolov8s-seg.pt'...
100%|██████████████████████████████████████████████████████████████████████████████| 22.8M/22.8M [00:24<00:00, 983kB/s]
Ultralytics YOLOv8.1.30 🚀 Python-3.8.18 torch-1.13.1+cu117 CUDA:0 (NVIDIA GeForce RTX 2060, 6144MiB)
YOLOv8s-seg summary (fused): 195 layers, 11810560 parameters, 0 gradients, 42.6 GFLOPs

image 1/1 D:\GraduationDesign\YOLOv8\ultralytics\ultralytics\assets\bus.jpg: 640x480 4 persons, 1 bus, 1 tie, 23.0ms
Speed: 3.0ms preprocess, 23.0ms inference, 5.0ms postprocess per image at shape (1, 3, 640, 480)
Results saved to runs\segment\predict
💡 Learn more at https://docs.ultralytics.com/modes/predict

bus

分类: PythonYOLO 标签: PythonYOLOYOLOv8

评论

暂无评论数据

暂无评论数据

目录