def layer_shapes(image_shape, model):
    """
    Compute layer shapes given input image shape and the model.
    Args
        image_shape: The shape of the image.
        model: The model to use for computing how the image shape is transformed in the pyramid.
    Returns
        A dictionary mapping layer names to image shapes.
    """
    shape = {
        model.layers[0].name: (None,) + image_shape,
    }

    for layer in model.layers[1:]:
        nodes = layer._inbound_nodes
        for node in nodes:
            input_shapes = [shape[inbound_layer.name] for inbound_layer in node.inbound_layers]
            if not input_shapes:
                continue
            shape[layer.name] = layer.compute_output_shape(
                input_shapes[0] if len(input_shapes) == 1 else input_shapes
            )

    return shape