zipnerf-pytorch icon indicating copy to clipboard operation
zipnerf-pytorch copied to clipboard

Surface level must be within volume data range

Open pokameng opened this issue 1 year ago • 12 comments

@SuLvXiangXin hello when i run bash scripts/extract_360.sh,there is a error: extract.py", line 379, in main verts, faces, normals, values = measure.marching_cubes(

ValueError: Surface level must be within volume data range.

My dataset is bicycle

pokameng avatar Jun 03 '23 05:06 pokameng

@pokameng How is your training process, and the rendered image?

SuLvXiangXin avatar Jun 03 '23 15:06 SuLvXiangXin

@pokameng How is your training process, and the rendered image?

My training and rendered are from the old code version, but my mesh is from the latest. My training and rendered process are successful.

pokameng avatar Jun 05 '23 13:06 pokameng

+1 I am seeing the same error with the garden dataset:

2023-06-05 16:38:28: Generate visibility mask...
Warning: image_path not found for reconstruction
Generating visibility grid: 100%|██████████████████████████████████| 161/161 [25:23<00:00,  9.46s/it, visibility_mask=0]
2023-06-05 17:04:01: Extract mesh from visibility mask...
2023-06-05 17:04:04: Error!
Traceback (most recent call last):
  File "/mnt/c/Users/B/zipnerf-pytorch/extract.py", line 638, in <module>
    app.run(main)
  File "/home/fox/.local/lib/python3.10/site-packages/absl/app.py", line 308, in run
    _run_main(main, args)
  File "/home/fox/.local/lib/python3.10/site-packages/absl/app.py", line 254, in _run_main
    sys.exit(main(argv))
  File "/mnt/c/Users/B/zipnerf-pytorch/extract.py", line 379, in main
    verts, faces, normals, values = measure.marching_cubes(
  File "/home/fox/.local/lib/python3.10/site-packages/skimage/measure/_marching_cubes_lewiner.py", line 131, in marching_cubes
    return _marching_cubes_lewiner(volume, level, spacing,
  File "/home/fox/.local/lib/python3.10/site-packages/skimage/measure/_marching_cubes_lewiner.py", line 160, in _marching_cubes_lewiner
    raise ValueError("Surface level must be within volume data range.")
ValueError: Surface level must be within volume data range.

Training succeeded, and renders look great: image

image

@SuLvXiangXin What might be happening here? Thanks!

EDIT, I also saw an error when I added Config.mesh_resolution = 1024 to the config file.

antithing avatar Jun 05 '23 16:06 antithing

@antithing @pokameng Surface level must be within volume data range means no mesh can be extract while all density are below or above the surface value. Maybe you are using the old training code, and extract.py use a different behavior of loading checkpoint, please make sure you load the checkpoint correctly. You are expexted to find the log in log_extract.txt like this

2023-05-28 13:51:18: Resuming from checkpoint exp/360_v2_glo/garden/checkpoints/025000
2023-05-28 13:51:18: Loading states from exp/360_v2_glo/garden/checkpoints/025000
2023-05-28 13:51:20: All model weights loaded successfully
2023-05-28 13:51:20: All optimizer states loaded successfully
2023-05-28 13:51:20: All scheduler states loaded successfully
2023-05-28 13:51:20: GradScaler state loaded successfully
2023-05-28 13:51:20: All random states loaded successfully

If you have loaded the checkpoint correctly, please let me known.

SuLvXiangXin avatar Jun 06 '23 00:06 SuLvXiangXin

AH, the checkpoi9nt is not loading. I am running extract_360.sh, which is:

#!/bin/bash

SCENE=garden
EXPERIMENT=360_v2/"$SCENE"
DATA_ROOT=/mnt/c/Users/B/zipnerf-pytorch/data/
DATA_DIR="$DATA_ROOT"/"$SCENE"

accelerate launch extract.py --gin_configs=configs/360.gin \
    --gin_bindings="Config.data_dir = '${DATA_DIR}'" \
    --gin_bindings="Config.exp_name = '${EXP_NAME}'" \
    --gin_bindings="Config.factor = 4"

And the error is:

2023-06-06 08:56:19: Checkpoint does not exist. Starting a new training run.
2023-06-06 08:56:19: Load visibility mask from exp/mesh/visibility_mask_0.2.pt
2023-06-06 08:56:21: Extract mesh from visibility mask...
2023-06-06 08:56:23: Error!

However, when I run render_360.sh, with the same variables:

#!/bin/bash

SCENE=garden
EXPERIMENT=360_v2/"$SCENE"
DATA_ROOT=/mnt/c/Users/B/zipnerf-pytorch/data/
DATA_DIR="$DATA_ROOT"/"$SCENE"

accelerate launch render.py \
  --gin_configs=configs/360.gin \
  --gin_bindings="Config.data_dir = '${DATA_DIR}'" \
  --gin_bindings="Config.exp_name = '${EXPERIMENT}'" \
  --gin_bindings="Config.render_path = True" \
  --gin_bindings="Config.render_path_frames = 120" \
  --gin_bindings="Config.render_video_fps = 30" \
  --gin_bindings="Config.factor = 4"

It works. Is this an issue with the extract sh script? Thanks!

antithing avatar Jun 06 '23 07:06 antithing

Ah, okay, I had a typo in the script. --gin_bindings="Config.exp_name = '${EXP_NAME}'" \ should have been --gin_bindings="Config.exp_name = '${EXPERIMENT}'" \

Now it runs, and errors with:

2023-06-06 08:58:27: Resuming from checkpoint exp/360_v2/garden/checkpoints/025000
2023-06-06 08:58:27: Loading states from exp/360_v2/garden/checkpoints/025000
2023-06-06 08:58:31: All model weights loaded successfully
2023-06-06 08:58:31: All optimizer states loaded successfully
2023-06-06 08:58:31: All scheduler states loaded successfully
2023-06-06 08:58:31: All random states loaded successfully
2023-06-06 08:58:31: Loading in 0 custom states
2023-06-06 08:58:31: Generate visibility mask...
Warning: image_path not found for reconstruction
Generating visibility grid: 100%|█████████████████████████████| 161/161 [24:24<00:00,  9.10s/it, visibility_mask=0.0028]
2023-06-06 09:23:12: Extract mesh from visibility mask...
2023-06-06 09:23:18: Extract visibility mask done.
2023-06-06 09:23:18: Process grid cell (1/1, 1/1, 1/1)...
2023-06-06 09:23:58: Extract mesh...
2023-06-06 09:23:59: Extract vertices: 79448, faces: 113175
2023-06-06 09:23:59: Concatenate mesh...
2023-06-06 09:23:59: Clean mesh...
Repair non manifold vertices:  78%|██████████████████████████████████████████▊            | 7/9 [00:00<00:00,  5.64it/s]2023-06-06 09:24:00: Mesh cleaning: (79448, 3) --> (0, 3), (113175, 3) --> (0, 3)
2023-06-06 09:24:00: Evaluate mesh vertex color...
Evaluating color projection: 0it [00:00, ?it/s]
2023-06-06 09:24:00: Error!
Traceback (most recent call last):
  File "/mnt/c/Users/B/zipnerf-pytorch/extract.py", line 638, in <module>
    app.run(main)
  File "/home/sfox/.local/lib/python3.10/site-packages/absl/app.py", line 308, in run
    _run_main(main, args)
  File "/home/sfox/.local/lib/python3.10/site-packages/absl/app.py", line 254, in _run_main
    sys.exit(main(argv))
  File "/mnt/c/Users/B/zipnerf-pytorch/extract.py", line 492, in main
    rgbs = evaluate_color_projection(module, accelerator, v, f, config)
  File "/home/sfox/.local/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "/mnt/c/Users/B/zipnerf-pytorch/extract.py", line 157, in evaluate_color_projection
    vc = torch.cat(vc, dim=0)
RuntimeError: torch.cat(): expected a non-empty list of Tensors

What am i missing now? Thanks!

antithing avatar Jun 06 '23 08:06 antithing

@antithing It seems that the clean_mesh operation delete all the vertices. That's strange, you can try to comment out the clean_mesh operation in the code and try it again.

SuLvXiangXin avatar Jun 06 '23 15:06 SuLvXiangXin

I comment out:

  #  vertices, faces = clean_mesh(vertices, faces,
   #                              remesh=False, remesh_size=0.01,
   #                              logger=logger, main_process=accelerator.is_main_process)

now it is working, but it only exports this mesh: (from the garden dataset)

image

Also there is only a ply file, with no texture.

Thank you for your help!

log_extract.txt

log_render.txt log_train.txt

antithing avatar Jun 06 '23 18:06 antithing

Okay I deleted the experiment folder, and started again from scratch. I get a different error on mesh extraction. Please see all logs attached. log_extract.txt log_train.txt

Thank you!

antithing avatar Jun 06 '23 20:06 antithing

@antithing KeyboardInterrupt It seems that you interupt it using Ctrl + C?

SuLvXiangXin avatar Jun 07 '23 08:06 SuLvXiangXin

Okay I have re-cloned the repo and started again. (with the bicycle dataset) I have it running, however I see an error when I add Config.mesh_resolution = 1024

ValueError: Configurable 'Config' doesn't have a parameter named 'mesh_resolution'.
  In file "configs/360.gin", line 7
    Config.mesh_resolution = 1024

And the resulting mesh looks like this:

image

Is this the expected mesh quality? Or can I get a better result?

Thanks again!

antithing avatar Jun 07 '23 12:06 antithing

@antithing Sorry for confusing, you can use Config.mesh_voxels=1073741824 instead of Config.mesh_resolution = 1024, while 1073741824 equals to 1024**3 .

For the texture, you can explore a way to make it better, while I have both methods provided in the code can't get fine results.

SuLvXiangXin avatar Jun 07 '23 12:06 SuLvXiangXin