Is there any module in pytorch can extract sub region of conv feature map such as spatial transformer (given the affine matrix) or roi pooling layer(given the window’s 4-tuple coordinates)?
You could try using the ROIPooling implementation from https://github.com/longcw/faster_rcnn_pytorch/tree/master/faster_rcnn/roi_pooling
Note that implementing ROIPooling in pytorch can be very easily done with existing layers (even though it won’t be as efficient as the implementation from above), an example can be found in https://github.com/pytorch/examples/blob/d8d378c31d2766009db400ac03f41dd837a56c2a/fast_rcnn/roi_pooling.py#L38-L53 , where adaptive_max_pool
was recently merged into master.
while, I made a toy example to compare the speed: https://github.com/blackyang/compare_roi_pooling_speed
the rois are defined as [roi_id , left_coord , top_coord, right_coord, bot_coord] = [ roi_id , x1, y1 , x2, y2 ]
I noticed that it is not mentioned in the code, so maybe it can help someone.