首先在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的权重文件放置在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'
再运行代码。就成功了
版权声明:本文为博主..Severus原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/qq_51123264/article/details/121275150