tf-models: official.vision.detection Mask-RCNN Invalid argument: indices[1,63] = [1, -1] does not index into param shape [2,100,112,112]

独自空忆成欢 提交于 2020-05-15 04:15:07

问题


I am trying to train a Mask RCNN model based on the official MaskRCNN model present here: tensorflow/models.

Below are the steps I followed:

  1. Created a tfrecord for training and validation. I have checked encoding and decoding of the tfrecords, it is working fine.
  2. Set up the config file as below:
    # my_maskrcnn.yaml
    train:
        train_file_pattern: "data/<dataset_name>/train/tfrecords/train.tfrecord-*"
        batch_size: 2
    eval:
        eval_file_pattern: "data/<data_set_name>/val/tfrecords/val.tfrecord-*"
        batch_size: 2
    predict:
        batch_size: 2
    architecture:
        num_classes: 2
    maskrcnn_parser:
        output_size: [512, 512]
    
  3. Put the models/official to PYTHONPATH.
  4. Ran the command for a single GPU as suggested in the documentation:
    python path/to/models/official/vision/detection/main.py \
        --strategy_type=one_device \
        --model_dir=models_mask_rcnn \
        --mode=train \
        --config_file="mymaskrcnn.yaml" \
        --model=mask_rcnn
    

But I am getting the following error:

Traceback (most recent call last):
File ".../models/official/vision/detection/main.py", line 255, in <module>
    app.run(main)
File ".../lib/python3.7/site-packages/absl/app.py", line 299, in run
    _run_main(main, args)
File ".../lib/python3.7/site-packages/absl/app.py", line 250, in _run_main
    sys.exit(main(argv))
File ".../models/official/vision/detection/main.py", line 250, in main
    run()
File ".../models/official/vision/detection/main.py", line 244, in run
    callbacks=callbacks)
File ".../models/official/vision/detection/main.py", line 130, in run_executor
    save_config=True)
File ".../models/official/modeling/training/distributed_executor.py", line 482, in train
    tf.convert_to_tensor(num_steps, dtype=tf.int32))
File ".../lib/python3.7/site-packages/tensorflow/python/eager/def_function.py", line 688, in __call__
    result = self._call(*args, **kwds)
File ".../lib/python3.7/site-packages/tensorflow/python/eager/def_function.py", line 741, in _call
    return self._stateless_fn(*args, **kwds)
File ".../lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 2407, in __call__
    return graph_function._filtered_call(args, kwargs)  # pylint: disable=protected-access
File ".../lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 1655, in _filtered_call
    self.captured_inputs)
File ".../lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 1732, in _call_flat
    ctx, args, cancellation_manager=cancellation_manager))
File ".../lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 598, in call
    ctx=ctx)
File ".../lib/python3.7/site-packages/tensorflow/python/eager/execute.py", line 60, in quick_execute
    inputs, attrs, num_outputs)
tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
(0) Invalid argument:  indices[1,63] = [1, -1] does not index into param shape [2,100,112,112]
        [[{{node while/body/_241/while/maskrcnn/tf_op_layer_sample_and_crop_foreground_masks/GatherNd_4/sample_and_crop_foreground_masks/GatherNd_4}}]]
(1) Invalid argument:  indices[1,63] = [1, -1] does not index into param shape [2,100,112,112]
        [[{{node while/body/_241/while/maskrcnn/tf_op_layer_sample_and_crop_foreground_masks/GatherNd_4/sample_and_crop_foreground_masks/GatherNd_4}}]]
        [[while/body/_241/while/AddN_40/_3885]]
0 successful operations.
1 derived errors ignored. [Op:__inference_train_step_89096]

Function call stack:
train_step -> train_step

Where am I going wrong?

来源:https://stackoverflow.com/questions/61280885/tf-models-official-vision-detection-mask-rcnn-invalid-argument-indices1-63

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!