CharlesShang / FastMaskRCNN

Mask RCNN in TensorFlow
Apache License 2.0
3.1k stars 1.1k forks source link

when i run unit_test/data_test.py, it shows an error: TypeError: Can not convert a bool into a Tensor or Operation #59

Closed tjussh closed 7 years ago

tjussh commented 7 years ago

File "/home/JKe/sunshihua/FastMaskRCNN-master/unit_test/data_test.py", line 64, in feat = ROIAlign(image, boxes, False, 16, 7, 7) File "/home/JKe/sunshihua/FastMaskRCNN-master/libs/layers/crop.py", line 59, in crop with tf.control_dependencies([assert_op, images, batch_inds]): File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 3776, in control_dependencies return get_default_graph().control_dependencies(control_inputs) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 3505, in control_dependencies c = self.as_graph_element(c) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2578, in as_graph_element return self._as_graph_element_locked(obj, allow_tensor, allow_operation) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2667, in _as_graph_element_locked % (type(obj).name, types_str)) TypeError: Can not convert a bool into a Tensor or Operation.

gopi77 commented 7 years ago

I am also facing the issue, anyone solved it? I did one change at data_test.py L.No 30, at coco.read() Replaced /data/coco/records/coco_trainval2014_00000-of-00048.tfrecord with /data/coco/records/coco_train2014_00000-of-00033.tfrecord (because this is what generated when i did previous steps)


gopi@gp:/media/gopi/external_2tb/FastMaskRCNN$ python ./unit_test/data_test.py I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:910] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties: name: GeForce GTX 1070 major: 6 minor: 1 memoryClockRate (GHz) 1.835 pciBusID 0000:01:00.0 Total memory: 7.92GiB Free memory: 7.51GiB I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0 I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0: Y I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0) Traceback (most recent call last): File "./unit_test/data_test.py", line 48, in feat = ROIAlign(image, boxes, False, 16, 7, 7) File "./unit_test/../libs/layers/crop.py", line 42, in crop with tf.control_dependencies([assert_op, images, batch_inds]): File "/home/gopi/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3583, in control_dependencies return get_default_graph().control_dependencies(control_inputs) File "/home/gopi/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3314, in control_dependencies c = self.as_graph_element(c) File "/home/gopi/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2405, in as_graph_element return self._as_graph_element_locked(obj, allow_tensor, allow_operation) File "/home/gopi/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2494, in _as_graph_element_locked % (type(obj).name, types_str)) TypeError: Can not convert a bool into a Tensor or Operation.

gopi77 commented 7 years ago

Enabled the below code & it runs fine L.No 34 to 38 of /FastMaskRCNN/libs/layers/crop.py

if batch_inds is False:
  num_boxes = tf.shape(boxes)[0]
  batch_inds = tf.zeros([num_boxes], dtype=tf.int32, name='batch_inds')
  batch_inds = boxes[:, 0] * 0
  batch_inds = tf.cast(batch_inds, tf.int32)