mxnet-ssd icon indicating copy to clipboard operation
mxnet-ssd copied to clipboard

Compute anchors for custom dataset

Open qilicun opened this issue 6 years ago • 2 comments

Hi, Sorry for this question is very stupid, but I'm new to SSD. When I train SSD with own dataset, the result looks not that good, so I'm considering to change the anchor size due to this dataset. I check the symbol_factory.py, found this

image

My question is how to get this size vector? Any help is appreciated.

qilicun avatar Oct 31 '17 04:10 qilicun

  1. Pick the min scale and the max scale of default boxes with respect to the input size. In this case, from relu7 to the top layer, smin=0.15, smax=0.9.
  2. Compute each scale for the m = 6 layers. s(k) = smin + (smax - smin) / (m - 1) * (k-1), k \in [1, m]. Then we have [0.15, 0.3, 0.45, 0.6, 0.75, 0.9]. 3.Insert the smallest scale ahead for layer relu4_3: [0.07, 0.15, 0.3, 0.45, 0.6, 0.75, 0.9]
  3. Compute the scale for aspect ratio of 1 by s(k)' = sqrt(s(k) * s(k+1)). e.g. s(1)' = sqrt(s(1) * s(2)) = sqrt(0.07 * 0.15) = 0.1025. We have [0.1025, 0.2121, 0.3674, 0.5196, 0.6708, 0.8216, 0.9721]
  4. Zip the two lists from step 3 & 4, then we have the sizes vector.

For your own conditions, you may set the min scale and the max scale to fit the object scales. But the default anchor sizes is good enough for various object scales, and I think your accuracy problem may not be caused by it.

ghost avatar Oct 31 '17 06:10 ghost

@xioryu Thanks a lot! That was really useful!

and I think your accuracy problem may not be caused by it.

Probably you are right, so I was considering to add some layers for the vgg16_reduced model and extract features from those layers. Anyway, thanks for your help!

qilicun avatar Oct 31 '17 07:10 qilicun