Mask_RCNN icon indicating copy to clipboard operation
Mask_RCNN copied to clipboard

Mask-RCNN TF 2.4.1 Compatibility

Open Mstfakts opened this issue 3 years ago • 4 comments

Hello,

I've seen a number of projects made for TF2.x compatibility. Despite the fact that I have made necessary changes to the project, none of them work properly.

I've been working on a project that has a number of deep learning components that must work together. Also, as I strive to add new features to my project that include detection and segmentation, I've opted to use this framework. I was thinking that if I only changed a little portion of the MaskRCNN, it would still function with the rest of the project. My work, however, has been entangled due to version differences.

So, I was wondering how I could run MaskRCNN without utilizing tf.compat.v1.disable eager execution() in TF 2.4.1. If I utilize this line block, it impacts the entire working process of my project and causes numerous issues.

  1. The first error that I get is:
asserts = [
        tf.Assert(tf.greater(tf.shape(input=proposals)[0], 0), [proposals],
                  name="roi_assertion"),
    ]

TypeError: Could not build a TypeSpec for <tf.Operation 'tf.debugging.Assert/Assert/AssertGuard/Identity' type=Identity> with type Operation

Despite I made it a remark line, the project generates similar issues for the rest of the lines.

  1. If I change that line block to a comment line, I get the following error:
tf.cond(
        pred=tf.greater(tf.shape(input=positive_overlaps)[1], 0),
        true_fn=lambda: tf.argmax(input=positive_overlaps, axis=1),
        false_fn=lambda: tf.cast(tf.constant([]), tf.int64)
    )

TypeError: To be compatible with tf.eager.defun, Python functions must return zero or more Tensors; in compilation of <function <lambda> at 0x0000015B27E0EEE8>, found return value of type <class 'tensorflow.python.keras.engine.keras_tensor.KerasTensor'>, which is not a Tensor.

  1. Other issues I encountered when working with tf.compat.v1.disable eager execution() are listed below.

    3.1- I attempted to utilize that block of code to work for only one file, however once you place it in your project, it impacts the entire project. The rest of the project then produces a variety of mistakes.

    3.2- After that, I put tf.compat.v1.enable eager execution() exactly before the'return' part of the file. In that scenario, the project states that it is not permitted to enable or disable easger execution while the project is in progress.

Mstfakts avatar Feb 04 '22 08:02 Mstfakts

I work with: RTX 3060 python 3.8 cuda_11.0.2_451.48_win10 cudnn-11.0-windows-x64-v8.0.4.30 TF: 2.3.0 Keras: 2.4.3 and it runs with GPU well. btw, I use https://github.com/leekunhee/Mask_RCNN for tf2.X

AndySung320 avatar Feb 11 '22 06:02 AndySung320

this might help in your case.

Kamlesh364 avatar Apr 20 '22 05:04 Kamlesh364

I work with: RTX 3060 python 3.8 cuda_11.0.2_451.48_win10 cudnn-11.0-windows-x64-v8.0.4.30 TF: 2.3.0 Keras: 2.4.3 and it runs with GPU well. btw, I use https://github.com/leekunhee/Mask_RCNN for tf2.X

He said he would like to use it without having to disable eager execution. The repo you linked to has eager execution disabled to make this code work with TF 2

tqamarVT avatar Sep 18 '22 19:09 tqamarVT

this might help in your case.

Again, he said he is looking to see how he can run this code in TF2 without having to disable eager execution.

Your update is disabling eager execution to make it work

tqamarVT avatar Sep 18 '22 19:09 tqamarVT