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.

inconsistant anchor reference (may be the cause of the lower accuracy than faster-rcnn)

See original GitHub issue

Hi,

Please notice you have an inconsistant reference to the order of the anchors (lines 86 and 79)

https://github.com/jwyang/fpn.pytorch/blob/23bd1d2fa09fbb9453f11625d758a61b9d600942/lib/model/rpn/rpn_fpn.py#L86

https://github.com/jwyang/fpn.pytorch/blob/23bd1d2fa09fbb9453f11625d758a61b9d600942/lib/model/rpn/rpn_fpn.py#L79

lets say k is the number of anchors

than in line 79 you are doing softmax after reshape which make anchors: 0:k-1 assosiated with proposal = false k:2k-1 assosiated with proposal = True.

and in line 86 your anchors are arranged in a different way: i mod 2 == 0 associated with proposal = false i mod 2 == 1 associated with proposal = True.

I propose to reshape the score in this way to be consistant. (You will also need to change few other things in proposalLayer for it to work)

rpn_cls_scores.append(rpn_cls_score_reshape.permute(0, 2, 3, 1).contiguous().view(batch_size, -1, 2))

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:9
  • Comments:22 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
Feynman27commented, Apr 17, 2018

Okay, I see here that the indices of the scores/probs must exactly match the indices of the bbox_deltas. I’ve changed the anchor generation minimally such that the enumeration order is (Width x Height x Anchor):

# Reshape to get a list of (x, y) and a list of (w, h)
#  Enumerate by (Width x Height x Anchor)
box_centers = np.stack([box_centers_x.transpose(1,0).reshape(-1),
                        box_centers_y.transpose(1,0).reshape(-1)], axis=1)
box_sizes = np.stack([box_widths.transpose(1,0).reshape(-1),
                     box_heights.transpose(1,0).reshape(-1)], axis=1)
# Convert to corner coordinates (x1, y1, x2, y2)
boxes = np.concatenate([box_centers - 0.5 * box_sizes,
              box_centers + 0.5 * box_sizes], axis=1)
2reactions
Feynman27commented, Apr 17, 2018

So maybe we could match the order by doing something like:

rpn_bbox_pred = self.RPN_bbox_pred(rpn_conv1)
# reshape to match order of anchors
rpn_bbox_pred_reshape = rpn_bbox_pred.view(rpn_bbox_pred.size(0), 
                                           rpn_bbox_pred.size(1)/4, 
                                           4, 
                                           rpn_bbox_pred.size(2), 
                                           rpn_bbox_pred.size(3))
rpn_bbox_pred_reshape = rpn_bbox_pred_reshape.permute(0,1,3,4,2).contiguous().view(batch_size, -1, 4)

This would have an enumeration order of (Width x Height x Anchor)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Faster R-CNN: Towards Real-Time Object Detection with ...
Even such a large stride provides good results, though accuracy may be further improved with a smaller stride. For anchors, we use 3...
Read more >
Anchoring Faster RCNN - Cross Validated - Stack Exchange
For each anchor then the RPN predicts the probability of containing an object in general and four correction coordinates to move and resize ......
Read more >
A Convolutional Neural Network Combining Discriminative ...
It can be seen from Figure 10a that the proposed method and variants in this paper are better than Faster RCNN. After the...
Read more >
Improved Faster RCNN Based on Feature Amplification ...
The detection accuracy of DFPN with the horizontal anchors are comparable with that of FPN with the horizontal anchors. The same problem exists...
Read more >
Faster R-CNN: Towards Real-Time Object Detection with ...
simple alternating optimization, RPN and Fast R-CNN can be trained to share ... R-CNNs produce detection accuracy better than the strong baseline of ......
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