具體參考:(如果侵權(quán)需忿,速刪)
- https://zhuanlan.zhihu.com/p/354945895
-
https://blog.csdn.net/qq_44703886/article/details/121327643
3.https://blog.csdn.net/weixin_50008473/article/details/122347582
4.https://zhuanlan.zhihu.com/p/50387521
5.https://blog.csdn.net/fengdu78/article/details/119431155
6.https://blog.csdn.net/didiaopao/article/details/120274519
github:1.https://github.com/mikel-brostrom/Yolov5_DeepSort_Pytorch
2.https://github.com/layumi/Person_reID_baseline_pytorch
環(huán)境:
Nvidia RTX 3060
Ubuntu 16.04
CUDA 11.1
cuDNN 8.2.0
torch 1.10.1+cu111
torchvision 0.11.2+cu111
一、搭建YOLOv5-DeepSORT虛擬環(huán)境
1.使用conda創(chuàng)建 YOLOv5-DeepSORT 需要的環(huán)境
conda create -n yolov5_deepsort python=3.8 //yolov5_deepsort是虛擬環(huán)境的名字
source activate yolov5_deepsort
2.下載YOLOv5-DeepSORT工程
YOLOv5-DeepSORT版本需要和YOLOv5版本對(duì)應(yīng)渤早,對(duì)應(yīng)關(guān)系參考另一篇文章:http://www.reibang.com/p/bfec81af1cf9 (親測(cè)YOLOv5 v5.0 + DeepSORT v2.0 可運(yùn)行)
(1)YOLOv5-DeepSORT官網(wǎng)地址:https://github.com/mikel-brostrom/Yolov5_DeepSort_Pytorch
//DeepSORT 官網(wǎng)版本
git clone https://github.com/mikel-brostrom/Yolov5_DeepSort_Pytorch
(2)YOLOv5-DeepSORT版本有很多,也可以點(diǎn)擊 master - tag可以下載不同的版本
使用zip解壓命令:unzip Yolov5_DeepSort_Pytorch-2.0(以v2.0為例)
3.安裝依賴
cd Yolov5_DeepSort_Pytorch-2.0
注意:requirements.txt依賴項(xiàng)的Python 3.8 或更高版本,包括torch>=1.7.0,torchvision>=0.8.1
(1)可以使用pip命令安裝
pip install -r requirements.txt
(2)pytorch及各種import可自行安裝饿肺,注意pytorch和cuda版本需對(duì)應(yīng)蒋困,官網(wǎng)地址:https://pytorch.org/get-started/previous-versions/ 對(duì)應(yīng)關(guān)系如下:
本文選擇使用官網(wǎng)命令進(jìn)行安裝盾似,torch 1.10.1+cu111,torchvision 0.11.2+cu111
pip install torch==1.10.1+cu111 torchvision==0.11.2+cu111 torchaudio==0.10.1 -f https://download.pytorch.org/whl/torch_stable.html
import:
需要下載的包
(1)出現(xiàn)問題:ModuleNotFoundError: No module named 'cv2'
pip install opencv-python
(2)出現(xiàn)問題:ModuleNotFoundError: No module named 'pandas'
pip install pandas
(3)出現(xiàn)問題:ModuleNotFoundError: No module named 'requests'
pip install requests
(4)出現(xiàn)問題:ModuleNotFoundError: No module named 'yaml'
pip install pyyaml
(5)出現(xiàn)問題:ModuleNotFoundError: No module named 'tqdm'
pip install tqdm
(6)出現(xiàn)問題:ModuleNotFoundError: No module named 'matplotlib'
pip install matplotlib
(7)出現(xiàn)問題:ModuleNotFoundError: No module named 'seaborn'
pip install seaborn
二雪标、訓(xùn)練自己的數(shù)據(jù)
1.需要準(zhǔn)備的如下文件
(1)YOLOv5權(quán)重文件零院,放在~/code/Yolov5_DeepSort_Pytorch-3.0/yolov5/runs/train/exp4/weights下的best.pt
(2)重識(shí)別/分類模型,放在~/code/Yolov5_DeepSort_Pytorch-3.0/deep_sort_pytorch/deep_sort/deep/checkpoint下的ckpt.t7
(3)待追蹤的視頻村刨,放在~/code/Yolov5_DeepSort_Pytorch-3.0下的800-1.avi
2.執(zhí)行命令:
cd ~/code/Yolov5_DeepSort_Pytorch-3.0
python track.py --yolo_weights yolov5/weights/best.pt --source 800-1.mp4 --deep_sort_weights deep_sort_pytorch/deep_sort/deep/checkpoint/ckpt.t7 --device 0 --save-vid --save-txt
YOLOv5 v2.0版本出現(xiàn)問題除了下載一堆包以外告抄,遇到兩個(gè)問題
問題1:RuntimeError: a view of a leaf Variable that requires grad is being used in an in-place operation.
解決方法參考:https://blog.csdn.net/weixin_44612221/article/details/115359866
問題2:AttributeError: Can't get attribute 'SPPF' on <module 'models.common' from '/home/slave110/code/yolov5-5.0/models/common.py'>
解決方法參考:https://www.bilibili.com/read/cv14568709