1、安装python3.8
| 1 | apt-get install python3.8-distutils -y |
| 2 | apt-get install python3.8-tk -y |
| 3 | apt-get install curl -y |
| 4 | curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py |
| 5 | python3.8 get-pip.py |
2、下载代码
git clone --recurse-submodules https://github.com/mikel-brostrom/Yolov5_DeepSort_Pytorch.git
3、安装依赖
pip install -r requirements.txt
这里的torch需要针对你的显卡和CUDA版本来进行安装。
python3.8 -m pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio===0.8.1 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.tun
a.tsinghua.edu.cn/simple
我的是3070显卡。
4、开始检测视频
python3.8 track.py --source 1.mp4 --save-vid --save-txt --classes 0
5、分析结果
id_dict = {}
for line in open('../exp11/1.txt'):
id = line.split(' ')[1]
if id not in id_dict:
id_dict[id] = 1
else:
id_dict[id] += 1
print(len(id_dict))
{'1': 468,
'2': 5,
'3': 768,
'7': 3,
'9': 6,
'10': 110,
'11': 7,
'19': 2,
'21': 2,
'23': 86,
'27': 46,
'29': 378,
'34': 222,
'35': 194,
'43': 120}

很明显,出现少于10次的数据可以舍弃掉。
最终检测到9个人。
与人眼分析的结果一致!!
该博客介绍了如何在Ubuntu上安装Python3.8和相关库,然后利用GitHub上的Yolov5_DeepSort_Pytorch项目进行实时多目标跟踪。通过运行指定命令检测视频,并分析跟踪结果,剔除出现次数少于10次的目标,最终确定检测到9个人,验证了结果与人眼分析的一致性。
https://github.com/mikel-brostrom/Yolov5_DeepSort_Pytorch
2226

被折叠的 条评论
为什么被折叠?



