zisianw / FaceBoxes.PyTorch

A PyTorch Implementation of FaceBoxes
MIT License
846 stars 213 forks source link

how to handle the number of anchor box? #55

Closed jjh930910 closed 5 years ago

jjh930910 commented 5 years ago

i am a beginner class of detection with deep learning so i don't know how to handle anchor box. i try to change filter numbers of loc_layers(21 to 11) in multibox in faceboxes.py but i have an error "Runtime error : the expanded size of the tensor (11584) must match the exisitng size(21824) at non singleton dimension1. Target sizes : [32 ,11584 ,4]. Tensor sizes : [32 ,21824 ,1]" i think 21824 is number of default(anchor) box and 11584 is number of prediction box so what should i do to decrease number of filters?

and i have one more qusetion

this paper has anchor densification module but i don't want to use this module fully, i want to use half of anchor densification to decrease my university project's latency so i have change prior_box.py 33th line

"dense_cx = [xself.steps[k]/self.image_size[1] for x in [j+0, j+0.25, j+0.5, j+0.75]] --> dense_cx = [xself.steps[k]/self.image_size[1] for x in [j+0, j+0.5]]"

but i have an similar error above problem so i need your advice

xsacha commented 5 years ago

It's probably easier to take out one of the Inception layers. This will give a ~16% speed up for very little accuracy drop off.

To remove an anchor, you must realise that the tensor size (21824) is the combination of the width height anchor size and that there is 3 dense and 2 normal anchors. If you look at the size of the boxes created you can work out what the new tensor size will be and adjust loc_layers accordingly.

jjh930910 commented 5 years ago

what is 3 dense and 2 normal anchors? as i know, 32 32 feature map have 4 dense anchor box and 64 64 feature map have 2 dense anchor box. 128 128,256 256,512 * 512 feature maps has normal anchor box. Is this wrong?

xsacha commented 5 years ago

Sorry, 3 normal anchors and 2 are dense. One is 4 and one is 2, yes.

The size depends on the input resolution.