pytorch3d
pytorch3d copied to clipboard
ValueError: Meshes does not have textures
When I am trying to load meshes for renderer, raise ValueError("Meshes does not have textures")
- This is the code, mesh_path is *.ply file, and there is also *.png file as texture file, I want to load mesh from ply file and also textures
for mesh_path in mesh_paths:
obj_label = int(osp.basename(mesh_path).split('.')[0].split('_')[-1])-1
self.meshes[obj_label] = load_mesh(mesh_path)
then here is the exception log
File "/data_sata/SixDoF_Group/SixDoF_Group/WorkSpace_ZT/scflow/test.py", line 123, in <module>
outputs = single_gpu_test(model, dataloader, validate=args.eval)
File "/data_sata/SixDoF_Group/SixDoF_Group/WorkSpace_ZT/scflow/tools/eval.py", line 51, in single_gpu_test
batch_preds = model(data, return_loss=False)
File "/data_sata/SixDoF_Group/SixDoF_Group/anaconda3/envs/scflow/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/data_sata/SixDoF_Group/SixDoF_Group/anaconda3/envs/scflow/lib/python3.9/site-packages/mmcv/parallel/data_parallel.py", line 42, in forward
return super().forward(*inputs, **kwargs)
File "/data_sata/SixDoF_Group/SixDoF_Group/anaconda3/envs/scflow/lib/python3.9/site-packages/torch/nn/parallel/data_parallel.py", line 166, in forward
return self.module(*inputs[0], **kwargs[0])
File "/data_sata/SixDoF_Group/SixDoF_Group/anaconda3/envs/scflow/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/data_sata/SixDoF_Group/SixDoF_Group/WorkSpace_ZT/scflow/models/refiner/base_refiner.py", line 341, in forward
data = self.format_data_test(data_batch)
File "/data_sata/SixDoF_Group/SixDoF_Group/WorkSpace_ZT/scflow/models/refiner/base_refiner.py", line 95, in format_data_test
render_outputs = self.renderer(ref_rotations, ref_translations, internel_k, labels)
File "/data_sata/SixDoF_Group/SixDoF_Group/anaconda3/envs/scflow/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/data_sata/SixDoF_Group/SixDoF_Group/WorkSpace_ZT/scflow/models/utils/rendering.py", line 219, in forward
images, fragments = self.image_renderer(meshes_to_render, cameras=cameras, znear=znear, zfar=zfar, lights=lights)
File "/data_sata/SixDoF_Group/SixDoF_Group/anaconda3/envs/scflow/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/data_sata/SixDoF_Group/SixDoF_Group/anaconda3/envs/scflow/lib/python3.9/site-packages/pytorch3d/renderer/mesh/renderer.py", line 108, in forward
images = self.shader(fragments, meshes_world, **kwargs)
File "/data_sata/SixDoF_Group/SixDoF_Group/anaconda3/envs/scflow/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/data_sata/SixDoF_Group/SixDoF_Group/anaconda3/envs/scflow/lib/python3.9/site-packages/pytorch3d/renderer/mesh/shader.py", line 94, in forward
texels = meshes.sample_textures(fragments)
File "/data_sata/SixDoF_Group/SixDoF_Group/anaconda3/envs/scflow/lib/python3.9/site-packages/pytorch3d/structures/meshes.py", line 1546, in sample_textures
raise ValueError("Meshes does not have textures")
ValueError: Meshes does not have textures
Thanks for your kind answer!
PyTorch3D does not have built-in support for reading a texture image together with a ply file. Are there UV coordinates stored in the ply file itself?
Are there other tools which read or write data like this, making this a standard way to store a mesh? If so, can you share an example of the data?
Thank you for your answer, I have found the method, from PR#1100
The file header contains the texture file like this
comment TextureFile <NAME>.png
Thanks again for your kindly help!
Great! I'll say the same here as I said there: If you have a freely-licensed example of such data (or you want to create a synthetic test data file) then we can nicely merge that PR.
Is the open Dataset like YCB-V freely-licensed?
Here is where this dataset come from
@article{xiang2017posecnn,
author = {Xiang, Yu and Schmidt, Tanner and Narayanan, Venkatraman and Fox, Dieter},
title = {PoseCNN: A Convolutional Neural Network for 6D Object Pose Estimation in Cluttered Scenes},
journal = {arXiv preprint arXiv:1711.00199},
year = {2017}
}