jchibane / if-net

Implicit Feature Network (IF-Net) - Codebase
314 stars 57 forks source link

question about boundary_sampling #28

Closed LordLiang closed 3 years ago

LordLiang commented 3 years ago
def boundary_sampling(path):
    try:

        if os.path.exists(path +'/boundary_{}_samples.npz'.format(args.sigma)):
            return

        off_path = path + '/isosurf_scaled.off'
        out_file = path +'/boundary_{}_samples.npz'.format(args.sigma)

        mesh = trimesh.load(off_path)
        points = mesh.sample(sample_num)

        boundary_points = points + args.sigma * np.random.randn(sample_num, 3)
        grid_coords = boundary_points.copy()
        grid_coords[:, 0], grid_coords[:, 2] = boundary_points[:, 2], boundary_points[:, 0]

        grid_coords = 2 * grid_coords

        occupancies = iw.implicit_waterproofing(mesh, boundary_points)[0]

        np.savez(out_file, points=boundary_points, occupancies = occupancies, grid_coords= grid_coords)
        print('Finished {}'.format(path))
    except:
        print('Error with {}: {}'.format(path, traceback.format_exc()))

Hi, thank you for your excellent work! I have 2 questions about boundary_sampling, can you help me?

  1. Why do you exchange grid_coords[:, 0] and grid_coords[:, 2]? Do you want to rotate grid_coords ?
  2. grid_coords = 2 * grid_coords before this you normalize the range to [-0.5, 0.5] while you generate isosurf_scaled.off, now why do you change it to [-1, 1]
jchibane commented 3 years ago

Hi LordLiang,

this is the coordinate system which is needed for the 'grid_sample' function, see for example

https://github.com/jchibane/if-net/blob/master/models/local_model.py#L141

The grid sample function is used for trilinear interpolation when doing feature extraction from discrete deep feature grids at continuously sampled point coordinates.

Best, Julian

eoozbq commented 1 month ago

Hi LordLiang,

this is the coordinate system which is needed for the 'grid_sample' function, see for example

https://github.com/jchibane/if-net/blob/master/models/local_model.py#L141

The grid sample function is used for trilinear interpolation when doing feature extraction from discrete deep feature grids at continuously sampled point coordinates.

Best, Julian

Hi, I encountered a similar issue in the voxelized_data_shapenet.py file. In the return statement(line 76):

return {'grid_coords': np.array(coords, dtype=np.float32), 'occupancies': np.array(occupancies, dtype=np.float32), 'points': np.array(points, dtype=np.float32), 'inputs': np.array(input, dtype=np.float32), 'path': path} I noticed that the key 'points' is included but not actually used. Additionally, I observed that 'grid_coords' does not fall within the range [-1, 1], as points + sigma results in values exceeding this range. I’m trying to understand where exactly the 'points' data is supposed to be useful.

eoozbq commented 1 month ago

Hi LordLiang,

this is the coordinate system which is needed for the 'grid_sample' function, see for example

https://github.com/jchibane/if-net/blob/master/models/local_model.py#L141

The grid sample function is used for trilinear interpolation when doing feature extraction from discrete deep feature grids at continuously sampled point coordinates.

Best, Julian

Hi, I encountered a similar issue in the voxelized_data_shapenet.py file. In the return statement:

return {'grid_coords': np.array(coords, dtype=np.float32), 'occupancies': np.array(occupancies, dtype=np.float32), 'points': np.array(points, dtype=np.float32), 'inputs': np.array(input, dtype=np.float32), 'path': path} I noticed that the key 'points' is included but not actually used. Additionally, I observed that 'grid_coords' does not fall within the range [-1, 1], as points + sigma results in values exceeding this range. I’m trying to understand where exactly the 'points' data is supposed to be useful.