1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Mask R-CNN: How to infer the shape of Lambda's output?

Discussão em 'Python' iniciado por Stack, Outubro 1, 2024 às 02:23.

  1. Stack

    Stack Membro Participativo

    I am exploring the following sample code of Mask R-CNN: https://github.com/matterport/Mask_RCNN/tree/master/samples

    However, when I ran the demo.ipynb file, an error was returned for the code below, which I don't know how to fix.

    model = modellib.MaskRCNN(mode="inference", model_dir=MODEL_DIR, config=config)

    The error reads as follows.

    NotImplementedError: Exception encountered when calling Lambda.call().
    We could not automatically infer the shape of the Lambda's output. Please specify the `output_shape` argument for this Lambda layer.
    Arguments received by Lambda.call():
    • args=('\<KerasTensor shape=(None, 1000, 1, 1, 1024), dtype=float32, sparse=False, name=keras_tensor_3553\>',)
    • kwargs={'mask': 'None'}


    It seems that the fpn_classifier_graph function caused an error as it could not identify Lambda's output, and it is necessary to specify the correct output_shape.

    However, I have no idea how to modify the code...

    ChatGPT suggested revising the Lambda to explicitly specify the output_shape as follows, which did not work...

    shared = KL.Lambda(lambda x: K.squeeze(K.squeeze(x, 3), 2),
    name="pool_squeeze",
    output_shape=lambda s: (s[0], s[1], s[3]))(x)

    Continue reading...

Compartilhe esta Página