Args to Export .npz File
Closed this issue · 4 comments
Does anyone know how to set the args to successfully run with --export PATH/TO/FILE.npz
? It looks like there are a bunch of variables in lib/tracer//SphereTracer.py
that are None
during the rendering, such as self.num_steps
, self.camera_clamp
and self.min_dis
etc.
Not sure I understand your question. The default parameters found in options.py
should provide the correct values. These default arguments should be automatically imported in app/sdf_renderer.py
. The file exporter is just so you can render the model with the C++ interactive viewer.
Best,
Joey
Hi @joeylitalien ,
Thanks for the reply! Sorry for not being clear.
What I'm trying to do after training and getting the pretrained model is to export a 3D mesh/pointcloud object using python app/sdf_renderer.py --net OctreeSDF --num-lods 5 --pretrained _results/models/armadillo.pth --render-res 1280 720 --shading-mode matcap --lod 4 --export _results/render_app/imgs/armadillo/armadillo.npz
However I don't have num_steps
or camera_clamp
information as I encountered the errors:
Total number of parameters: 10146213
camera_clamp change to [0,0]
Traceback (most recent call last):
File "app/sdf_renderer.py", line 106, in
net = SOL_NGLOD(net)
File "/ssd2/yzhao/nglod/sdf-net/lib/models/SOL_NGLOD.py", line 50, in init
self.vs = voxel_sparsify(2000000, net, self.lod, sol=False)
File "/ssd2/yzhao/nglod/sdf-net/lib/renderutils.py", line 63, in voxel_sparsify
surface = sample_surface(n, net, sol=sol, device=device)[:n]
File "/ssd2/yzhao/nglod/sdf-net/lib/renderutils.py", line 42, in sample_surface
rb = tracer(net, ray_o, ray_d)
File "/ssd2/yzhao/nglod/sdf-net/lib/tracer/BaseTracer.py", line 49, in call
return self.forward(*args, **kwargs)
File "/ssd2/yzhao/nglod/sdf-net/lib/tracer/SphereTracer.py", line 91, in forward
cond = cond & (torch.abs(d) > self.min_dis)[:,0]
TypeError: '>' not supported between instances of 'Tensor' and 'NoneType'
So I hardcoded some value, for example, num_steps = 5 and camera_clamp = [0, 0], but it turned out to have some errors like this:
Total number of parameters: 10146213
camera_clamp change to [0,0]
Traceback (most recent call last):
File "app/sdf_renderer.py", line 106, in
net = SOL_NGLOD(net)
File "/ssd2/yzhao/nglod/sdf-net/lib/models/SOL_NGLOD.py", line 50, in init
self.vs = voxel_sparsify(2000000, net, self.lod, sol=False)
File "/ssd2/yzhao/nglod/sdf-net/lib/renderutils.py", line 63, in voxel_sparsify
surface = sample_surface(n, net, sol=sol, device=device)[:n]
File "/ssd2/yzhao/nglod/sdf-net/lib/renderutils.py", line 42, in sample_surface
rb = tracer(net, ray_o, ray_d)
File "/ssd2/yzhao/nglod/sdf-net/lib/tracer/BaseTracer.py", line 49, in call
return self.forward(*args, **kwargs)
File "/ssd2/yzhao/nglod/sdf-net/lib/tracer/SphereTracer.py", line 132, in forward
grad = gradient(x[hit], net, method=self.grad_method)
File "/ssd2/yzhao/nglod/sdf-net/lib/diffutils.py", line 82, in gradient
raise NotImplementedError
NotImplementedError
So I'm wondering is there any example command with arg values to export the .npz file successfully since I'm quite new to the field. Thanks in advance!
The file exporter is simply for portability AFAIK; it does not convert the neural surfaces into a 3D mesh like you want. Please see issue #24 for some code to do this.
As for your code snippet, setting camera_clamp = [0,0]
will undoubtedly produce errors because this parameter is used to specify clipping bounds around the [-1,1] unit cube where the surface is traced. Setting it to zero means you are tracing nothing. Similarly, num_steps
specifies the maximum number of iterations when performing sphere tracing, so setting it to a low value will most likely not output the correct render.
Hope this clarifies a few things,
Joey
Hi @joeylitalien , Thank you so much for the explanation! I manually set the values to default ones in options.py
and it moved forward a little bit.
May I also ask how much memory is required to export a mesh using the command mentioned above? As I'm getting RuntimeError: CUDA out of memory. Tried to allocate 978.00 MiB (GPU 0; 22.38 GiB total capacity; 21.05 GiB already allocated; 63.94 MiB free; 21.68 GiB reserved in total by PyTorch)
no matter which gpu I use. Thanks again!
--update--:
Sorry I misunderstood a little! Thank you again for the help! Just one more question - does import mcubes
refer to marching cubes and can be installed by pip/conda in issue #24 ? I tried to install using conda install -c flyem-forge marching_cubes
, it looks like there is a conflict with Python3.8. Thanks!
Sorry again for the repeated updates! I've successfully exported a mesh. Thanks again!