sdfstudio icon indicating copy to clipboard operation
sdfstudio copied to clipboard

Export mesh not working after training a model with nerfstudio data

Open ManuConcepBrito opened this issue 1 year ago • 8 comments

Description I successfully trained a model with nerfstudio-data, but when exporting the data to a mesh, I get the following error:

Extract mesh with marching cubes and may take a while
Traceback (most recent call last):
  File "/usr/local/bin/ns-extract-mesh", line 8, in <module>
    sys.exit(entrypoint())
  File "/root/sdfstudio/scripts/extract_mesh.py", line 139, in entrypoint
    tyro.cli(tyro.conf.FlagConversionOff[ExtractMesh]).main()
  File "/root/sdfstudio/scripts/extract_mesh.py", line 125, in main
    get_surface_sliding(
  File "/usr/local/lib/python3.10/dist-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/root/sdfstudio/nerfstudio/utils/marching_cubes.py", line 159, in get_surface_sliding
    combined.merge_vertices(digits_vertex=6)
AttributeError: 'list' object has no attribute 'merge_vertices

To Reproduce Train with:

ns-train neus-facto --pipeline.model.sdf-field.inside-outside False --vis viewer --experiment-name shoe nerfstudio-data --data shoe

And export mesh with:

ns-extract-mesh --load-config outputs/shoe/neus-facto/2023-09-08_161804/config.yml --output-path meshes/shoe.ply

ManuConcepBrito avatar Sep 08 '23 17:09 ManuConcepBrito

Hi, how is the model looks like in the viewer or in wandb? Could you try to uncomment this line to check if the mesh is extracted successfully https://github.com/autonomousvision/sdfstudio/blob/master/nerfstudio/utils/marching_cubes.py#L149?

niujinshuchong avatar Sep 08 '23 20:09 niujinshuchong

I tried that but still getting that error, the viewer does not load the visualization but the data looks good (and I tried with Nerfstudio and it is working). This is what the viewer looks like:

imagen

ManuConcepBrito avatar Sep 15 '23 11:09 ManuConcepBrito

I'm also facing the same issue for some scenes of my private dataset. The 'combined' list is empty instead of being Trimesh datatype. On a closer look, I found that the learned SDF doesn't have a zero level set (hence, it cannot enter the Marching cubes code block). A quick way to check would be to print(f"Min SDF: {np.min(z)}, Max SDF: {np.max(z)}, Level: {level}") above the line.

So turns out it's not a mesh extraction code issue but a NeuS training issue for my case. Your issue may be different, but might be worth checking out the SDF.

mayankgolhar avatar Sep 20 '23 18:09 mayankgolhar

I'm also facing the same issue for some scenes of my private dataset. The 'combined' list is empty instead of being Trimesh datatype. On a closer look, I found that the learned SDF doesn't have a zero level set (hence, it cannot enter the Marching cubes code block). A quick way to check would be to print(f"Min SDF: {np.min(z)}, Max SDF: {np.max(z)}, Level: {level}") above the line.

So turns out it's not a mesh extraction code issue but a NeuS training issue for my case. Your issue may be different, but might be worth checking out the SDF.

Hey, i'm having the same issue with a bakedangelo model. Extract mesh with marching cubes and may take a while Min SDF: -0.6122978329658508, Max SDF: -0.5027145147323608, Level: 0 Min SDF: -0.6156349182128906, Max SDF: -0.505859911441803, Level: 0 Min SDF: -0.6124227046966553, Max SDF: -0.5026049017906189, Level: 0 Min SDF: -0.6124935150146484, Max SDF: -0.5062590837478638, Level: 0 Min SDF: -0.6747320294380188, Max SDF: -0.48882657289505005, Level: 0 Min SDF: -0.6608027219772339, Max SDF: -0.5282750129699707, Level: 0 Min SDF: -0.6763045787811279, Max SDF: -0.4956194758415222, Level: 0 Min SDF: -0.6555583477020264, Max SDF: -0.534900963306427, Level: 0 AAAAAAAAAAAAAAAAAAAAAAAAA Traceback (most recent call last): File "/root/anaconda3/envs/sdfstudio/bin/ns-extract-mesh", line 8, in <module> sys.exit(entrypoint()) File "/home/vrai/repos/sdfstudio/scripts/extract_mesh.py", line 139, in entrypoint tyro.cli(tyro.conf.FlagConversionOff[ExtractMesh]).main() File "/home/vrai/repos/sdfstudio/scripts/extract_mesh.py", line 125, in main get_surface_sliding( File "/root/anaconda3/envs/sdfstudio/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(*args, **kwargs) File "/home/vrai/repos/sdfstudio/nerfstudio/utils/marching_cubes.py", line 161, in get_surface_sliding combined.merge_vertices(digits_vertex=6) AttributeError: 'list' object has no attribute 'merge_vertices'

i printed that line but the level here is 0. Any suggestions?

Training a new model would help?

davidceka avatar Dec 04 '23 21:12 davidceka

Hey, I have also get the same error. I printed the value of 'combined' variable and it seems to be empty while training Bakedangelo.

✅ Done loading checkpoint from outputs/bakedangelo-all-faces/bakedangelo/2024-01-20_165734/sdfstudio_models/step-000980000.ckpt Extract mesh with marching cubes and may take a while Min SDF: -7.898805141448975, Max SDF: -7.541195869445801, Level: 0 Min SDF: -8.815443992614746, Max SDF: -7.792299270629883, Level: 0 Min SDF: -7.899983882904053, Max SDF: -7.538562297821045, Level: 0 Min SDF: -8.818672180175781, Max SDF: -7.7922563552856445, Level: 0 Min SDF: -8.005515098571777, Max SDF: -7.5059075355529785, Level: 0 Min SDF: -8.922639846801758, Max SDF: -7.899257659912109, Level: 0 Min SDF: -8.006643295288086, Max SDF: -7.511916637420654, Level: 0 Min SDF: -8.920838356018066, Max SDF: -7.901449203491211, Level: 0 combined--->[] Traceback (most recent call last): File "/home/ew38upaq/anaconda3/envs/nerfstudio/bin/ns-extract-mesh", line 8, in <module> sys.exit(entrypoint()) File "/home/ew38upaq/models/sdfstudio/scripts/extract_mesh.py", line 139, in entrypoint tyro.cli(tyro.conf.FlagConversionOff[ExtractMesh]).main() File "/home/ew38upaq/models/sdfstudio/scripts/extract_mesh.py", line 125, in main get_surface_sliding( File "/home/ew38upaq/anaconda3/envs/nerfstudio/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "/home/ew38upaq/models/sdfstudio/nerfstudio/utils/marching_cubes.py", line 160, in get_surface_sliding combined.merge_vertices(digits_vertex=6) AttributeError: 'list' object has no attribute 'merge_vertices'

mohit-choithwani avatar Jan 21 '24 15:01 mohit-choithwani

I also encountered the same problem. After I trained bakedangelo, I encountered the same error when trying to extract mesh.AttributeError: 'list' object has no attribute 'merge_vertices'

  1. train bakedangelo:ns-train bakedangelo --machine.num-gpus 2 --pipeline.datamanager.train-num-rays-per-batch 1500 --pipeline.model.sdf-field.inside-outside False --vis wandb --experiment-name bakedangelo-dtu65 sdfstudio-data --data data/dtu/scan65
  2. extract mesh: image

wujinhu1999 avatar Jan 26 '24 03:01 wujinhu1999

I also encountered the same problem. After I trained bakedangelo, I encountered the same error when trying to extract mesh.AttributeError: 'list' object has no attribute 'merge_vertices'

  1. train bakedangelo:ns-train bakedangelo --machine.num-gpus 2 --pipeline.datamanager.train-num-rays-per-batch 1500 --pipeline.model.sdf-field.inside-outside False --vis wandb --experiment-name bakedangelo-dtu65 sdfstudio-data --data data/dtu/scan65

  2. extract mesh:

image

In my experience, this error occurs when the model isn't training right, either because of the dataset being invalid or some other error like this. Have you checked the training parameters? Also, you could try and change the flash "save only last checkpoint" to false, so you can check all the checkpoints previous to that. One time I had that error as iteration 200k and I had to go down to 160k to get a valid mesh extraction.

Nonetheless, I can suggest to retrain the model and see if that helps.

davidceka avatar Jan 26 '24 08:01 davidceka

I also encountered the same problem. After I trained bakedangelo, I encountered the same error when trying to extract mesh.AttributeError: 'list' object has no attribute 'merge_vertices'

  1. train bakedangelo:ns-train bakedangelo --machine.num-gpus 2 --pipeline.datamanager.train-num-rays-per-batch 1500 --pipeline.model.sdf-field.inside-outside False --vis wandb --experiment-name bakedangelo-dtu65 sdfstudio-data --data data/dtu/scan65
  2. extract mesh:

image

In my experience, this error occurs when the model isn't training right, either because of the dataset being invalid or some other error like this. Have you checked the training parameters? Also, you could try and change the flash "save only last checkpoint" to false, so you can check all the checkpoints previous to that. One time I had that error as iteration 200k and I had to go down to 160k to get a valid mesh extraction.

Nonetheless, I can suggest to retrain the model and see if that helps.

Hello, I tried several weights and still got the error. The training parameters are those of the author and I have not changed them. The only change is this --pipeline.datamanager.train-num-rays-per-batch 1500. I used two 3090, 24g gpu.

wujinhu1999 avatar Jan 28 '24 02:01 wujinhu1999