1.下载
BoT-SORT github:传送门
git clone https://github.com/NirAharon/BOT-SORT.git
1.1 环境配置
我是无脑直接
conda create -n botsort_env python=3.7
conda activate botsort_env
pip install -r requirements.txt
在pytorch官网选择合适版本
我是11.4但是没有对应版本只能先下载11.3试试看
conda install pytorch torchvision torchaudio cudatoolkit=11.4 -c pytorch -c conda-forge
其实不是所有安装包都需要的,可(yi)以(ding)参考下面这个文档
【参考文档】【第47篇】BoT-SORT实战:手把手教你实现BoT-SORT训练和测试
1.2 报错 及 解决办法
1.2.1 ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30‘ not found
主要看版本中是否存在对应的GLIBCXX_3.4.30,才可以进行软连接,建议是直接移步到参考文档
【参考文档】ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22‘ not found
1.2.2 ImportError: cannot import name ‘Image‘ from ‘PIL’
可能是版本不兼容,删掉重装可能会好,或者是安装一个较低版本
1.2.3网络不行导致resnet下载失败
直接去github下载
然后
cp 《下载文件路径》 《提示安装路径》
比如
cp /home/public/evening_yolo/tracker/resnest50-528c19ca.pth /home/public/.cache/torch/hub/checkpoints/
2. 回归代码看论文核心创新点
是基于之前的bytetrack进行的改进和创新。
核心创新点:
- 卡尔曼滤波器直接输出长宽而不是比例
- 相机运动模型CMC
- IoU和ReID融合
其他和bytetrack其实也是大同小异
2.1 直接输出长宽
主要体现在KalmanFilter类的initiate函数
2.2 相机运动模型CMC
主要体现在第一次关联之后使用相机运动模型优化
''' Step 2: First association, with high score detection boxes'''
strack_pool = joint_stracks(tracked_stracks, self.lost_stracks)
# Predict the current location with KF
STrack.multi_predict(strack_pool)
# Fix camera motion
warp = self.gmc.apply(img, dets)
STrack.multi_gmc(strack_pool, warp)
STrack.multi_gmc(unconfirmed, warp)
2.2.1 multi_gmc
def multi_gmc(stracks, H=np.eye(2, 3)):
if len(stracks) > 0:
multi_mean = np.asarray([st.mean.copy() for st in stracks])
multi_covariance = np.asarray([st.covariance for st in stracks])
R = H[:2, :2]#得到影响所有状态向量和噪声矩阵的第一部分 M2*2
R8x8 = np.kron(np.eye(4, dtype=float), R)
'''得到的论文中的M矩阵
M 0 0 0
0 M 0 0
0 0 M 0
0 0 0 M
'''
t = H[:2, 2]#得到平移部分T2*1
for i, (mean, cov) in enumerate(zip(multi_mean, multi_covariance)):
'''x=M * x'''
mean = R8x8.dot(mean)
'''x=M * x + T'''
mean[:2] += t
cov = R8x8.dot(cov).dot(R8x8.transpose())#P' = M * P * M^T
stracks[i].mean = mean
stracks[i].covariance = cov
2.3 IoU和ReID融合
(1)公式12
#-------公式12----------
emb_dists = matching.embedding_distance(strack_pool, detections) / 2.0#计算特征的cost矩阵
raw_emb_dists = emb_dists.copy()
emb_dists[emb_dists > self.appearance_thresh] = 1.0
emb_dists[ious_dists_mask] = 1.0
(2)公式13
# -------公式13----------
dists = np.minimum(ious_dists, emb_dists)#使用矩阵中每个元素的最小值作为成本矩阵C的最终值