Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with data preprocessing: MTL files do not contain Ns lines #3

Closed
pauljcb opened this issue Dec 7, 2021 · 5 comments
Closed

Comments

@pauljcb
Copy link

pauljcb commented Dec 7, 2021

Hi,

The material files provided with the meshes in the 3D-FUTURE dataset do no contain information about the specular exponents "Ns", leading to a failure of simple_3dviz when reading the textured meshes in preprocess_data.py :

Traceback (most recent call last):
  File "preprocess_data.py", line 271, in <module>
    main(sys.argv[1:])
  File "preprocess_data.py", line 258, in main
    renderables = get_textured_objects_in_scene(
  File "E:\users\PJB1\Code\ATISS\scripts\utils.py", line 144, in get_textured_objects_in_scene
    raw_mesh = TexturedMesh.from_file(model_path)
  File "C:\Users\PJB1\Miniconda3\envs\atiss\lib\site-packages\simple_3dviz\renderables\textured_mesh.py", line 300, in from_file
    mtl = read_material_file(mesh.material_file)
  File "C:\Users\PJB1\Miniconda3\envs\atiss\lib\site-packages\simple_3dviz\io\__init__.py", line 27, in read_material_file
    return {
  File "C:\Users\PJB1\Miniconda3\envs\atiss\lib\site-packages\simple_3dviz\io\material.py", line 25, in __init__
    self.read(filename)
  File "C:\Users\PJB1\Miniconda3\envs\atiss\lib\site-packages\simple_3dviz\io\material.py", line 113, in read
    self._Ns = float([
IndexError: list index out of range

Do you know an easy way to overcome this issue without having to locally make changes in the simple_3dviz library ?
Thanks !
Paul

@nazcaspider
Copy link
Contributor

I ran into that problem too. Checkout my pull request at simple-3dviz: angeloskath/simple-3dviz#7

@pauljcb
Copy link
Author

pauljcb commented Dec 17, 2021

Thank you for your answer ! Without having to modify through simple-3dviz, for the moment I have come with this trick.
In get_textured_objects_in_scene of file scripts\utils.py, add from simple_3dviz.io import read_mesh_file and replace:

# Load the furniture and scale it as it is given in the dataset
raw_mesh = TexturedMesh.from_file(model_path)

by:

# Load the furniture and scale it as it is given in the dataset
try:
    raw_mesh = TexturedMesh.from_file(model_path)
except:
    try:
        texture_path = furniture.texture_image_path
        mesh_info = read_mesh_file(model_path)
        vertices = mesh_info.vertices
        normals = mesh_info.normals
        uv = mesh_info.uv
        material = Material.with_texture_image(texture_path)
        raw_mesh = TexturedMesh(vertices,normals,uv,material)
    except:
        print("Failed loading texture info.")
        raw_mesh = Mesh.from_file(model_path)

Feel free if you have better solutions.

@wamiq-reyaz
Copy link

@pauljcb I used your code to fix the IndexError but I face this one

python preprocess_data.py /datawaha/cggroup/parawr/datasets/scenegraphs/3D-bedrooms /datawaha/cggroup/parawr/datasets/scenegraphs/3D-FRONT /datawaha/cggroup/parawr/datasets/scenegraphs/3D-FUTURE-model /datawaha/cggroup/parawr/datasets/scenegraphs/3D-FUTURE-model/model_info.json /datawaha/cggroup/parawr/datasets/scenegraphs/3D-FRONT-texture-folder --dataset_filtering threed_front_bedroom Applying threed_front_bedroom filtering Loading scenes from /tmp/threed_front.pkl Loading dataset with 682 rooms Saving training statistics for dataset with bounds: {'translations': (array([-2.76956 , 0.0844895 , -2.65222538]), array([2.55987 , 3.396067, 2.66785 ])), 'sizes': (array([0.05946365, 0.0505 , 0.05698576]), array([2.10990515, 1.55473 , 1.32646537])), 'angles': (array([-3.14159265]), array([3.14159265]))} to /datawaha/cggroup/parawr/datasets/scenegraphs/3D-bedrooms/dataset_stats.txt Applying threed_front_bedroom filtering Loading scenes from /tmp/threed_front.pkl {'translations': (array([-2.76956 , 0.0844895 , -2.65222538]), array([2.55987 , 3.396067, 2.66785 ])), 'sizes': (array([0.05946365, 0.0505 , 0.05698576]), array([2.10990515, 1.55473 , 1.32987 ])), 'angles': (array([-3.14159265]), array([3.14159265]))} Loading dataset with 711 rooms 274it [13:39, 2.99s/it] Traceback (most recent call last): File "preprocess_data.py", line 271, in <module> main(sys.argv[1:]) File "preprocess_data.py", line 261, in main render( File "/home/parawr/Projects/scenegraphs/external/ATISS/scripts/utils.py", line 194, in render scene.add(r) File "/home/parawr/anaconda3/envs/atiss/lib/python3.8/site-packages/simple_3dviz/scenes.py", line 60, in add renderable.init(self._ctx) File "/home/parawr/anaconda3/envs/atiss/lib/python3.8/site-packages/simple_3dviz/renderables/textured_mesh.py", line 197, in init self.material = self._material File "/home/parawr/anaconda3/envs/atiss/lib/python3.8/site-packages/simple_3dviz/renderables/textured_mesh.py", line 239, in material self._material.texture.shape[2], IndexError: tuple index out of range

Any idea what causes this?

@wamiq-reyaz
Copy link

Well, I do know what causes this. There are a few textures in the 3D-FRONT dataset that are greyscale and do not have that axis indexed by 2. My solution was to simply remove those textures.

@paschalidoud
Copy link
Collaborator

Hi,

I am sorry for not replying sooner. As @wamiq-reyaz said the simplest solution is simply to remove those textures. Unfortunately, this is an issue with 3D-FRONT data, so we don't have a better way of solving it. I am closing this issue for now but feel free to reopen it.

Cheers,
Despoina

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants