win10+anaconda安装yolov5的方法及问题解决方案
作者:light-124 发布时间:2022-02-03 10:31:58
对于yolo系列,应用广泛,在win10端也有很大的应用需求,所以这篇文章给出win10环境下的安装教程。
先给出系列文章win10+anacnda实现yolov3
YOLOV5-3.0/3.1版本
版本问题
python 3.7 torch 1.6.0 torchvision 0.7.0 cuda 10.1
注意:Yolov5-3.1只能使用torch 1.6.0
1.在网站下载对应版本的torch和torchvision的whl文件
https://download.pytorch.org/whl/torch_stable.html
2.新建虚拟环境
conda create -n YOLOV5-3.1 python=3.7
3.查看虚拟环境
conda info -e
4.激活虚拟环境
activate YOLOV5-3.1
5.安装相关库
pip3 install opencv-python==4.4.0.46 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install numpy==1.19.2 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install Cython==0.29.21 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install pillow==8.0.1 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install matplotlib==3.3.2 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install pyyaml==5.3.1 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install tensorboard==2.3.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install scipy==1.5.2 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install tqdm==4.54.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install pandas==1.1.3 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install seaborn==0.11.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install pycocotools==2.0.2 -i https://pypi.tuna.tsinghua.edu.cn/simple/
6.安装torch
将路径跳转到步骤1中下载的文件位置,使用pip install .....whl 格式来安装whl文件
7.验证
import torch
#查看版本
print(torch.__version__)
#查看gpu是否可用.返回True则表示可以使用gpu
torch.cuda.is_available()
#返回设备gpu个数
torch.cuda.device_count()
8.图像检测
python detect.py
9.调用摄像头
python detect.py --source 0
YOLOV5-4.0版本
电脑配置
CPU:i7-10750H
内存:16G
显卡:GTX1650 4G
Anaconda:4.9.2
1.一开始就最好把源换一下
查看当前下载源
conda config --show-sources
添加源:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
查看当前下载源
conda config --show-sources
如果出现国内源挂掉的情况,就换回默认源
conda config --remove-key channels
2.新建虚拟环境
conda create -n YOLOV5-4.0 python=3.7
3.查看虚拟环境
conda info -e
4.激活虚拟环境
activate YOLOV5-4.0
5.安装相关库
注意1:这里不能直接使用pip install -r requirements.txt 这样直接安装会默认安装cpu版本的torch,不知道为什么,可能是torch是其他库的依赖库,这里不懂,有会的小伙伴可以一起交流。
注意2:Cv2的版本不能是4.5,需要指定成4.4或者以下。同时Python3.8装不上cv2 4.4。所以需要安装python3.7版本,这样才能将cv2的4.4版本安装上去。同时在安装库的时候需要先安装opnecv-python,不能先安装numpy,这样才能安装上cv2的4.4版本。
pip3 install opencv-python==4.4.0.46 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install numpy==1.19.2 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install Cython==0.29.21 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install pillow==8.0.1 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install matplotlib==3.3.2 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install pyyaml==5.3.1 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install tensorboard==2.3.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install scipy==1.5.2 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install tqdm==4.54.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install pandas==1.1.3 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install seaborn==0.11.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip3 install pycocotools==2.0.2 -i https://pypi.tuna.tsinghua.edu.cn/simple/
注意:这里需要先安装opencv-python再安装numoy,而且opencv-python的版本最好不好是4.5。否则这里会报出CV2函数的错误。
6.安装torch
我们使用的版本依次是
pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=10.2。
torcp.7版本。Python对应3.7版本,否则不能使用cuda。cv2要用4.5以下版本。
YOLOv5最好使用cuda10.2版本
Yolov5 4.0建议搭配torcp.7/yolov5 3.0建议搭配pytorcp.6
安装方式一:在网站中找到对应的版本然后离线安装
https://download.pytorch.org/whl/torch_stable.html
方式二:
conda install pytorch=1.7.1 torchvision=0.8.2 cudatoolkit=10.2 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
6.验证
import torch
#查看版本
print(torch.__version__)
#查看gpu是否可用
torch.cuda.is_available()
#返回设备gpu个数
torch.cuda.device_count()
7.图像检测
python detect.py
8.摄像头
python detect.py --source 0
9.mp4视频测试
python detect.py --source 161.mp4 (这里接视频的位置)
如上图,视频已经被识别过啦
过程中的一些报错
报错1:打开摄像头报错
File "D:\BIG-YOLOV5\YOLO\yolov5-4.0\yolov5-4.0\utils\datasets.py", line 276, in __init__
assert cap.isOpened(), 'Failed to open %s' % s AssertionError: Failed to open 0
解决办法:找到设备管理器-照相机-右键开启设备
报错2:摄像头报错
解决办法:本人用的是联想拯救者电脑
1电脑-右键属性-设备管理器-照相机-点击开启
2开始-设置-隐私-相机-将设置都打开
3点击任务栏上的电池图标,将摄像头隐私开启。
报错3:在创建虚拟环境后,安装库的时候出现错误
WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(139): Could not remove or rename D:\anaconda\pkgs\notebook-6.2.0-py38haa244fe_0.tar.bz2. Please remove this file manually (you may need to reboot to free file handles)
原因:在安装库的中途退出了
解决办法:conda clean --all
报错4:
An unexpected error has occurred. Conda has prepared the above report.
If submitted, this report will be used by core maintainers to improve
future releases of conda.
解决办法:conda clean -i
报错5:cv2版本报错4.5.1
cv2.error: OpenCV(4.5.1)C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-1drr4hl0\opencv\modules\highgui\src\window.cpp:717: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvWaitKey'
解决办法:这个错误可真是解决太长时间,一直找不到原因,一直试一直试.....
Cv2的版本不能是4.5,需要指定成4.4或者以下。Python3.8装不上cv2 4.4。所以需要安装python3.7版本,这样才能将cv2的4.4版本安装上去。同时在安装库的时候需要先安装opnecv-python,不能先安装numpy,这样才能安装上cv2的4.4版本。
来源:https://blog.csdn.net/handsomeandge/article/details/116238172
猜你喜欢
- 一般我们能过VS2005的SQL explorer来添加一个本地的MDF文件。也许你可能会出现下面这个问题:Exception Detail
- 看lifesinger的《由Kimi找茬想到的》,我想到的:1、 我不同意将“合并付款”定调在“很多卖家都需要”。这个“很多”在卖家里面大概
- 前言大家做自动化登录时可能都遇到过滑块验证码需要手动验证的问题,这次我们就来解决他如下: 在我们做自动化登录时,总会遇到各种奇奇怪怪的验证
- Numpy创建矩阵并等间隔抽取数据1、利用Numpy创建向量和二维矩阵1.1 创建向量得到需要强调的是,向量的维度,在python中并不是书
- pycharm右键新建时会有目录(文件夹)和python package两个选项,这两个到底有什么不同呢1.原来在python模块的每一个包
- 一、前言越来越多的网站和App开始为用户搭建签到系统,以此来吸引和留住用户。签到系统是一种轻量、互动性强的营销方式,通过用户签到获取免费权益
- 想要一个这玩意,可是找了网上许多着色器,要么是兼容性成问题,要么是匹配不精确,比如说:1、注释里包含字符串、关键词,类似于:/* xxxx&
- 一、心知天气API密钥获取首先,访问https://www.seniverse.com,进行登录或者注册操作,然后在控制台上创建一个免费版的
- 在CSS中,实现分栏布局有两种方法。第一种方法是使用四种CSS定位选项(absolute 、static、relative和fixed)中的
- 对于如何结束一个Python程序或者用Python操作去结束一个进程等,Python本身给出了好几种方法,而这些方式也存在着一些区别,对相关
- 如下所示:<?php$dir = dirname(__FILE__);$open_dir = opendir($dir);echo &
- 现在有一个xml,格式如下: <date> <item> <id> 1 </id> <
- 刚刚看了bootstrap的导航栏,发现有点弄混了,现在来整理一下;导航栏是一个很好的功能,是 Bootstrap 网站的一个突出特点。导航
- 在项目里碰到需要把类似'450000'的数字转换为会计记账所用的格式,'450,000.00',分隔千分位和
- 运行下面两个命令,即可把 Vim(含插件)配置成 Python IDE。目前支持 MAC 和 Ubuntu。curl -O https://
- matplotlibmatplotlib是最流行的python底层绘图库,接下来就由小编为大家介绍一些关于matplotlib的一些基本图形
- 我想把存在数据库里的每天24小时来访者数另放到一个Excel文件中去,可以吗?可以,其实就是将数据库里面的内容生成一个Excel文件:toe
- 换脸!这段时间,deepfakes搞得火热,比方说把《射雕英雄传》里的朱茵换成了杨幂,看下面的图!毫无违和感!其实早在之前,基于AI换脸的技
- 本文实例讲述了PHP查询快递信息的方法。分享给大家供大家参考。具体如下:这里使用快递100物流查询官方文档中只能返回html的接口也可以返回
- 问题你想对在Unix系统上面运行的程序设置内存或CPU的使用限制。解决方案resource 模块能同时执行这两个任务。例如,要限制CPU时间