sgrvinod / a-PyTorch-Tutorial-to-Object-Detection

SSD: Single Shot MultiBox Detector | a PyTorch Tutorial to Object Detection
MIT License
3.01k stars 715 forks source link

Wrong scale values #48

Open neeveermoree opened 4 years ago

neeveermoree commented 4 years ago

These are the values used in

obj_scales = {'conv4_3': 0.1,
                      'conv7': 0.2,
                      'conv8_2': 0.375,
                      'conv9_2': 0.55,
                      'conv10_2': 0.725,
                      'conv11_2': 0.9}

In paper this values are used: image Proper values are: 0.2 , 0.34, 0.48, 0.62, 0.76, 0.9 Code to check:

m = 6
k = np.arange(1, m+1, 1)
scales = 0.2 + (0.9 - 0.2) / (m - 1) * (k - 1)
jjjkkkjjj commented 4 years ago

I have same question. But many SSD's implementation use s_1 = 0.1.

e.g.) ssd.pytorch

...

s_k = self.min_sizes[k]/self.image_size

...

min_size = [30, 60, 11, 262, 213, 264]. So, s_1 =30/300=0.1.

Where s_k=0.1 is from?? I can't find one in original paper...

jjjkkkjjj commented 4 years ago

Author says "An alternative way of improving SSD is to design a better tiling of default boxes so that its position and scale are better aligned with the receptive field of each position on a feature map. We leave this for future work."

s_1=0.1 may be from feature work :(

EDIT: chainercv's issue comments helped me.

sgrvinod commented 4 years ago

Hello, it's been a while since I read the paper, so I don't remember my thought process regarding why I went ahead with a scale of 0,1 for conv4_3.

Looking at the paper now, in Section 3.1 (Page 7), it is stated the conv4_3 will use a scale of 0.1.

We set default box with scale 0.1 on conv4_3.

So does this mean s_minis now 0.1? Apparently not, because the paper treats conv4_3 as somewhat of a special case and considers s_min to be the scale of conv7 instead. And from conv7 onwards, they are regularly spaced up to s_max.

This is apparent in their wording throughout the paper. At the end of page 7:

For SSD512 model, we add extra conv12_2 for prediction, set s_min to 0.15, and 0.07 on conv4_3.

Here too, the scale for conv4_3 is set separately.

On page 11:

We follow the strategy mentioned in Sec. 2.2, but now our smallest default box has a scale of 0.15 instead of 0.2, and the scale of the default box on conv4_3 is 0.07 (e.g. 21 pixels for a 300 × 300 image)

For SSD512 model, we add extra conv12_2 for prediction, set s_min to 0.1, and 0.04 on conv4_3.

I don't remember if my understanding of this is as clear now as it was when I wrote the code, but this is all I can tell you now, off the top of my head. I'm sure I must have been confused at that time too, and I must've checked with other repositories to confirm. This paper is a little too empirical sometimes.

jjjkkkjjj commented 4 years ago

@sgrvinod

We set default box with scale 0.1 on conv4_3.

Oh, it's written!!! Thanks a lot! You saved a lot of my time!

phamkhactu commented 4 years ago

which relationship between anchors and min_size. Suppose I have 6 anchors box (w:h) (100,50)(125:75)(150:175), (175,180),(205,175),(235,153). How to calculate min_size, max_size. Thanks in advance if share the formular.