lukemelas / EfficientNet-PyTorch

A PyTorch implementation of EfficientNet
Apache License 2.0
7.82k stars 1.52k forks source link

Resnet 50/101+BiFPN integration #130

Open abhigoku10 opened 4 years ago

abhigoku10 commented 4 years ago

@lukemelas i am trying to replace Resnet50+FPN with Resent50/101+BiFPN and i am getting this error "RuntimeError: the size of tensor a (9) must match the size of tensor b (10) at non-singleton dimension 3 " any idea to resolve this?? cannot we integrate BiFPN with any other architectures

lukemelas commented 4 years ago

Have you resolved this?

Cyril9227 commented 4 years ago

I got pretty much the same error as you, it comes from the fact that in your FPN head you are trying to add 2 tensors of different shapes, this is because your inputs dimension are not a power of two, i.e your strides are not log2-contiguous (2, 4, 8... for instance).

This should however work for an input size of let's say (batch_size, channels, 1024, 1024).

The weird part is that this error disappears when I'm using it within Detectron2 API, I guess they must have some boilerplate code to do some padding.

Not sure how to fix it in the first place, if anyone has any idea...

Cyril9227 commented 4 years ago

Ok, so it turns out that Detectron2 automatically pads the image if the dimensions are not divisible by 2 enough time, you might want to take a look at https://github.com/facebookresearch/detectron2/issues/852