question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Understanding ROIPool

See original GitHub issue

❓ Questions and Help

Shouldn’t feature_map[:,:,:7,:7].max(1)[0] be equal to roi_pool(feature_map[None], bbox_tmp) in the following case? thanks in advance!

import torch
from maskrcnn_benchmark.layers import ROIPool
feature_map = torch.rand(1,256, 80, 160).cuda()
bbox_tmp = torch.FloatTensor([[0, 0, 0, 7, 7]]).cuda()
roi_pool = ROIPool((7,7), spatial_scale=1.0)
roi_pool(feature_map[None], bbox_tmp)                                                                                                                                                                                                               
tensor([[[[0.8403, 0.8633, 0.8704, 0.8704, 0.6135, 0.8561, 0.8561],
          [0.8403, 0.8633, 0.8633, 0.8820, 0.8820, 0.8215, 0.3497],
          [0.8174, 0.7352, 0.8100, 0.8820, 0.8820, 0.8215, 0.9108],
          [0.8174, 0.6335, 0.8100, 0.8100, 0.8296, 0.8296, 0.9108],
          [0.9459, 0.9459, 0.6566, 0.6566, 0.8296, 0.8296, 0.3599],
          [0.9459, 0.9459, 0.8508, 0.6646, 0.7663, 0.7663, 0.6380],
          [0.8416, 0.8508, 0.9013, 0.9013, 0.7663, 0.7663, 0.6380]]]],
       device='cuda:0')

feature_map[:,:,:7,:7].max(1)[0]
tensor([[[0.9961, 0.9978, 0.9998, 0.9906, 0.9947, 0.9965, 0.9963],
         [0.9989, 0.9929, 0.9914, 0.9813, 0.9977, 0.9999, 0.9981],
         [0.9976, 0.9995, 0.9979, 0.9955, 0.9948, 0.9991, 0.9985],
         [0.9992, 0.9991, 0.9988, 0.9970, 0.9972, 0.9950, 0.9986],
         [0.9982, 0.9966, 0.9968, 0.9852, 0.9983, 0.9897, 0.9916],
         [0.9890, 0.9920, 0.9989, 0.9997, 0.9959, 0.9977, 0.9932],
         [0.9985, 0.9861, 0.9852, 0.9946, 0.9983, 0.9993, 0.9971]]],
       device='cuda:0')

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
IssamLaradjicommented, Jan 11, 2019

Ah that makes sense! thanks a lot 😃

0reactions
fmassacommented, Jan 11, 2019

Your bounding box is going outside of the image, which is causing it to add some padding while performing the crop.

This gives a zero tensor:

feature_map = torch.rand(1, 1, 5, 5).cuda()
bbox = torch.tensor([[0, 0, 0, 4, 4]], dtype=torch.float32, device='cuda')
roi_pool = ROIPool((5, 5), spatial_scale=1.0)
print(roi_pool(feature_map, bbox) - feature_map)
tensor([[[[0., 0., 0., 0., 0.],
          [0., 0., 0., 0., 0.],
          [0., 0., 0., 0., 0.],
          [0., 0., 0., 0., 0.],
          [0., 0., 0., 0., 0.]]]], device='cuda:0')

I’m closing the issue, but let me know if you still have questions

Read more comments on GitHub >

github_iconTop Results From Across the Web

Region of interest pooling explained
Region of interest pooling (also known as RoI pooling) is an operation widely used in object detection tasks using convolutional neural ...
Read more >
Understanding Region of Interest (RoI Pooling) - Kemal Erdem
RoI (Region of Interest) is a proposed region from the original image. We're not going to describe how to extract those regions because...
Read more >
Region of Interest Pooling
Region of Interest (ROI) pooling is used for utilising single feature map for all the proposals generated by RPN in a single pass....
Read more >
Detailed Explanation of RoI Pooling vs RoI Align vs ...
In the last article, we went through the steps of building an object detector using Mask R-CNN which is able to output a...
Read more >
Annotated RPN, ROI Pooling and ROI Align - Kaushik's Blog
In this blog post we will implement and understand a few core components of two stage object ... ROI Pool aims to solve...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found