I ported crop_and_resize from tensorflow for pytorch.
F.grid_sample has to expand the input feature and cost a lot of memery if we have too many rois.
crops = F.grid_sample(bottom.expand(rois.size(0), bottom.size(1), bottom.size(2), bottom.size(3)), grid)


  
      
      GitHub
  
  
    

longcw/RoIAlign.pytorch 85

RoIAlign.pytorch - RoIAlign & crop_and_resize for PyTorch