Skip to content
DeepForgeby svx
All problems
HardComputer Visioncv-207

ROI Align Single Sample

Problem

Sample a fixed-size ROI Align grid from a feature map.

For each pooled cell use the bin center (y1 + (ph + 0.5) * roi_h / pooled, x1 + (pw + 0.5) * roi_w / pooled) and bilinearly interpolate with coordinates clamped to the feature bounds. Return the pooled x pooled grid rounded to 4 decimal places.

Test cases

case 1
in: [[[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]],[0,0,4,4],2]
expected: [[6,8],[14,16]]
case 2
in: [[[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]],[0.5,0.5,3.5,3.5],2]
expected: [[7.25,8.75],[13.25,14.75]]
case 3
in: [[[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]],[0,0,4,4],1]
expected: [[11]]
case 4
in: [[[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]],[1,1,3,3],2]
expected: [[8.5,9.5],[12.5,13.5]]
Starter codePython
def roi_align(feature, roi, pooled_size):
    # Your code here
    pass

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