varunagrawal / tiny-faces-pytorch

Finding Tiny Faces in PyTorch
MIT License
164 stars 44 forks source link

[Bug]: In models/utils:get_bbox: Dimension error #19

Closed Lotayou closed 9 months ago

Lotayou commented 4 years ago

Here's the original piece of code

https://github.com/varunagrawal/tiny-faces-pytorch/blob/dbe0ee57ddc41891b5228ec244946b84480d87bf/models/utils.py#L36

However the actual tensor is 4-dimensional of shape (1,h*s,w*s,25), which would lead to an out-of-bound error when the input image resolution is lower than a certain threshold (900 I presume): image

I guess this line should be written as

prob_cls[:, :, :, invalid_template_id] = 0.0
varunagrawal commented 9 months ago

Could it be that you are inputting a 4 dimensional tensor to the model? It seems pointless to have the shape of your input be (1, h*s, w*s, 25) when (h*s, w*s, 25) gives the same amount of information.

You could try doing input.squeeze() before passing it into the model.