簡介
- CornerNet 是最經典的Anchor-free方法,本博客主要介紹數據預處理中最核心步驟: ground truth heatmaps。
方法
![在這裏插入圖片描述]()
- 如上圖所示, 有三種顏色的圖形, 紅色框代表ground truth, 綠色框的角點在橙色圓圈裏面, gound truth heatmap就是通過高斯分佈函數生成, 以ground thuth 的兩個角點爲中心,半徑爲r, 利用高斯分佈分數生成heatmap,其中,角點爲positive, 其餘地方爲negative。具體公式如下:
guassions(x,y)=e−2σ2x2+y2
σ=31r
- 半徑r的確定比較複雜, 其中要確保兩個小圓區域內所有角點的組合生成的框(綠色)和ground truth的iou要大於一個值(默認0.3) ,半徑具體生成可以論文作者的issues.主要是利用解方程和極限情況求解。
- 生成半徑代碼
def gaussian_radius(det_size, min_overlap=0.7):
height, width = det_size
a1 = 1
b1 = (height + width)
c1 = width * height * (1 - min_overlap) / (1 + min_overlap)
sq1 = np.sqrt(b1 ** 2 - 4 * a1 * c1)
r1 = (b1 + sq1) / 2
a2 = 4
b2 = 2 * (height + width)
c2 = (1 - min_overlap) * width * height
sq2 = np.sqrt(b2 ** 2 - 4 * a2 * c2)
r2 = (b2 + sq2) / 2
a3 = 4 * min_overlap
b3 = -2 * min_overlap * (height + width)
c3 = (min_overlap - 1) * width * height
sq3 = np.sqrt(b3 ** 2 - 4 * a3 * c3)
r3 = (b3 + sq3) / 2
return min(r1, r2, r3)