YOLOv5+Deepsort的环境配置

首先在https://github.com/mikel-brostrom/Yolov5_DeepSort_Pytorch下载YOLOv5+Deepsort的v2版本也可以v3版本,这里就v2版本演示,
此处https://github.com/ultralytics/yolov5/tree/v5.0下载YOLOV5的v5版本。
注意:版本要符合YOLOv5+Deepsort v2和Yolov5中v5版本相配适,YOLOv5+Deepsort v3和YoloV5中v6版本相配适
YOLOv5+Deepsort的环境配置_第1张图片
YOLOv5+Deepsort的环境配置_第2张图片
下载权重文件
将网盘中YOLOv5的权重文件放置在yolov5/weights文件夹下,DeepSort的权重文件ckpt.t7放置在deep_sort/deep/checkpoint文件夹下

链接:https://pan.baidu.com/share/init?surl=5c0i-EQuKiTXrOGp3ShxvQ
提取码:u5v3

使用anaconda建立一个DeepSort虚拟环境:

conda create -n DeepSort python=3.8
conda activate DeepSort

安装pytorch1.7和cuda10.2
由于更新了yolov5,因此,pytorch的版本也需要更新到1.7以上,我这里匹配的是cuda 10.2。

pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html

在pycharm中安装requirements.txt文件。

pip install -r requirements.txt

在requirements.txt中opencv-python可能安装不上。可以直接在pycharm终端上安装。

pip install opencv-python

之后需要测试视频:
下载链接:https://pan.baidu.com/s/1VOVy0kcXvwDX03QE56JmEw
提取码:pd63

在pycharm终端上运行
python3 track.py --source (test.mp4测试视频名字) --show-vid

文件类型不同,命令不同:
Video: --source file.mp4 # python track.py --source=“011.mp4” --show-vid
Webcam: --source 0
RTSP stream: --source rtsp://170.93.143.139/rtplive/470011e600ef003a004ee33696235daa
HTTP stream: --source http://wmccpinetop.axiscam.net/mjpg/video.mjpg

可能还会报一个错误:
Hint: This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://www.intel.com/software/products/support/.

解决方法:
在track.py文件中加入下列代码:

import os
 
os.environ['KMP_DUPLICATE_LIB_OK']='True'

再运行代码。就成功了

你可能感兴趣的:(深度学习,pytorch,深度学习,人工智能)