google-research / nerf-from-image

Shape, Pose, and Appearance from a Single Image via Bootstrapped Radiance Field Inversion
Apache License 2.0
377 stars 18 forks source link

converting to triangle mesh #19

Closed yyash-patel closed 5 months ago

yyash-patel commented 5 months ago

Hi,

I followed the process as mentioned in #12 , but result seems weird , may be I might have made a mistake . This is what I did -

  1. executed the command - python run.py --resume_from g_p3d_car_pretrained --inv_export_demo_sample --gpus 4 --batch_size 16

  2. and then saved SDF output from this line because I think SDF values are sampled according to the 3D query points (coords) - https://github.com/google-research/nerf-from-image/blob/fddf72a8bc7b64307fad146f9a7b39d8df56a915/models/generator.py#L626

  3. finally ran the code below (.npy is the file that I save from the above mentioned step, shape is (128,128,128))

sdf = np.load('sdf_distance.npy')
vertices, triangles = mcubes.marching_cubes(-sdf, 0)

mesh = o3d.geometry.TriangleMesh()
mesh.vertices = o3d.utility.Vector3dVector(vertices)
mesh.triangles = o3d.utility.Vector3iVector(triangles)
o3d.io.write_triangle_mesh("mesh_file.ply", mesh)

I have attached the result of the mesh view for one of the image of a car ,

car2 car1

Can you please advise ?

yyash-patel commented 5 months ago

The issue is resolved !