tensorflow / models

Models and examples built with TensorFlow
Other
76.93k stars 45.8k forks source link

Adding explicit_padding to EfficientDet model #9602

Open qraleq opened 3 years ago

qraleq commented 3 years ago

Prerequisites

1. The entire URL of the file you are using

https://github.com/tensorflow/models/blob/master/research/object_detection/models/ssd_efficientnet_bifpn_feature_extractor.py

2. Describe the feature you request

Currently, in ssd_efficientnet_bifpn_feature_extractor.py

https://github.com/tensorflow/models/blob/83b2ad3bf9557ec684c80d5e1760887f847b6ab6/research/object_detection/models/ssd_efficientnet_bifpn_feature_extractor.py#L101-L102

it says that using the use_explicit_padding parameter is unsupported by EfficientNetBiFPN.

I would like to be able to use the explicit_padding option with the EfficientDet model. Not sure if this is a limitation of the EfficientDet model, or it just hasn't been implemented yet.

3. Additional context

In order to make the model invariant to the input image size, I usually use a combination of FlexibleAnchorGenerator and explicit_padding. I previously used this successfully in the TF1 models such as ssd_mobilenet_v2_fpn. Now I'm trying to achieve the same behavior using TF2 OD API and EfficientDet model, but I found that use_explicit_padding is not supported in the EfficientDet model.

I tried to implement this on my own, but when I add the padding layers to efficientnet_model.py similar to how it's already done in mobilenet_v2.py, I get errors when loading the weights from the ModelZoo checkpoint, and I'm not sure how to fix it. Additionally, the structure or the ssd_efficientnet_feature_extractor.py and bidirectional_feature_pyramid_generators.py is quite different from the corresponding files for ssd_mobilenet_v2_fpn, which makes it difficult to figure out where the padding has to be applied.

4. Are you willing to contribute it? (Yes or No)

Yes, but will need some guidance.

qraleq commented 3 years ago

@tombstone @pkulzc Can you please check this and provide some guidance, please?

matejcrnac commented 3 years ago

Has anyone managed to solve this issue?