tensorflow / tensorflow/models

Comments for tile_anchors() incorrectly state number of boxes generated.

Open
#9,654 0 comments 0 reactions 3 assignees View on GitHub

@pkulzc is already working on this.

Since Jan 22, 2021.

models:research:odapi type:docs
Dominant language
Python
Stars
77.7k
Forks
44.8k
PR merge metrics
No merged PRs in 30d

Description

Prerequisites

Please answer the following question for yourself before submitting an issue.

  • I checked to make sure that this issue has not been filed already.

1. The entire URL of the documentation with the issue

https://github.com/tensorflow/models/blob/master/research/object_detection/anchor_generators/grid_anchor_generator.py#L140

2. Describe the issue

I believe the function comments for GridAnchorGenerator.tile_anchors() incorrectly state how many boxes will be generated by the function.

The function comment reads:

For example, setting scales=[.1, .2, .2] and aspect ratios = [2,2,1/2] 
means that we create three boxes: one with scale .1, aspect ratio 2, 
one with scale .2, aspect ratio 2, and one with scale .2 and aspect ratio 1/2.

However, if I set scales and aspect_ratios to the above values in my model configuration, nine boxes are generated not three.


To test this, I set the following values in my Faster R-CNN configuration:

first_stage_anchor_generator {
    grid_anchor_generator {
        height_stride: 8
        width_stride: 8
        scales: [0.1, 0.2, 0.2]
        aspect_ratios: [2.0, 2.0, 0.5]
    }
}

I then printed heights and widths on line 175 of grid_anchor_generator.py like so:

ratio_sqrts = tf.sqrt(aspect_ratios)
heights = scales / ratio_sqrts * base_anchor_size[0]
widths = scales * ratio_sqrts * base_anchor_size[1]
with tf.Session() as sess: print(heights.eval(), widths.eval()) 
sys.exit()

The values printed for heights and widths were [18.101933598375616, 36.20386719675123, 36.20386719675123, 18.101933598375616, 36.20386719675123, 36.20386719675123, 36.20386719675123, 72.40773439350247, 72.40773439350247] and [36.20386719675124, 72.40773439350248, 72.40773439350248, 36.20386719675124, 72.40773439350248, 72.40773439350248, 18.10193359837562, 36.20386719675124, 36.20386719675124], respectively.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.