赞
踩
最近在学习目标追踪,记录下Yolov5-Deepsort-Fastreid 的环境配置过程
1、在GitHub搜索框上输入yolov5-Deepsort-Fastreid ,或者直接访问https://github.com/zengwb-lx/Yolov5-Deepsort-Fastreid
2.在Code 下拉列表中选择Download ZIP。 下载源码文件
3.下载完毕后,解压至合适的位置。
1.在开始菜单栏中找到Anacond3里面的Anaconda prompt(Anaconda3) ,打开Anaconda prompt 命令窗口。
2.使用命令创建yolov5-deepsort-fastreid的环境
conda create -n yolov5-deepsort-fastreid python=3.7
3.使用命令激活yolov5-deepsort-fastreid 环境
conda activate yolov5-deepsort-fastreid
4.安装cudatoolkit cudnn
conda install cudatoolkit=10.2.89 cudnn=7.6.5
5.安装pytorch torvision。根据pytorch 官网的命令进行安装
# CUDA 10.2
pip install torch==1.10.1+cu102 torchvision==0.11.2+cu102 torchaudio==0.10.1 -f https://download.pytorch.org/whl/torch_stable.html
6.测试cuda、torch 是否正确安装
//输入python ,进入python环境
Python 3.7.13 (default, Mar 28 2022, 08:03:21) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.cuda.is_available())
True
>>>exit()
//结果返回True 表示安装正确
7.安装requirements.txt。
在步骤5中已经安装了torch、torchvision,在requirements.txt中需要注释掉
pip install -r requirements.txt
8.安装faiss-cpu
pip install faiss-cpu
9.整个环境如下所示:
absl-py 1.1.0 pypi_0 pypi
anykeystore 0.2 pypi_0 pypi
apex 0.1 pypi_0 pypi
blas 1.0 mkl https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ca-certificates 2022.4.26 haa95532_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
cachetools 5.2.0 pypi_0 pypi
certifi 2022.6.15 py37haa95532_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
colorama 0.4.5 pypi_0 pypi
cryptacular 1.6.2 pypi_0 pypi
cudatoolkit 10.2.89 h74a9793_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
cudnn 7.6.5 cuda10.2_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
cycler 0.11.0 pypi_0 pypi
cython 0.29.30 pypi_0 pypi
cython-based-reid-evaluation-code 0.0.0 pypi_0 pypi
easydict 1.9 pypi_0 pypi
faiss-cpu 1.7.2 pypi_0 pypi
fonttools 4.33.3 pypi_0 pypi
freetype 2.10.4 hd328e21_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
google-auth 2.8.0 pypi_0 pypi
google-auth-oauthlib 0.4.6 pypi_0 pypi
greenlet 1.1.2 pypi_0 pypi
grpcio 1.47.0 pypi_0 pypi
hupper 1.10.3 pypi_0 pypi
importlib-metadata 4.11.4 pypi_0 pypi
infomap 2.5.0 pypi_0 pypi
intel-openmp 2021.4.0 haa95532_3556 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
joblib 1.1.0 pypi_0 pypi
jpeg 9e h2bbff1b_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
kiwisolver 1.4.3 pypi_0 pypi
libpng 1.6.37 h2a8f88b_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libtiff 4.2.0 he0120a3_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libuv 1.40.0 he774522_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libwebp 1.2.2 h2bbff1b_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
lz4-c 1.9.3 h2bbff1b_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
markdown 3.3.7 pypi_0 pypi
markupsafe 2.1.1 pypi_0 pypi
matplotlib 3.5.2 pypi_0 pypi
mkl 2021.4.0 haa95532_640 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl-service 2.4.0 py37h2bbff1b_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl_fft 1.3.1 py37h277e83a_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl_random 1.2.2 py37hf11a4ad_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
numpy 1.21.6 pypi_0 pypi
numpy-base 1.21.5 py37hca35cd5_3 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
oauthlib 3.2.0 pypi_0 pypi
opencv-python 4.6.0.66 pypi_0 pypi
openssl 1.1.1o h2bbff1b_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
packaging 21.3 pypi_0 pypi
pastedeploy 2.1.1 pypi_0 pypi
pbkdf2 1.3 pypi_0 pypi
pillow 9.0.1 py37hdc2b20a_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pip 21.2.4 py37haa95532_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
plaster 1.0 pypi_0 pypi
plaster-pastedeploy 0.7 pypi_0 pypi
protobuf 3.19.4 pypi_0 pypi
pyasn1 0.4.8 pypi_0 pypi
pyasn1-modules 0.2.8 pypi_0 pypi
pyparsing 3.0.9 pypi_0 pypi
pyramid 2.0 pypi_0 pypi
pyramid-mailer 0.15.1 pypi_0 pypi
python 3.7.13 h6244533_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
python-dateutil 2.8.2 pypi_0 pypi
python3-openid 3.2.0 pypi_0 pypi
pytorch 1.10.1 py3.7_cuda10.2_cudnn7_0 pytorch
pytorch-mutex 1.0 cuda pytorch
pyyaml 6.0 py37h2bbff1b_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
repoze-sendmail 4.4.1 pypi_0 pypi
requests-oauthlib 1.3.1 pypi_0 pypi
rsa 4.8 pypi_0 pypi
scikit-learn 1.0.2 pypi_0 pypi
scipy 1.7.3 pypi_0 pypi
setuptools 61.2.0 py37haa95532_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
six 1.16.0 pyhd3eb1b0_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
sklearn 0.0 pypi_0 pypi
sqlalchemy 1.4.38 pypi_0 pypi
sqlite 3.38.3 h2bbff1b_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
tabulate 0.8.10 pypi_0 pypi
tensorboard 2.9.1 pypi_0 pypi
tensorboard-data-server 0.6.1 pypi_0 pypi
tensorboard-plugin-wit 1.8.1 pypi_0 pypi
termcolor 1.1.0 py37haa95532_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
threadpoolctl 3.1.0 pypi_0 pypi
tk 8.6.12 h2bbff1b_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
torchaudio 0.10.1 py37_cu102 pytorch
torchvision 0.11.2 py37_cu102 pytorch
tqdm 4.64.0 pypi_0 pypi
transaction 3.0.1 pypi_0 pypi
translationstring 1.4 pypi_0 pypi
typing_extensions 4.1.1 pyh06a4308_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
vc 14.2 h21ff451_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
velruse 1.1.1 pypi_0 pypi
venusian 3.0.0 pypi_0 pypi
vs2015_runtime 14.27.29016 h5e58377_2 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
webob 1.8.7 pypi_0 pypi
werkzeug 2.1.2 pypi_0 pypi
wheel 0.37.1 pyhd3eb1b0_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
wincertstore 0.2 py37haa95532_2 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
wtforms 3.0.1 pypi_0 pypi
wtforms-recaptcha 0.3.2 pypi_0 pypi
xz 5.2.5 h8cc25b3_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
yacs 0.1.6 pyhd3eb1b0_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
yaml 0.2.5 he774522_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
zipp 3.8.0 pypi_0 pypi
zlib 1.2.12 h8cc25b3_2 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
zope-deprecation 4.4.0 pypi_0 pypi
zope-interface 5.4.0 pypi_0 pypi
zope-sqlalchemy 1.6 pypi_0 pypi
zstd 1.5.2 h19a0ad4_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
1.测试命令
python person_count.py
2.测试结果部分截图
2022-06-28 16:23:24 [INFO]: 86/time: 0.112s, fps: 8.952, detection numbers: 34, tracking numbers: 36
yolo+deepsort: 0.0638284683227539
2022-06-28 16:23:24 [INFO]: 87/time: 0.111s, fps: 9.033, detection numbers: 35, tracking numbers: 35
yolo+deepsort: 0.056847333908081055
2022-06-28 16:23:24 [INFO]: 88/time: 0.102s, fps: 9.830, detection numbers: 32, tracking numbers: 35
yolo+deepsort: 0.059839487075805664
2022-06-28 16:23:24 [INFO]: 89/time: 0.104s, fps: 9.641, detection numbers: 32, tracking numbers: 32
yolo+deepsort: 0.06283211708068848
2022-06-28 16:23:24 [INFO]: 90/time: 0.107s, fps: 9.371, detection numbers: 33, tracking numbers: 33
yolo+deepsort: 0.05784487724304199
2022-06-28 16:23:25 [INFO]: 91/time: 0.105s, fps: 9.549, detection numbers: 31, tracking numbers: 33
yolo+deepsort: 0.06582355499267578
2022-06-28 16:23:25 [INFO]: 92/time: 0.114s, fps: 8.795, detection numbers: 33, tracking numbers: 33
yolo+deepsort: 0.06183505058288574
2022-06-28 16:23:25 [INFO]: 93/time: 0.110s, fps: 9.115, detection numbers: 33, tracking numbers: 34
yolo+deepsort: 0.07679462432861328
2022-06-28 16:23:25 [INFO]: 94/time: 0.122s, fps: 8.219, detection numbers: 37, tracking numbers: 36
yolo+deepsort: 0.06682109832763672
2022-06-28 16:23:25 [INFO]: 95/time: 0.112s, fps: 8.952, detection numbers: 33, tracking numbers: 37
yolo+deepsort: 0.06382918357849121
2022-06-28 16:23:25 [INFO]: 96/time: 0.109s, fps: 9.199, detection numbers: 37, tracking numbers: 37
yolo+deepsort: 0.06283283233642578
2022-06-28 16:23:25 [INFO]: 97/time: 0.111s, fps: 9.033, detection numbers: 35, tracking numbers: 38
1.TypeError: load() missing 1 required positional argument: ‘Loader’
在Yaml 5.1版本后弃用了 yaml.load(file) 这个用法。Yaml 5.1版本之后就修改了需要指定Loader,通过默认加载器(FullLoader)禁止执行任意函数,使得此load函数的安全得到加强。因此在Yaml大于5.1的版本,需要做如下修改。以下三种方法均可。
d1=yaml.load(file,Loader=yaml.FullLoader)
d1=yaml.safe_load(file)
d1=yaml.load(file, Loader=yaml.CLoader)
2.ImportError: cannot import name ‘container_abcs’ from ‘torch._six’
ImportError: cannot import name ‘int_classes’ from ‘torch._six’
原因是在1.8版本之后container_abcs就已经被移除了。所以导入方式不同会出现这样的错误:cannot import name ‘container_abcs’ from ‘torch._six’
因此使用不同版本的torch会出现不同问题。
1.8以下版本使用 from torch._six import container_abcs;
1.8以上版本使用import collections.abc as container_abcs
//由于目前安装的torch 版本为10.1,大于1.8。将from torch._six import container_abcs, string_classes, int_classes 替换如下即可
# from torch._six import container_abcs, string_classes, int_classes
import collections.abc as container_abcs
int_classes = int
string_classes = str
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。