欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 艺术 > YOLOv10环境搭建、训练自己的目标检测数据集、实际验证和测试

YOLOv10环境搭建、训练自己的目标检测数据集、实际验证和测试

2024/11/30 12:26:56 来源:https://blog.csdn.net/Xiao_Ya__/article/details/140757035  浏览:    关键词:YOLOv10环境搭建、训练自己的目标检测数据集、实际验证和测试

1 环境搭建


1.1 在官方仓库的给定的使用python=3.9版本,则使用conda创建对应虚拟环境。

conda create -n yolov10 python=3.9

1.2 切换到对应虚拟环境

conda activate yolov10

1.3 在指定目录下克隆yolov10官方仓库代码

git clone https://github.com/THU-MIG/yolov10.git

1.4 进入对应本地yolov10目录下安装对应依赖项

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/

如果使用 pip install -r requirements.txt 命令,可能会遇到错误

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001A7EADD6CD0>, 'Connection to files.pythonhosted.org timed out. (connect timeout=15)')': /packages/48/f4/d0b61525a3d3db78636f1937d1bc24cbb39abc57484a545b72b6ab35c114/torch-2.0.1-cp39-cp39-win_amd64.whl
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001A7EADD6CA0>, 'Connection to files.pythonhosted.org timed out. (connect timeout=15)')': /packages/48/f4/d0b61525a3d3db78636f1937d1bc24cbb39abc57484a545b72b6ab35c114/torch-2.0.1-cp39-cp39-win_amd64.whl
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001A7EB200400>, 'Connection to files.pythonhosted.org timed out. (connect timeout=15)')': /packages/48/f4/d0b61525a3d3db78636f1937d1bc24cbb39abc57484a545b72b6ab35c114/torch-2.0.1-cp39-cp39-win_amd64.whl
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001A7EB1F1F10>, 'Connection to files.pythonhosted.org timed out. (connect timeout=15)')': /packages/48/f4/d0b61525a3d3db78636f1937d1bc24cbb39abc57484a545b72b6ab35c114/torch-2.0.1-cp39-cp39-win_amd64.whl
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001A7EB1F15B0>, 'Connection to files.pythonhosted.org timed out. (connect timeout=15)')': /packages/48/f4/d0b61525a3d3db78636f1937d1bc24cbb39abc57484a545b72b6ab35c114/torch-2.0.1-cp39-cp39-win_amd64.whl
ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/48/f4/d0b61525a3d3db78636f1937d1bc24cbb39abc57484a545b72b6ab35c114/torch-2.0.1-cp39-cp39-win_amd64.whl (Caused by ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000001A7ECD869A0>, 'Connection to files.pythonhosted.org timed out. (connect timeout=15)'))

1.5 安装对应的包

pip install -e .

2 模型训练及测试效果

2.1 在Roboflow下载数据集并导出为YOLO的数据集(  或者在Roboflow制作自己的数据集并导出为YOLO的数据集)。参考Roboflow 使用详解:数据集标注、训练及下载

2.3 把data.yaml复制到C:\Users\WYX\Desktop\code\yolov10-main\ultralytics\cfg\datasets目录下,重命名为VOC_new.yaml,并修改相应的配置。

2.4 模型训练 

需要修改C:\Users\WYX\Desktop\code\yolov10-main\ultralytics\models\yolov10\train.py。

训练

yolo detect train data=VOC_new.yaml model=yolov10n.yaml epochs=500 batch=32 imgsz=640 device=cpu

2.5 模型验证 

yolo val model=jameslahm/yolov10n data=VOC_new.yaml batch=32 

2.6 预测并导出

yolo export model=jameslahm/yolov10n format=onnx opset=13 simplify

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com