matterport / Mask_RCNN

Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow
Other
24.73k stars 11.71k forks source link

TypeError: unsupported operand type(s) for /: 'Tensor' and 'float' #165

Open 76176235 opened 6 years ago

76176235 commented 6 years ago

Hi,i am a new to tf and keras.I run Mask_RCNN-2.0 .when i debug the project,i meet a problem.But i dont understand it likeing this: Traceback (most recent call last): File "/home/whao/pycharm-2017.1.2/helpers/pydev/pydevd.py", line 1585, in globals = debugger.run(setup['file'], None, None, is_module) File "/home/whao/pycharm-2017.1.2/helpers/pydev/pydevd.py", line 1015, in run pydev_imports.execfile(file, globals, locals) # execute the script File "/home/whao/pycharm-2017.1.2/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/home/whao/Mask_RCNN-2.0/coco.py", line 382, in model_dir=args.logs) File "/home/whao/Mask_RCNN-2.0/model.py", line 1735, in init self.keras_model = self.build(mode=mode, config=config) File "/home/whao/Mask_RCNN-2.0/model.py", line 1875, in build target_rois, input_gt_class_ids, gt_boxes, input_gt_masks]) File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 603, in call output = self.call(inputs, *kwargs) File "/home/whao/Mask_RCNN-2.0/model.py", line 636, in call self.config.IMAGES_PER_GPU, names=names) File "/home/whao/Mask_RCNN-2.0/utils.py", line 673, in batch_slice output_slice = graph_fn(inputs_slice) File "/home/whao/Mask_RCNN-2.0/model.py", line 635, in w, x, y, z, self.config), File "/home/whao/Mask_RCNN-2.0/model.py", line 531, in detection_targets_graph negative_count = int((positive_count / config.ROI_POSITIVE_RATIO) - positive_count) TypeError: unsupported operand type(s) for /: 'Tensor' and 'float'

why the int32 of tensor can operand to the float constant: positive_count = tf.shape(positive_indices)[0]

Negative ROIs. Add enough to maintain positive:negative ratio.

negative_count = int((positive_count / config.ROI_POSITIVE_RATIO) - positive_count)

it differs from the first version: r = 1.0 / config.ROI_POSITIVE_RATIO negative_count = tf.cast(r * tf.cast(positive_count, tf.float32), tf.int32) - positive_count What should i do to be able to do that like Mask_RCNN-2.0?

WanyiLi commented 6 years ago

I met the same problem. Have you solved it?

76176235 commented 6 years ago

@WanyiLi Yes,i solved it.You can solve it by viewing the code of the first version.

WanyiLi commented 6 years ago

@76176235 Yeah, I got it. Thank you very much!

avinashtgoje commented 6 years ago

@76176235 @WanyiLi I am getting same error !

shiqi-67 commented 6 years ago

I am sorry, i can not solve the problem, can you make it more details?

MNCTTY commented 6 years ago

@76176235 @WanyiLi hi, guys! Can you say by steps how to solve it, please? I can't understand what words "You can solve it by viewing the code of the first version" mean. Should I use this part of code from the first version in version 2.0?? upd: I've done it, but the problem still the same: TypeError: unsupported operand type(s) for /: 'Tensor' and 'float' now it's on r = 1.0 / config.ROI_POSITIVE_RATIO

shiqi-67 commented 6 years ago

you can through the error to find the different between the first version and the second version.2018-04-02 17:08:38>MNCTTY 写道:

@76176235@WanyiLi hi, guys! Can you say by steps how to solve it, please? I can't understand what words "You can solve it by viewing the code of the first version" mean. Should I use this part of code from the first version in version 2.0?? Thank you

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

guuCheng commented 6 years ago

what a pity! I also meet the same error. I can't understand how to solve the error.Can you say by steps how to solve it, please? @WanyiLi thanks !

76176235 commented 6 years ago

Now,the version of code is Mask R-CNN 2.1. You can avoid this error ,while you compile Mask R-CNN 1.0 .

guuCheng commented 6 years ago

@76176235 thanks,i will have a try!

guuCheng commented 6 years ago

@76176235 ,cool man, I solved my error,hh!