tensorflow / models

Models and examples built with TensorFlow
Other
77.24k stars 45.75k forks source link

pad_to_multiple_resizer not recognized #9502

Open SamLee514 opened 4 years ago

SamLee514 commented 4 years ago

Prerequisites

Please answer the following questions for yourself before submitting an issue.

1. The entire URL of the file you are using

https://github.com/tensorflow/models/tree/master/research/object_detection/utils/config_util.py

2. Describe the bug

When I try to train EfficientD2 with pad_to_multiple_resizer as the image resizer option, I get

ValueError: Unknown image resizer type.

This traces back to the file above where it looks like pad_to_multiple_resizer isn't even a recognized option, the only options being fixed_shape_resizer, keep_aspect_ratio_resizer, identity_resizer and conditional_shape_resizer. However, pad_to_multiple_resizer is a valid option from the image resizer proto file. Is this simply something I'm missing, or is the option supposed to be there?

3. Steps to reproduce

Use model_main_tf2.py to train an EfficientDet D2 model with the following configurations for ssd:

... num_classes: 5 image_resizer { pad_to_multiple_resizer { multiple: 256 } } ...

4. Expected behavior

Images are fed through and resized according to the description of pad_to_multiple_resizer.

5. Additional context

ValueError: in user code:

/home/sam/models/research/object_detection/inputs.py:985 transform_and_pad_input_data_fn  *                                                                           
    tensor_dict = pad_input_data_to_static_shapes(
/home/sam/models/research/object_detection/utils/config_util.py:85 get_spatial_image_size  *                                                                          
    raise ValueError("Unknown image resizer type.")

ValueError: Unknown image resizer type.

6. System information

aii-jayson commented 3 years ago

similar situation here. @SamLee514 did you get any workaround?

SamLee514 commented 3 years ago

@aii-jayson unfortunately not :(, just been working with other models in the meantime

dranaivo commented 3 years ago

I also have the same issue. What I found, however, is that you can build the model with the pad_to_multiple_resizer.

My (temporary) fix is to train using one of the available resizer, provided the pre-processed shape is close to what you expect during inference, then export the model with a config_override, overriding the image resizer with pad_to_multiple_resizer. Of course, this is not really a general fix.

NB: The specific line(s) where all options are indicated: https://github.com/tensorflow/models/blob/master/research/object_detection/utils/config_util.py#L58