Skip to content
DeepForgeby svx
All problems
HardDeep Learningdl-139

Anchor-Free Center Heatmap

Problem

Build a Gaussian center heatmap for anchor-free detection. The output grid has ceil(size / stride) cells per dimension; cell (i, j) has center (j * stride + stride / 2, i * stride + stride / 2). Its value is exp(-d^2 / (2 * sigma^2)) where d is the distance to the object center and sigma = radius / 3.

The signature is center_heatmap(width, height, stride, center_x, center_y, radius).

Hint

The peak is 1.0 when the object center lands exactly on a cell center.

Test cases

case 1
in: [4,4,1,1.5,1.5,1]
expected: [[0.0001234098,0.0111089965,0.0001234098,2e-10],[0.0111089965,1,0.0111089965,1.52e-8],[0.0001234098,0.0111089965,0.0001234098,2e-10],[2e-10,1.52e-8,2e-10,0]]
case 2
in: [4,4,2,1,1,1.5]
expected: [[1,0.0003354626],[0.0003354626,1.125e-7]]
case 3
in: [2,2,1,0,0,3]
expected: [[0.7788007831,0.2865047969],[0.2865047969,0.1053992246]]
Starter codePython
import math
def center_heatmap(width, height, stride, center_x, center_y, radius):
    # Your code here
    pass

3 test cases · run your code against them in the editor