you359/Keras-FasterRCNN

tensorflow.python.framework.errors_impl.InvalidArgumentError: slice index 31 of dimension 1 out of bounds.

DableUTeeF opened this issue · 4 comments

My environment is
Ubuntu 18.04
Tensorflow 1.14.0
Keras 2.2.4

I'm using simple parser with some edit from here #6

like this

        if C.num_rois > 1:
            if len(pos_samples) < C.num_rois // 2:
                selected_pos_samples = pos_samples.tolist()
            else:
                if len(pos_samples) > 0:
                    selected_pos_samples = np.random.choice(pos_samples, C.num_rois // 2, replace=False).tolist()
                else:
                    selected_pos_samples = []
            try:
                if len(neg_samples) > 0:
                    selected_neg_samples = np.random.choice(neg_samples, C.num_rois - len(selected_pos_samples),
                                                            replace=False).tolist()
                else:
                    selected_neg_samples = []
            except:
                if len(neg_samples) > 0:
                    selected_neg_samples = np.random.choice(neg_samples, C.num_rois - len(selected_pos_samples),
                                                            replace=True).tolist()
                else:
                    selected_neg_samples = []

            sel_samples = selected_pos_samples + selected_neg_samples
            if len(sel_samples) == 0:
                continue

and I delete all val and test set, use all_imgs as trian set right away.

The problem is, at a certain point in the first epoch(say 300th iteration), this error comes.

2019-10-19 16:43:33.168527: W tensorflow/core/framework/op_kernel.cc:1273] OP_REQUIRES failed at strided_slice_op.cc:106 : Invalid argument: slice index 21 of dimension 1 out of bounds.
2019-10-19 16:43:33.168539: W tensorflow/core/framework/op_kernel.cc:1273] OP_REQUIRES failed at strided_slice_op.cc:106 : Invalid argument: slice index 21 of dimension 1 out of bounds.
2019-10-19 16:43:33.168550: W tensorflow/core/framework/op_kernel.cc:1273] OP_REQUIRES failed at strided_slice_op.cc:106 : Invalid argument: slice index 22 of dimension 1 out of bounds.
Traceback (most recent call last):
  File "rcnn/train_frcnn.py", line 292, in <module>
    loss_class = model_classifier.train_on_batch([X, X2[:, sel_samples, :]], [Y1[:, sel_samples, :], Y2[:, sel_samples, :]])
  File "/home/palm/miniconda3/envs/main36/lib/python3.6/site-packages/keras/engine/training.py", line 1217, in train_on_batch
    outputs = self.train_function(ins)
  File "/home/palm/miniconda3/envs/main36/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 2715, in __call__
    return self._call(inputs)
  File "/home/palm/miniconda3/envs/main36/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 2675, in _call
    fetched = self._callable_fn(*array_vals)
  File "/home/palm/miniconda3/envs/main36/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1439, in __call__
    run_metadata_ptr)
  File "/home/palm/miniconda3/envs/main36/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 528, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: slice index 31 of dimension 1 out of bounds.
	 [[{{node roi_pooling_conv_1/strided_slice_157}} = StridedSlice[Index=DT_INT32, T=DT_FLOAT, begin_mask=0, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=7, _device="/job:localhost/replica:0/task:0/device:GPU:0"](_arg_input_2_0_1/_13699, roi_pooling_conv_1/strided_slice_157/stack, roi_pooling_conv_1/strided_slice_157/stack_1, loss_1/dense_regress_3_loss/strided_slice_2/stack_2)]]
	 [[{{node loss_1/dense_regress_3_loss/Mean_2/_14305}} = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_49135_loss_1/dense_regress_3_loss/Mean_2", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

What should I do about this?

I met the same problem, have you found a solution?

No I gave up and move to Pytorch instead

@DableUTeeF Do you have any good source faster rcnn implementation

@Mps24-7uk I use Detectron2, which is Pytorch.