1 Star 1 Fork 1

vegetable0511/ReID2024

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
t.py 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
vegetable0511 提交于 2024-03-27 19:12 . 5
import numpy as np
def gaussian_kernel(distance_matrix, sigma):
return np.exp(-distance_matrix / (2 * sigma ** 2))
# temp_dist = np.array([[0.5, 1, 2],
# [0.7, 4, 3],
# [2, 3, 0.6]]
# )
temp_dist = np.array([[2.2796936e+00, 1.4185905e-04, 2.1287000e+00, 1.8230720e+00, 2.0047464e+00, 1.9925015e+00],
[1.8264387e+00, 2.2247264e+00, 2.1148393e+00, 1.8682027e+00, 2.1857731e+00, 2.0481849e+00],
[2.1379218e+00, 1.7820594e+00, 1.9546708e+00, 2.1857350e+00, 2.2835042e+00, 2.2263017e+00],
[1.7801874e+00, 1.9467703e+00, 1.7516470e+00, 1.5445557e+00, 2.1465287e+00, 1.7326559e+00],
[1.3039300e+00, 1.8856990e+00, 2.0850537e+00, 1.8263741e+00, 1.9664614e+00, 1.2030802e+00],
[6.8809760e-01, 1.9833440e+00, 2.0243869e+00, 2.1859434e+00, 2.1319501e+00, 1.6423464e-03]])
temp_min = np.min(temp_dist, axis=1)
index1 = np.where(temp_min < 0.6)[0]
weight1 = temp_dist[index1,:].mean(axis=0)
weight1 = 1.0/(weight1 + 0.01)
weight1 = weight1/np.sum(weight1)
gaus_dist = gaussian_kernel(temp_dist, sigma=0.9)
gaus_max = np.max(gaus_dist, axis=1)
index2 = np.where(gaus_max > 0.6)[0]
weight2 = gaus_dist[index2,:].mean(axis=0)
weight2 = weight2/np.sum(weight2)
print(gaus_dist)
print('------temp------')
print(temp_min)
print(index1)
print(weight1)
print('------gaus-------')
print(gaus_max)
print(index2)
print(weight2)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/vegetable0511/re-id2024.git
git@gitee.com:vegetable0511/re-id2024.git
vegetable0511
re-id2024
ReID2024
master

搜索帮助