tensorflow / models

Models and examples built with TensorFlow
Other
76.94k stars 45.79k forks source link

Error running object_detection/builders/model_builder_tf2_test.py file #9496

Open S130111 opened 3 years ago

S130111 commented 3 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/official/...

2. Describe the bug

[ OK ] ModelBuilderTF2Test.test_unknown_faster_rcnn_feature_extractor [ RUN ] ModelBuilderTF2Test.test_unknown_meta_architecture INFO:tensorflow:time(main.ModelBuilderTF2Test.test_unknown_meta_architecture): 0.0s I1123 15:23:23.062027 140676018898688 test_util.py:1973] time(main.ModelBuilderTF2Test.test_unknown_meta_architecture): 0.0s [ OK ] ModelBuilderTF2Test.test_unknown_meta_architecture [ RUN ] ModelBuilderTF2Test.test_unknown_ssd_feature_extractor INFO:tensorflow:time(main.ModelBuilderTF2Test.test_unknown_ssd_feature_extractor): 0.0s I1123 15:23:23.063109 140676018898688 test_util.py:1973] time(main.ModelBuilderTF2Test.test_unknown_ssd_feature_extractor): 0.0s [ OK ] ModelBuilderTF2Test.test_unknown_ssd_feature_extractor

ERROR: test_create_center_net_model (main.ModelBuilderTF2Test) ModelBuilderTF2Test.test_create_center_net_model Test building a CenterNet model from proto txt.

Traceback (most recent call last): File "object_detection/builders/model_builder_tf2_test.py", line 224, in test_create_center_net_model model = model_builder.build(config, is_training=True) File "/home/pjy/models-master/research/object_detection/builders/model_builder.py", line 1090, in build add_summaries) File "/home/pjy/models-master/research/object_detection/builders/model_builder.py", line 976, in _build_center_net_model center_net_config.feature_extractor) File "/home/pjy/models-master/research/object_detection/builders/model_builder.py", line 1054, in _build_center_net_feature_extractor bgr_ordering=feature_extractor_config.bgr_ordering File "/home/pjy/models-master/research/object_detection/models/center_net_resnet_feature_extractor.py", line 148, in resnet_v2_101 bgr_ordering=bgr_ordering File "/home/pjy/models-master/research/object_detection/models/center_net_resnet_feature_extractor.py", line 74, in init resnet_output = tf.keras.layers.BatchNormalization()(resnet_output) File "/home/pjy/python3.6/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 926, in call input_list) File "/home/pjy/python3.6/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1098, in _functional_construction_call self._maybe_build(inputs) File "/home/pjy/python3.6/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 2643, in _maybe_build self.build(input_shapes) # pylint:disable=not-callable File "/home/pjy/python3.6/lib/python3.6/site-packages/tensorflow/python/keras/layers/normalization.py", line 350, in build input_shape) ValueError: ('Input has undefined axis dimension. Input shape: ', TensorShape([None, 256, None, None]))


Ran 20 tests in 32.850s

FAILED (errors=1, skipped=1)

3. Steps to reproduce

Test run python3 object_detection/builders/model_builder_tf2_test.py error

4. Expected behavior

I install the api according to the steps, but every time I make an error in this test link, the error problem is this one

5. Additional context

Include any logs that would be helpful to diagnose the problem.

6. System information

saikumarchalla commented 3 years ago

@S130111 Have you installed OD API using this link? Can you confirm it?.

I tried to install TF OD API and it was installed properly on colab. Please find the gist here.

Could you please try to install again as per the documentation provided above and let us know if you are facing the issue still. Thanks!

S130111 commented 3 years ago

@ S130111您是否使用此链接安装了OD API ?您能确认吗?

我尝试安装TF OD API,并且已在colab上正确安装。请在这里找到要点。

您能否根据上面提供的文档尝试再次安装,并让我们知道您是否仍然遇到此问题。谢谢!

@saikumarchalla Yes, I installed the OD API according to the link process you sent. I tried this many times. I also changed the tensorflow version many times. I never knew what went wrong. The only difference I didn’t use conda. I I am using ubuntu16.04 system, I will try to install again

saikumarchalla commented 3 years ago

Similar issue: #9412

S130111 commented 3 years ago

类似的问题:#9412

@saikumarchalla Hello, this problem is ignored now, I now try to train the model normally, my training command is python3 model_main_tf2.py --model_dir=models/faster_rcnn_resnet50_v1_fpn --pipeline_config_path=models/faster_rcnn_resnet50_v1_fpn/pipeline.config, but it will give the following error Traceback (most recent call last): File "model_main_tf2.py", line 113, in tf.compat.v1.app.run() File "/home/pjy/python3.6/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 40, in run _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef) File "/home/pjy/python3.6/lib/python3.6/site-packages/absl/app.py", line 303, in run _run_main(main, args) File "/home/pjy/python3.6/lib/python3.6/site-packages/absl/app.py", line 251, in _run_main sys.exit(main(argv)) File "model_main_tf2.py", line 110, in main record_summaries=FLAGS.record_summaries) File "/home/pjy/python3.6/lib/python3.6/site-packages/object_detection/model_lib_v2.py", line 562, in train_loop unpad_groundtruth_tensors) File "/home/pjy/python3.6/lib/python3.6/site-packages/object_detection/model_lib_v2.py", line 339, in load_fine_tune_checkpoint raise IOError('Checkpoint is expected to be an object-based checkpoint.') OSError: Checkpoint is expected to be an object-based checkpoint. My configuration file istrain_config: { batch_size: 8 sync_replicas: true startup_delay_steps: 0 replicas_to_aggregate: 8 num_steps: 25000 optimizer { momentum_optimizer: { learning_rate: { cosine_decay_learning_rate { learning_rate_base: .04 total_steps: 25000 warmup_learning_rate: .013333 warmup_steps: 2000 } } momentum_optimizer_value: 0.9 } use_moving_average: false } fine_tune_checkpoint_version: V2 fine_tune_checkpoint: "/home/pjy/Detect/workspace/pre-trained-models/faster_rcnn_resnet50_v1_640x640_coco17_tpu-8/checkpoint/ckpt-0.index" fine_tune_checkpoint_type: "detection" data_augmentation_options { random_horizontal_flip { } }

max_number_of_boxes: 100 unpad_groundtruth_tensors: false use_bfloat16: true # works only on TPUs }

train_input_reader: { label_map_path: "/home/pjy/Detect/workspace/annotations/label_map.pbtxt" tf_record_input_reader { input_path: "/home/pjy/Detect/workspace/annotations/train.record" } }

eval_config: { metrics_set: "coco_detection_metrics" use_moving_averages: false batch_size: 1; }

eval_input_reader: { label_map_path: "/home/pjy/Detect/workspace/annotations/label_map.pbtxt" shuffle: false num_epochs: 1 tf_record_input_reader { input_path: "/home/pjy/Detect/workspace/annotations/test.record" } } What went wrong, thank you very much

S130111 commented 3 years ago

Can someone help me? I also got the same error when training the model, the error is as follows: Simply pass a True/False value to the training argument of the __call__ method of your layer or model. INFO:tensorflow:Error reported to Coordinator: in user code:

/home/pjy/python3.6/lib/python3.6/site-packages/object_detection/model_lib_v2.py:356 _dummy_computation_fn  *
    labels)
/home/pjy/python3.6/lib/python3.6/site-packages/object_detection/model_lib_v2.py:113 _compute_losses_and_predictions_dicts  *
    prediction_dict = model.predict(
/home/pjy/python3.6/lib/python3.6/site-packages/object_detection/meta_architectures/ssd_meta_arch.py:570 predict  *
    feature_maps = self._feature_extractor(preprocessed_inputs)
/home/pjy/python3.6/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py:982 __call__  **
    self._maybe_build(inputs)
/home/pjy/python3.6/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py:2643 _maybe_build
    self.build(input_shapes)  # pylint:disable=not-callable
/home/pjy/python3.6/lib/python3.6/site-packages/object_detection/models/ssd_resnet_v1_fpn_keras_feature_extractor.py:145 build
    include_top=False)
/home/pjy/python3.6/lib/python3.6/site-packages/object_detection/models/keras_models/resnet_v1.py:303 resnet_v1_50
    layers=layers_override, **kwargs)
/home/pjy/python3.6/lib/python3.6/site-packages/tensorflow/python/keras/applications/resnet.py:475 ResNet50
    input_tensor, input_shape, pooling, classes, **kwargs)
/home/pjy/python3.6/lib/python3.6/site-packages/tensorflow/python/keras/applications/resnet.py:175 ResNet
    axis=bn_axis, epsilon=1.001e-5, name='conv1_bn')(x)
/home/pjy/python3.6/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py:926 __call__
    input_list)
/home/pjy/python3.6/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py:1098 _functional_construction_call
    self._maybe_build(inputs)
/home/pjy/python3.6/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py:2643 _maybe_build
    self.build(input_shapes)  # pylint:disable=not-callable
/home/pjy/python3.6/lib/python3.6/site-packages/tensorflow/python/keras/layers/normalization.py:350 build
    input_shape)

ValueError: ('Input has undefined `axis` dimension. Input shape: ', TensorShape([None, 64, None, None]))

Traceback (most recent call last): File "/home/pjy/python3.6/lib/python3.6/site-packages/tensorflow/python/training/coordinator.py", line 297, in stop_on_exception yield File "/home/pjy/python3.6/lib/python3.6/site-packages/tensorflow/python/distribute/mirrored_run.py", line 323, in run self.main_result = self.main_fn(*self.main_args, **self.main_kwargs) File "/home/pjy/python3.6/lib/python3.6/site-packages/tensorflow/python/autograph/impl/api.py", line 258, in wrapper raise e.ag_error_metadata.to_exception(e) ValueError: in user code: Help me, thank you kind people!!

S130111 commented 3 years ago

@saikumarchalla