Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError in run_graph #23

Closed
orestis-z opened this issue Nov 5, 2017 · 9 comments
Closed

AssertionError in run_graph #23

orestis-z opened this issue Nov 5, 2017 · 9 comments

Comments

@orestis-z
Copy link

I am running testing MASK_RCNN on my local computer and on a remote machine.
In inspect_model everything runs fine locally but on the remote machine I get an assertion error at ### 1.b RPN Predictions:

# Run RPN sub-graph
pillar = model.keras_model.get_layer("ROI").output  # node to start searching from
rpn = model.run_graph([image], [
    ("rpn_class", model.keras_model.get_layer("rpn_class").output),
    ("pre_nms_anchors", model.ancestor(pillar, "ROI/pre_nms_anchors:0")),
    ("refined_anchors", model.ancestor(pillar, "ROI/refined_anchors:0")),
    ("refined_anchors_clipped", model.ancestor(pillar, "ROI/refined_anchors_clipped:0")),
    ("post_nms_anchor_ix", model.ancestor(pillar, "ROI/rpn_non_max_suppression:0")),
    ("proposals", model.keras_model.get_layer("ROI").output),
])

=>

AssertionError            Traceback (most recent call last)
<ipython-input-14-799ca4676404> in <module>()
      7     ("refined_anchors_clipped", model.ancestor(pillar, "ROI/refined_anchors_clipped:0")),
      8     ("post_nms_anchor_ix", model.ancestor(pillar, "ROI/rpn_non_max_suppression:0")),
----> 9     ("proposals", model.keras_model.get_layer("ROI").output),
     10 ])

/home/orestisz/repositories/Mask_RCNN/model.py in run_graph(self, images, outputs)
   2296         for o in outputs.values():
   2297             print(o)
-> 2298             assert o is not None
   2299 
   2300         # Build a Keras function to run parts of the computation graph

AssertionError:

when printing the outputs:

for o in outputs.values():
            print(o)
            assert o is not None

I get the following output locally:

Tensor("rpn_class/concat:0", shape=(?, ?, 2), dtype=float32, device=/device:CPU:0)
Tensor("ROI/pre_nms_anchors:0", shape=(1, 10000, 4), dtype=float32, device=/device:CPU:0)
Tensor("ROI/refined_anchors:0", shape=(1, 10000, 4), dtype=float32, device=/device:CPU:0)
Tensor("ROI/refined_anchors_clipped:0", shape=(1, 10000, 4), dtype=float32, device=/device:CPU:0)
Tensor("ROI/rpn_non_max_suppression:0", shape=(?,), dtype=int32, device=/device:CPU:0)
Tensor("ROI/packed_2:0", shape=(1, ?, 4), dtype=float32, device=/device:CPU:0)

and the following remotely:

Tensor("rpn_class/concat:0", shape=(?, ?, 2), dtype=float32, device=/device:CPU:0)
Tensor("ROI/pre_nms_anchors:0", shape=(1, 10000, 4), dtype=float32, device=/device:CPU:0)
Tensor("ROI/refined_anchors:0", shape=(1, 10000, 4), dtype=float32, device=/device:CPU:0)
Tensor("ROI/refined_anchors_clipped:0", shape=(1, 10000, 4), dtype=float32, device=/device:CPU:0)
None

So looks like ("post_nms_anchor_ix", model.ancestor(pillar, "ROI/rpn_non_max_suppression:0")) is causing the issue.

Any suggestions? Thanks in advance

@vijaykbg
Copy link

vijaykbg commented Nov 6, 2017

I am getting the same error when I run 1.b RPN Predictions

image

Any suggestions?

@waleedka
Copy link
Collaborator

waleedka commented Nov 6, 2017

Can you provide more details about your setup?

  • Which versions of TensorFlow and Keras are you using?
  • Which OS?
  • Did you make any changes to the model, even if simple ones?

@waleedka
Copy link
Collaborator

waleedka commented Nov 6, 2017

Actually, I think I found the problem. TensorFlow 1.4 introduces a new version of the non-max-suppression operation with a new name. I just pushed a fix to handle the the 1.4 new name.

@waleedka waleedka closed this as completed Nov 6, 2017
@orestis-z
Copy link
Author

@waleedka thanks a lot for the fix!
But I think you wanted to type this:

nms_node = (model.ancestor(pillar, "ROI/rpn_non_max_suppression:0")
            or model.ancestor(pillar, "ROI/rpn_non_max_suppression/NonMaxSuppressionV2:0"))

instead of:

nms_node = (ancestor(model, pillar, "ROI/rpn_non_max_suppression:0")
            or ancestor(model, pillar, "ROI/rpn_non_max_suppression/NonMaxSuppressionV2:0"))

?

@waleedka
Copy link
Collaborator

waleedka commented Nov 6, 2017

You're right. Thank you. Pushed another fix.

@Superlee506
Copy link

@zamponotiropita Hi, do you meet this issue #285 , when I feed the run_graph with 2 images, it still outputs 1 batch_size. Any suggestion will be appreciated.

@dmiroff dmiroff mentioned this issue Jul 20, 2018
@benediktbrandt
Copy link

Just want to add that with tensorflow 1.9 it is now NonMaxSuppressionV3:0, so the code should be:

nms_node = model.ancestor(pillar, "ROI/rpn_non_max_suppression:0")
if nms_node is None:
    nms_node = model.ancestor(pillar, "ROI/rpn_non_max_suppression/NonMaxSuppressionV2:0")
if nms_node is None:
    nms_node = model.ancestor(pillar, "ROI/rpn_non_max_suppression/NonMaxSuppressionV3:0")

@1044886782
Copy link

Just want to add that with tensorflow 1.9 it is now NonMaxSuppressionV3:0, so the code should be:

nms_node = model.ancestor(pillar, "ROI/rpn_non_max_suppression:0")
if nms_node is None:
    nms_node = model.ancestor(pillar, "ROI/rpn_non_max_suppression/NonMaxSuppressionV2:0")
if nms_node is None:
    nms_node = model.ancestor(pillar, "ROI/rpn_non_max_suppression/NonMaxSuppressionV3:0")

Yeah,this helps me a lot,especially there is no answer among the Baidu or Google.I guess this bug due to the "version" will always confuse the newbie like me

@Jayleelwj
Copy link

Just want to add that with tensorflow 1.9 it is now NonMaxSuppressionV3:0, so the code should be:

nms_node = model.ancestor(pillar, "ROI/rpn_non_max_suppression:0")
if nms_node is None:
    nms_node = model.ancestor(pillar, "ROI/rpn_non_max_suppression/NonMaxSuppressionV2:0")
if nms_node is None:
    nms_node = model.ancestor(pillar, "ROI/rpn_non_max_suppression/NonMaxSuppressionV3:0")

Much appreciated for your answer. It works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants