CasiaFan / SSD_EfficientNet

SSD using TensorFlow object detection API with EfficientNet backbone
63 stars 10 forks source link

Occur dimensions mismatch when I used "ssd_efficientnet_fpn" #3

Open wulungching opened 5 years ago

wulungching commented 5 years ago

Hello, did I have something setting wrong? It seems there are feature maps size mismatch. However, it would not occur when I set feature_extractor type to "ssd_efficientnet"

File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "object_detection/model_main.py", line 105, in main tf.estimator.train_and_evaluate(estimator, train_spec, eval_specs[0]) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/training.py", line 471, in train_and_evaluate return executor.run() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/training.py", line 610, in run return self.run_local() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/training.py", line 711, in run_local saving_listeners=saving_listeners) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 354, in train loss = self._train_model(input_fn, hooks, saving_listeners) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 1207, in _train_model return self._train_model_default(input_fn, hooks, saving_listeners) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 1237, in _train_model_default features, labels, model_fn_lib.ModeKeys.TRAIN, self.config) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 1195, in _call_model_fn model_fn_results = self._model_fn(features=features, **kwargs) File "/home/wlching/github/tensorflow_models/research/object_detection/model_lib.py", line 302, in model_fn features[fields.InputDataFields.true_image_shape]) File "/home/wlching/github/tensorflow_models/research/object_detection/meta_architectures/ssd_meta_arch.py", line 560, in predict feature_maps = self._feature_extractor(preprocessed_inputs) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/keras/engine/base_layer.py", line 757, in __call__ outputs = self.call(inputs, *args, **kwargs) File "/home/wlching/github/tensorflow_models/research/object_detection/meta_architectures/ssd_meta_arch.py", line 237, in call return self._extract_features(inputs) File "/home/wlching/github/tensorflow_models/research/object_detection/models/efficientnet_feature_extractor.py", line 167, in _extract_features fpn_features = self._feature_map_generator(fpn_input_image_features) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/keras/engine/base_layer.py", line 757, in __call__ outputs = self.call(inputs, *args, **kwargs) File "/home/wlching/github/tensorflow_models/research/object_detection/models/feature_map_generators.py", line 641, in call top_down += residual File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/math_ops.py", line 866, in binary_op_wrapper return func(x, y, name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_math_ops.py", line 301, in add "Add", x=x, y=y, name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/util/deprecation.py", line 488, in new_func return func(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 3274, in create_op op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1792, in __init__ control_input_ops) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1631, in _create_c_op raise ValueError(str(e)) ValueError: Dimensions must be equal, but are 20 and 19 for 'FeatureMaps/top_down/add' (op: 'Add') with input shapes: [16,20,20,256], [16,19,19,256]. In addition, these two line without "=" ? https://github.com/CasiaFan/SSD_EfficientNet/blob/72543717fff4928acbf16f4a35fb9b8e75f505e9/efficientnet_feature_extractor.py#L100 https://github.com/CasiaFan/SSD_EfficientNet/blob/72543717fff4928acbf16f4a35fb9b8e75f505e9/efficientnet_feature_extractor.py#L261

CasiaFan commented 5 years ago

@wulungching I doubt this error should be caused by input size and padding setting in conv computation. Could you show me your input size setting or config file? Besides, Thanks for reporting the typo.

CasiaFan commented 5 years ago

@wulungching This error is caused due to mismatch of dimension of addition operation in fpn top town section for some input size. Add use_explicit_padding: true in config feature_extractor could prevent it. See ssd_efficientnet_fpn.config for reference.