WeijingShi / Point-GNN

Point-GNN: Graph Neural Network for 3D Object Detection in a Point Cloud, CVPR 2020.
MIT License
539 stars 112 forks source link

Visualization of graph neural network #80

Open abhigoku10 opened 3 years ago

abhigoku10 commented 3 years ago

@WeijingShi thanksfor sharing the source code i have a query 1.can we visualize the graph structure of PointGNN

  1. how to change the number of layers of the network ie currently i am not sure how __layer_configs__ gives one graphlevel:0 and three graphlevel:1 can you please explain this Thanks in advance
WeijingShi commented 3 years ago

Hi @abhigoku10,

  1. Using Open3D's lineset, we can visualize the graph. It allows you to specify a set of RGB points and lines between them. For example:

    def show_graph(src_points, des_points, edges):
    """
    :param src_points: [N, 3] src_points.
    :param des_points: [N, 3] des_points.
    :param edges: [M, 2],M pairs of connections src_points[edges[0]] -> des_points[edges[1]]
    :return: None
    """
    points = np.concatenate([src_points, des_points])
    edges[:, 1] += src_points.shape[0]
    line_set = open3d.LineSet()
    line_set.points = open3d.Vector3dVector(points)
    line_set.lines = open3d.Vector2iVector(edges)
    
    # add color if wanted
    # line_set.colors = np.zeros((edges.shape[0], 3), dtype=np.float32)
    
    def custom_draw_geometry_load_option(geometry_list):
        vis = open3d.Visualizer()
        vis.create_window()
        for geometry in geometry_list:
            vis.add_geometry(geometry)
        vis.run()
        vis.destroy_window()
    
    custom_draw_geometry_load_option([line_set])
  2. The first layer work on an input graph (graphlevel0) which is between the input points and the downsampled points. We pool the features from the input points to the downsampled points. Next are the GNN iterations. Three iterations all work on the same graph (graph level 1), where the downsampled points are connected to each other.