yizt / keras-faster-rcnn

keras实现faster rcnn,end2end训练、预测; 持续更新中,见todo... ;欢迎试用、关注并反馈问题
86 stars 36 forks source link

evaluate error #16

Open NiFangBaAGe opened 5 years ago

NiFangBaAGe commented 5 years ago

Hello, I occured an error when I use evaluate.py. Could you please help me?

Traceback (most recent call last): File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1322, in _do_call return fn(*args) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1307, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1409, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError: Reduction axis -1 is empty in shape [300,0] [[Node: proposals2detectboxes/map_1/while/ArgMax = ArgMax[T=DT_FLOAT, Tidx=DT_INT32, output_type=DT_INT64, _device="/job:localhost/replica:0/task:0/device:GPU:0"](proposals2detectboxes/map_1/while/strided_slice_1, proposals2detectboxes/map_1/while/Max/reduction_indices)]] [[Node: proposals2detectboxes/map_1/while/map/while/Identity/_2503 = _Recvclient_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_3210_proposals2detectboxes/map_1/while/map/while/Identity", tensor_type=DT_INT32, _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "evaluate.py", line 87, in main(argments) File "evaluate.py", line 61, in main use_multiprocessing=True) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper return func(*args, kwargs) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/keras/engine/training.py", line 2540, in predict_generator outs = self.predict_on_batch(x) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/keras/engine/training.py", line 1945, in predict_on_batch outputs = self.predict_function(ins) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 2482, in call self.session_kwargs) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 900, in run run_metadata_ptr) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1135, in _run feed_dict_tensor, options, run_metadata) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1316, in _do_run run_metadata) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1335, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: Reduction axis -1 is empty in shape [300,0] [[Node: proposals2detectboxes/map_1/while/ArgMax = ArgMax[T=DT_FLOAT, Tidx=DT_INT32, output_type=DT_INT64, _device="/job:localhost/replica:0/task:0/device:GPU:0"](proposals2detectboxes/map_1/while/strided_slice_1, proposals2detectboxes/map_1/while/Max/reduction_indices)]] [[Node: proposals2detectboxes/map_1/while/map/while/Identity/_2503 = _Recvclient_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_3210_proposals2detectboxes/map_1/while/map/while/Identity", tensor_type=DT_INT32, _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

Caused by op 'proposals2detectboxes/map_1/while/ArgMax', defined at: File "evaluate.py", line 87, in main(argments) File "evaluate.py", line 50, in main m = models.frcnn(config, stage='test') File "/home/sudong/hitsz/keras-faster-rcnn/faster_rcnn/layers/models.py", line 180, in frcnn [rcnn_deltas, rcnn_class_logits, proposal_boxes]) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/keras/engine/topology.py", line 619, in call output = self.call(inputs, kwargs) File "/home/sudong/hitsz/keras-faster-rcnn/faster_rcnn/layers/detect_boxes.py", line 127, in call dtype=[tf.float32] 2 + [tf.int64] + [tf.float32]) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/functional_ops.py", line 423, in map_fn swap_memory=swap_memory) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 3224, in while_loop result = loop_context.BuildLoop(cond, body, loop_vars, shape_invariants) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2956, in BuildLoop pred, body, original_loop_vars, loop_vars, shape_invariants) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2893, in _BuildLoop body_result = body(packed_vars_for_body) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/functional_ops.py", line 413, in compute packed_fn_values = fn(packed_values) File "/home/sudong/hitsz/keras-faster-rcnn/faster_rcnn/layers/detect_boxes.py", line 125, in outputs = tf.map_fn(lambda x: detect_boxes(*x, *options), File "/home/sudong/hitsz/keras-faster-rcnn/faster_rcnn/layers/detect_boxes.py", line 28, in detect_boxes class_ids = tf.argmax(class_logits[:, 1:], axis=-1) + 1 # [num_boxes] File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 432, in new_func return func(args, kwargs) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 220, in argmax return gen_math_ops.arg_max(input, axis, name=name, output_type=output_type) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 783, in arg_max name=name) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3392, in create_op op_def=op_def) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1718, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Reduction axis -1 is empty in shape [300,0] [[Node: proposals2detectboxes/map_1/while/ArgMax = ArgMax[T=DT_FLOAT, Tidx=DT_INT32, output_type=DT_INT64, _device="/job:localhost/replica:0/task:0/device:GPU:0"](proposals2detectboxes/map_1/while/strided_slice_1, proposals2detectboxes/map_1/while/Max/reduction_indices)]] [[Node: proposals2detectboxes/map_1/while/map/while/Identity/_2503 = _Recvclient_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_3210_proposals2detectboxes/map_1/while/map/while/Identity", tensor_type=DT_INT32, _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

yizt commented 5 years ago

@NiFangBaAGe 您好,推测您将NUM_CLASSES 设置为 1了,请设置为实际类别数,如VOC(20+1)

File "/home/sudong/hitsz/keras-faster-rcnn/faster_rcnn/layers/detect_boxes.py", line 28, in detect_boxes
class_ids = tf.argmax(class_logits[:, 1:], axis=-1) + 1 # [num_boxes]
InvalidArgumentError (see above for traceback): Reduction axis -1 is empty in shape [300,0]
NiFangBaAGe commented 5 years ago

@NiFangBaAGe 您好,推测您将NUM_CLASSES 设置为 1了,请设置为实际类别数,如VOC(20+1)

File "/home/sudong/hitsz/keras-faster-rcnn/faster_rcnn/layers/detect_boxes.py", line 28, in detect_boxes
class_ids = tf.argmax(class_logits[:, 1:], axis=-1) + 1 # [num_boxes]
InvalidArgumentError (see above for traceback): Reduction axis -1 is empty in shape [300,0]

Thank you, it works.

NiFangBaAGe commented 5 years ago

It seems that I meet another error when I use inference.py. Traceback (most recent call last): File "inference.py", line 93, in main(argments) File "inference.py", line 56, in main m = models.frcnn(config, stage='test') File "/home/sudong/hitsz/keras-faster-rcnn/faster_rcnn/layers/models.py", line 180, in frcnn [rcnn_deltas, rcnn_class_logits, proposal_boxes]) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/keras/engine/topology.py", line 619, in call output = self.call(inputs, *kwargs) File "/home/sudong/hitsz/keras-faster-rcnn/faster_rcnn/layers/detect_boxes.py", line 125, in call dtype=[tf.float32] 2 + [tf.int64] + [tf.float32]) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/functional_ops.py", line 423, in map_fn swap_memory=swap_memory) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 3224, in while_loop result = loop_context.BuildLoop(cond, body, loop_vars, shape_invariants) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2956, in BuildLoop pred, body, original_loop_vars, loop_vars, shape_invariants) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2893, in _BuildLoop body_result = body(packed_vars_for_body) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/functional_ops.py", line 413, in compute packed_fn_values = fn(packed_values) File "/home/sudong/hitsz/keras-faster-rcnn/faster_rcnn/layers/detect_boxes.py", line 123, in outputs = tf.map_fn(lambda x: detect_boxes(x, *options), File "/home/sudong/hitsz/keras-faster-rcnn/faster_rcnn/layers/detect_boxes.py", line 55, in detect_boxes nms_keep = tf.map_fn(fn=per_class_nms, elems=unique_class_ids) # (s,max_output_size,1) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/functional_ops.py", line 423, in map_fn swap_memory=swap_memory) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 3224, in while_loop result = loop_context.BuildLoop(cond, body, loop_vars, shape_invariants) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2956, in BuildLoop pred, body, original_loop_vars, loop_vars, shape_invariants) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2893, in _BuildLoop body_result = body(packed_vars_for_body) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/functional_ops.py", line 413, in compute packed_fn_values = fn(packed_values) File "/home/sudong/hitsz/keras-faster-rcnn/faster_rcnn/layers/detect_boxes.py", line 47, in per_class_nms score_threshold) # 一维索引 File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/image_ops_impl.py", line 1787, in non_max_suppression with ops.name_scope(name, 'non_max_suppression'): File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 5982, in enter return self._name_scope.enter() File "/home/sudong/anaconda3/envs/py36/lib/python3.6/contextlib.py", line 81, in enter return next(self.gen) File "/home/sudong/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 4099, in name_scope if not _VALID_SCOPE_NAME_REGEX.match(name): TypeError: expected string or bytes-like object

Only when I add 'config.DETECTION_MIN_CONFIDENCE = 0.0' it works. Could you help me?