视觉任务-目标跟踪检测DeepSort 与yolov5目标检测部署实践

目标跟踪检测算法DeepSort在window server 2012R 运行配置部署

目录

1.代码环境搭建
2. 报错解决方案
3. 运行调试
4. 演示演示结果

1 .代码环境搭建

  1. pycharm 2022
  2. python 3.8
  3. 2012R server
  4. 项目代码文件 https://github.com/mikel-brostrom/Yolov5_DeepSort_OSNet.git

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-22UsiFdk-1651371952077)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20220501095326668.png)]

  1. 文件夹 torchreid (https://github.com/KaiyangZhou/deep-person-reid.git)

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-sAhtNReZ-1651371952078)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20220501095031659.png)]

    整理一下,目录结构大致是这样的

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Y9psgiOB-1651371952079)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20220501095520916.png)]

    安装包,配置国内源比较快一点,我用的是清华源,至此基本完成项目配置

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/

小结:

pycharm 建立项目要熟练的使用,不然要搞的晕头转向,还有环境的切换,个人简易可以随便拉个python项目用conda下载包,换源,卸载包,这类的操作熟练,反正我就好烦,我电脑直接盘不够用,直接搞服务器了,

2. 报错解决方案

1. from .cv2 import * DLL laod failed 找不到指定模块

13e37f4f03ab2dc16dad2605884d8a55.png

原因:缺少相关库文件;

在网上检索了一下,目前有几种解决:

  1. 安装 visual studio c++;
  2. 下载相关的DLL 包,然后激活;
  3. CV2 与python 版本不匹配,下载相应的cv2 包对应相同的版本
  4. 综上,我都没有成功,2021R server服务器报错,以下是我的解决方案:

### [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-WkunzD0v-1651371952083)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20220501093257630.png)]

用户界面和基础结构这下面三个全选中,然后等待安装,安装完成后会重启服务器,再次连接就行了,安装时间一般为5-10 分钟

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-APgmTVcs-1651371952084)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20220501093532314.png)]

2.)目标主机无法连接,缺少权重文件.

在这里插入图片描述

这个需要到谷歌盘下载,不翻墙是下载不了的,下载不了是运行不了的,这个是权重的分享链接
这个是分享的链接
链接:https://pan.baidu.com/s/1jGcxCNi4agTdVz-IkN_UIA
提取码:1111

在这里插入图片描述

3. 运行调试

运行参数就这些,调整这些运行参数,来完成相应的功能

在这里插入图片描述

官方文档的用法,参考下,

Tracking can be run on most video formats

$ python track.py --source 0  # webcam
                           img.jpg  # image
                           vid.mp4  # video
                           path/  # directory
                           path/*.jpg  # glob
                           'https://youtu.be/Zgi9g1ksQHc'  # YouTube
                           'rtsp://example.com/media.mp4'  # RTSP, RTMP, HTTP stream

1. Yolov5

There is a clear trade-off between model inference speed and accuracy. In order to make it possible to fulfill your inference speed/accuracy needs you can select a Yolov5 family model for automatic download

$ python track.py --source 0 --yolo_model yolov5n.pt --img 640
                                          yolov5s.pt
                                          yolov5m.pt
                                          yolov5l.pt 
                                          yolov5x.pt --img 1280
                                          ...

2. DeepSort

The above applies to DeepSort models as well. Choose a ReID model based on your needs from this ReID model zoo

$ python track.py --source 0 --deep_sort_model osnet_x0_25_market1501
                                               osnet_x0_5_market1501
                                               osnet_x0_75_msmt17
                                               osnet_x1_0_msmt17
                                               ...

3. Filter tracked classes

By default the tracker tracks all MS COCO classes.

If you only want to track persons I recommend you to get these weights for increased performance

python3 track.py --source 0 --yolo_model yolov5/weights/crowdhuman_yolov5m.pt --classes 0  # tracks persons, only

If you want to track a subset of the MS COCO classes, add their corresponding index after the classes flag

python3 track.py --source 0 --yolo_model yolov5s.pt --classes 16 17  # tracks cats and dogs, only

Here is a list of all the possible objects that a Yolov5 model trained on MS COCO can detect. Notice that the indexing for the classes in this repo starts at zero.

4. MOT compliant results

Can be saved to your experiment folder runs/track/<yolo_model>_<deep_sort_model>/ by

python3 track.py --source ... --save-txt

5. 在命令行使用报错,可以使用pycharm 配置运行

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-uk6Pzhew-1651371952091)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20220501101909949.png)]

按照参考文档的方法进行使用,

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-6BUAJ2o0-1651371952093)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20220501102000076.png)]

4. 最后演示结果

目标跟踪

  • 5
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 13
    评论
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值