matterport / Mask_RCNN

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

MaskR-CNN on MacBook GPU #2175

Open jasdal365 opened 4 years ago

jasdal365 commented 4 years ago

Hi! Is it possible to run the Mask R-CNN on a GPU: AMD Radeon Pro 5300M. As far as I know with PlaidML you get a backend for keras, but in the code there are several tensorflow operations. Therefore I tried ngraph-bridge, which leads to this error:

Traceback (most recent call last):
  File “/Users/jd/Documents/Mask R-CNN/env/lib/python3.7/site-packages/tensorflow/python/framework/tensor_util.py”, line 558, in make_tensor_proto
    str_values = [compat.as_bytes(x) for x in proto_values]
  File “/Users/jd/Documents/Mask R-CNN/env/lib/python3.7/site-packages/tensorflow/python/framework/tensor_util.py”, line 558, in <listcomp>
    str_values = [compat.as_bytes(x) for x in proto_values]
  File “/Users/jd/Documents/Mask R-CNN/env/lib/python3.7/site-packages/tensorflow/python/util/compat.py”, line 65, in as_bytes
    (bytes_or_text,))
TypeError: Expected binary or unicode string, got <tile.Value Add FLOAT32(<tile.Value SymbolicDim UINT64()>, <tile.Value Add FLOAT64()>, <tile.Value Add FLOAT64()>, 6)>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File “/Users/jd/Documents/Mask R-CNN/3_validate.py”, line 160, in <module>
    model = modellib.MaskRCNN(mode=“inference”, config=ValConfig(), model_dir=RESULT_MODEL)
  File “INPUT_NETWORK/mrcnn/model.py”, line 1817, in __init__
    self.keras_model = self.build(mode=mode, config=config)
  File “INPUT_NETWORK/mrcnn/model.py”, line 1921, in build
    len(config.RPN_ANCHOR_RATIOS), config.TOP_DOWN_PYRAMID_SIZE)
  File “INPUT_NETWORK/mrcnn/model.py”, line 885, in build_rpn_model
    outputs = rpn_graph(input_feature_map, anchors_per_location, anchor_stride)
  File “INPUT_NETWORK/mrcnn/model.py”, line 852, in rpn_graph
    lambda t: tf.reshape(t, [tf.shape(t)[0], -1, 2]))(x)
  File “/Users/jd/Documents/Mask R-CNN/env/lib/python3.7/site-packages/keras/engine/base_layer.py”, line 457, in __call__
    output = self.call(inputs, **kwargs)
  File “/Users/jd/Documents/Mask R-CNN/env/lib/python3.7/site-packages/keras/layers/core.py”, line 687, in call
    return self.function(inputs, **arguments)
  File “INPUT_NETWORK/mrcnn/model.py”, line 852, in <lambda>
    lambda t: tf.reshape(t, [tf.shape(t)[0], -1, 2]))(x)
  File “/Users/jd/Documents/Mask R-CNN/env/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py”, line 330, in shape
    return shape_internal(input, name, optimize=True, out_type=out_type)
  File “/Users/jd/Documents/Mask R-CNN/env/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py”, line 354, in shape_internal
    input_tensor = ops.convert_to_tensor(input)
  File “/Users/jd/Documents/Mask R-CNN/env/lib/python3.7/site-packages/tensorflow/python/framework/ops.py”, line 1087, in convert_to_tensor
    return convert_to_tensor_v2(value, dtype, preferred_dtype, name)
  File “/Users/jd/Documents/Mask R-CNN/env/lib/python3.7/site-packages/tensorflow/python/framework/ops.py”, line 1145, in convert_to_tensor_v2
    as_ref=False)
  File “/Users/jd/Documents/Mask R-CNN/env/lib/python3.7/site-packages/tensorflow/python/framework/ops.py”, line 1224, in internal_convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File “/Users/jd/Documents/Mask R-CNN/env/lib/python3.7/site-packages/tensorflow/python/framework/constant_op.py”, line 305, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File “/Users/jd/Documents/Mask R-CNN/env/lib/python3.7/site-packages/tensorflow/python/framework/constant_op.py”, line 246, in constant
    allow_broadcast=True)
  File “/Users/jd/Documents/Mask R-CNN/env/lib/python3.7/site-packages/tensorflow/python/framework/constant_op.py”, line 284, in _constant_impl
    allow_broadcast=allow_broadcast))
  File “/Users/jd/Documents/Mask R-CNN/env/lib/python3.7/site-packages/tensorflow/python/framework/tensor_util.py”, line 562, in make_tensor_proto
    “supported type.” % (type(values), values))
TypeError: Failed to convert object of type <class ‘plaidml.tile.Value’> to Tensor. Contents: Add FLOAT32(<tile.Value SymbolicDim UINT64()>, <tile.Value Add FLOAT64()>, <tile.Value Add FLOAT64()>, 6). Consider casting elements to a supported type.

I would really appreciate if someone has got recommendations or instructions for this problem.

fabiofumarola commented 4 years ago

I think not all the layers are implemented in plaidml.