赞
踩
本文用于学习记录
YOLOv8 实现目标检测
git clone https://github.com/ultralytics/ultralytics.git
conda activate pytorch
# yolo task=detect mode=predict model='模型文件' source='图片目录'
yolo task=detect mode=predict model=yolov8n.pt source="/home/yjy/YJY/ultralytics/ultralytics/assets"
import numpy as np
from ultralytics import YOLO
model = YOLO("yolov8n.pt") # 权重
results = model("ultralytics/assets") # 预测的图片或文件夹
def predict(cfg=DEFAULT_CFG, use_python=False):
"""Runs YOLO model inference on input image(s)."""
model = cfg.model or 'yolov8n.pt'
# source = cfg.source if cfg.source is not None else ROOT / 'assets' if (ROOT / 'assets').exists() \
# else 'https://ultralytics.com/images/bus.jpg'
# args = dict(model=model, source=source)
args = dict(model=model, source='0')
# args = dict(model=model, source='1')
if use_python:
from ultralytics import YOLO
YOLO(model)(**args)
else:
predictor = DetectionPredictor(overrides=args)
predictor.predict_cli()
args = dict(model=model, source='http://admin:admin@172.16.20.120:8081')
需确保手机和电脑在同一局域网下(即连接的是同一个 WIFI)
以上就是 yolov8 的环境配置、运行与训练过程及其中可能出现的问题与解决办法。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。