tensorflow / models

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

following error while training the model using "model_main.py": AttributeError: 'WeightSharedConvolutionalBoxPredictor' object has no attribute 'inputs' #8913

Open BharathKR opened 4 years ago

BharathKR commented 4 years ago

Tensorflow version: 2.2.0 I started training the model using the below command

python model_main.py --pipeline_config_path=ssd_mobilenet_v1_fpn_640x640_coco17_tpu-8/pipeline.config --model_dir=training/ --num_train_steps=50000 --sample_1_of_n_eval_examples=1 --alsologtostderr

I get the below error Traceback (most recent call last): File "model_main.py", line 108, in tf.app.run() File "/home/jupyter/.local/lib/python3.7/site-packages/tensorflow/python/platform/app.py", line 40, in run _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef) File "/opt/conda/lib/python3.7/site-packages/absl/app.py", line 299, in run _run_main(main, args) File "/opt/conda/lib/python3.7/site-packages/absl/app.py", line 250, in _run_main sys.exit(main(argv)) File "model_main.py", line 104, in main tf.estimator.train_and_evaluate(estimator, train_spec, eval_specs[0]) File "/home/jupyter/.local/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/training.py", line 472, in train_and_evaluate return executor.run() File "/home/jupyter/.local/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/training.py", line 613, in run return self.run_local() File "/home/jupyter/.local/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/training.py", line 714, in run_local saving_listeners=saving_listeners) File "/home/jupyter/.local/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 349, in train loss = self._train_model(input_fn, hooks, saving_listeners) File "/home/jupyter/.local/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1182, in _train_model return self._train_model_default(input_fn, hooks, saving_listeners) File "/home/jupyter/.local/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1211, in _train_model_default self.config) File "/home/jupyter/.local/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1170, in _call_model_fn model_fn_results = self._model_fn(features=features, **kwargs) File "/home/jupyter/.local/lib/python3.7/site-packages/object_detection/model_lib.py", line 543, in model_fn update_ops=detection_model.updates(), File "/home/jupyter/.local/lib/python3.7/site-packages/object_detection/meta_architectures/ssd_meta_arch.py", line 1350, in updates self._box_predictor.inputs)) AttributeError: 'WeightSharedConvolutionalBoxPredictor' object has no attribute 'inputs'

ravikyram commented 4 years ago

@BharathKR

Request you to provide colab link or complete code snippet with supporting files to reproduce the issue in our environment.It helps us in localizing the issue faster.Thanks!

BharathKR commented 4 years ago

@ravikyram , thanks for the response, i'm currently working on GCP AI platform instance and there is no provision overthere to share my instance.
I followed the instructions in the below link to clone the git-repository and install the required dependencies https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2.md

followed by creating a train.record and test.record. Configured the pipeline.config fileof "ssd_mobilenet_v1_fpn_640x640_coco17_tpu-8" . I attached the edited config file. I then initiated the training of the model by

python model_main.py --pipeline_config_path=ssd_mobilenet_v1_fpn_640x640_coco17_tpu-8/pipeline.config --model_dir=training/ --num_train_steps=50000 --sample_1_of_n_eval_examples=1 --alsologtostderr

and after which the mentioned error showed up. I followed the instructions in this video where needed. https://www.youtube.com/watch?v=JR8CmWyh2E8

I'm unable to add all the support files as there is a file limit of 10mb here Thanks

pipeline.zip

jch1 commented 4 years ago

Hi @BharathKR - did you mean to train using model_main_tf2.py instead of model_main.py?

BharathKR commented 4 years ago

@jch1 Hi, no, I trained the model using model_main.py and I got the said error.

On a separate topic, I tried training using model_main_tf2.py and it threw me a different error

gowrishankarin commented 4 years ago

Hi, Facing the same problem with a custom dataset.

khany27 commented 4 years ago

Hello, I am facing the same problem when I start training with model_main.py.

AttributeError: 'WeightSharedConvolutionalBoxPredictor' object has no attribute 'inputs'

Also, I have tried the model_main_tf2.py and it gives the error as


W0723 11:53:29.138377 140432587712320 util.py:144] Unresolved object in checkpoint: (root).model._feature_extractor._bifpn_stage.node_input_blocks.7.0.1.1.moving_variance```
BharathKR commented 4 years ago

@tombstone @jch1 @pkulzc Hi guys, any update?

ademkesim commented 4 years ago

@khany27 hi, did you solve the problem?

vascobarbosa commented 4 years ago

Hello, I am facing the same problem when I start training with model_main.py.

AttributeError: 'WeightSharedConvolutionalBoxPredictor' object has no attribute 'inputs'

Also, I have tried the model_main_tf2.py and it gives the error as

W0723 11:53:29.138377 140432587712320 util.py:144] Unresolved object in checkpoint: (root).model._feature_extractor._bifpn_stage.node_input_blocks.7.0.1.1.moving_variance```

exactly the same issue here mac osx / tensorflow 2.3.0 / python 3.7

Thar0l commented 4 years ago

Hi! I have the same issue with ssd_mobilenet_v2_keras model with standart convolutional_box_predictor while trying to train on classic COCO dataset.

Ubuntu 20.04 / Python 3.8.2 / Tensorflow 2.3.0

Traceback (most recent call last): File "object_detection/model_main.py", line 108, in <module> tf.app.run() File "/home/thar0l/.local/lib/python3.8/site-packages/tensorflow/python/platform/app.py", line 40, in run _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef) File "/home/thar0l/.local/lib/python3.8/site-packages/absl/app.py", line 299, in run _run_main(main, args) File "/home/thar0l/.local/lib/python3.8/site-packages/absl/app.py", line 250, in _run_main sys.exit(main(argv)) File "object_detection/model_main.py", line 104, in main tf.estimator.train_and_evaluate(estimator, train_spec, eval_specs[0]) File "/home/thar0l/.local/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/training.py", line 505, in train_and_evaluate return executor.run() File "/home/thar0l/.local/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/training.py", line 646, in run return self.run_local() File "/home/thar0l/.local/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/training.py", line 743, in run_local self._estimator.train( File "/home/thar0l/.local/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 349, in train loss = self._train_model(input_fn, hooks, saving_listeners) File "/home/thar0l/.local/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1175, in _train_model return self._train_model_default(input_fn, hooks, saving_listeners) File "/home/thar0l/.local/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1203, in _train_model_default estimator_spec = self._call_model_fn(features, labels, ModeKeys.TRAIN, File "/home/thar0l/.local/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1163, in _call_model_fn model_fn_results = self._model_fn(features=features, **kwargs) File "/home/thar0l/Sources/models/research/object_detection/model_lib.py", line 556, in model_fn update_ops=detection_model.updates(), File "/home/thar0l/Sources/models/research/object_detection/meta_architectures/ssd_meta_arch.py", line 1350, in updates self._box_predictor.inputs)) AttributeError: 'ConvolutionalBoxPredictor' object has no attribute 'inputs'

pipeline.config.txt

Thar0l commented 4 years ago

PS: With model_main_tf2.py instead of model_main.py training starts normally.

codeperfectplus commented 3 years ago

model_main.py is for the TensorFlow version1 and model_main_tf2.py is for TensorFlow version 2. Please check the env and tensorflow version.

Jeanbouvatt commented 3 years ago

I had the same problem and solved it by downgrading tensorflow from 2.3 to 1.15

markgicharu commented 3 years ago

I added a basic data augmentation option and the error vanishes