1. 配置Anaconda环境:
conda create -n yolov10 python=3.9
conda activate yolov10
pip install -r requirements.txt
pip install -e .
这里由于torch==2.0.1太慢,单独用pytorch官网安装流程(选择支持GPU版本):
conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 -c pytorch
可能会遇到的报错:
1. conda 虚拟环境 Message was:\n\nfailed with error: [Errno 13] Permission denied:
这种错误看了很多帖子不能彻底解决,最好的办法就是重新安装新版Anaconda即可解决。
2. ERROR: File "setup.py" not found. Directory cannot be installed in editable mode: E:\YOLO\yolov10-main
(A "pyproject.toml" file was found, but editable mode currently requires a setup.py based build.)
WARNING: You are using pip version 20.2.4; however, version 24.0 is available.
You should consider upgrading via the 'D:\ProgramData\anaconda3\envs\yolov10\python.exe -m pip install --upgrade pip' command.
解决:
卸载: python -m pip uninstall pip setuptools
安装: python -m pip install -U pip setuptools
如果遇到pip的“拒绝访问”问题:
在pip前加上python -m即可。
2. yolov10官网下载程序:
python app.py
# Please visit http://127.0.0.1:7860
或者新建一个infer.py程序:
from ultralytics import YOLOv10
model = YOLOv10.from_pretrained('jameslahm/yolov10n')
source = 'http://images.cocodataset.org/val2017/000000039769.jpg'
model.predict(source=source, save=True)
输出结果到“盘符:\YOLO\yolov10-main\runs\detect\predict ",结果如下:
直接测试YOLO\yolov10-main\ultralytics\assets目录下的图像
yolo predict model=jameslahm/yolov10n
3. 将模型从pt转换成onnx:
yolo export model=自己盘符\YOLO\yolov10-main\model\yolov10x.pt format=onnx opset=13 simplify
运行预测:
yolo predict model=自己盘符\YOLO\yolov10-main\model\yolov10x.onnx
运行结果:
参考网站:
1. YOLOv10环境搭建、模型预测和ONNX推理_yolov10安装-CSDN博客
2.GitHub - THU-MIG/yolov10: YOLOv10: Real-Time End-to-End Object Detection