多彩编程 多彩编程MZPH · CODE BLOG
ARTICLE DETAIL

文章详情

深耕前端与后端开发技术的一线实战笔记与踩坑复盘。

YOLO快速入门——(2)YOLO V26安装与快速入门

YOLO快速入门——(2)YOLO V26安装与快速入门 YOLO V26安装与快速入门安装 Ultralytics前置要求安装Conda环境并配置国内源安装方式Ultralytics官方提供了pip、conda、docker等方式对于windows上推荐使用Conda方式基于python3.11创建ultralytics-env的conda的环境并激活如果需要使用GPU的功能推荐与pytorch一起安装conda create--nameultralytics-env-cconda-forgepython3.11ultralytics torchvision pytorch-gpu-yconda activate ultralytics-env如果不需要使用GPU安装方式如下conda create--nameultralytics-env-cconda-forgepython3.11ultralytics torchvision-yconda activate ultralytics-env如果后续还想继续使用gpu功能可以继续单独安装pytorchcondainstallpytorch torchvision torchaudio pytorch-cuda11.8-cpytorch-cnvidia通过 Python 使用 Ultralytics在 Python 中执行相同的预测fromultralyticsimportYOLO modelYOLO(yolo26n.pt)# 加载预训练的 YOLO26n 检测模型resultsmodel(https://ultralytics.com/images/bus.jpg,saveTrue)# 进行预测并保存标注后的图像第一次运行时会下载模型参数到本地缓存路径如果没有配置代理可能会比较慢可以手动用 ghproxy 镜像下载Update Settings withyolo settings keyvalue, i.e.yolo settings runs_dirpath/to/dir.Forhelpsee https://docs.ultralytics.com/usage/settings. Downloading https://github.com/ultralytics/assets/releases/download/v8.4.0/yolo26n.pt toyolo26n.pt:0% ────────────48.0KB/5.3MB6.6KB/s2:5613:36原链接https://github.com/ultralytics/assets/releases/download/v8.4.0/yolo26n.pt加上国内代理前缀浏览器 /wget/curl 直接下curl -O https://gh-proxy.org/https://github.com/ultralytics/assets/releases/download/v8.4.0/yolo26n.pt备选代理ghproxy 挂了就换其他代理如curl -O https://shturl.cc//https://github.com/ultralytics/assets/releases/download/v8.4.0/yolo26n.pt下载完把yolo26n.pt放到 ultralytics 的模型缓存目录代码就不会再重新下载WindowsC:\Users\你的用户名\.ultralytics\models\Linux / WSL~/.ultralytics/models/同理bus.jpg也可以提前通过代理下载到本地curl-Ohttps://v4.gh-proxy.org/https://github.com/ultralytics/assets/releases/download/v0.0.0/bus.jpg同时更新代码fromultralyticsimportYOLO modelYOLO(C:\\Users\\Administrator\\.ultralytics\\models\\yolo26n.pt)# 加载预训练的 YOLO26n 检测模型resultsmodel(../../../images/yolo/bus.jpg,saveTrue)# 进行预测并保存标注后的图像
返回列表