weixi-feng / LayoutGPT

Official repo for LayoutGPT
MIT License
300 stars 20 forks source link

IndexError: list index out of range #6

Closed thucz closed 1 year ago

thucz commented 1 year ago

Hi! This is a great repo!

I have finished the data preparation steps and generated the scene by run_layoutgpt_3d.py. I'm trying to visualize the generated 3D layout by rendering the image scenes:

basedir="/mnt/data/agic/data"

visualization_output_dir="./vis"
output_directory=$basedir"/output_pickle/threed_future_model_bedroom.pkl"
python render_from_file.py ../config/bedrooms_eval_config.yaml $visualization_output_dir $output_directory ../demo/floor_plan_texture_images \
    ../../llm_output/3D/gpt3.5.bedroom.k-similar.k_8.px_regular.json \
    --up_vector 0,1,0 --camera_position 2,2,2 --split test_regular --export_scene

I met the following error:

Traceback (most recent call last):
  File "render_from_files.py", line 383, in <module>
    main(sys.argv[1:])
  File "render_from_files.py", line 318, in main
    renderables, trimesh_meshes = get_textured_objects(
  File "/mnt/data/agic/LayoutGPT/ATISS/scene_synthesis/utils.py", line 31, in get_textured_objects
    raw_mesh = TexturedMesh.from_file(furniture.raw_model_path)
  File "/home/chenzheng/anaconda3/envs/atiss/lib/python3.8/site-packages/simple_3dviz/renderables/textured_mesh.py", line 300, in from_file
    mtl = read_material_file(mesh.material_file)
  File "/home/chenzheng/anaconda3/envs/atiss/lib/python3.8/site-packages/simple_3dviz/io/__init__.py", line 27, in read_material_file
    return {
  File "/home/chenzheng/anaconda3/envs/atiss/lib/python3.8/site-packages/simple_3dviz/io/material.py", line 25, in __init__
    self.read(filename)
  File "/home/chenzheng/anaconda3/envs/atiss/lib/python3.8/site-packages/simple_3dviz/io/material.py", line 113, in read
    self._Ns = float([
IndexError: list index out of range

I do not understand why this error occurred and don't know how to resolve it. Could you help me?

I found that simple_3dviz/io/material.py tried to read data from 3D-FUTURE-model/c2fecd9b-c61e-423a-a48d-08c63931cd1f/model.mtl And simple_3dviz assumed that model.mtl contains the specular exponent, namely a line starting with "Ns". But in fact, I do not find that. How should I resolve this gap?

The content of model.mtl:

newmtl solid_001_wire

d 1
Tr 0
Tf 1.000000 1.000000 1.000000
illum 2
Ka 0.000000 0.000000 0.000000
Kd 0.000000 0.000000 0.000000
Ks 0.313725 0.313725 0.313725
Ke 0.000000 0.000000 0.000000

map_Ka ./texture.png
map_Kd ./texture.png

newmtl solid_002_wire

d 1
Tr 0
Tf 1.000000 1.000000 1.000000
illum 2
Ka 0.196078 0.196078 0.196078
Kd 0.196078 0.196078 0.196078
Ks 0.705882 0.705882 0.705882
Ke 0.000000 0.000000 0.000000

map_Ka ./texture.png
map_Kd ./texture.png

newmtl solid_003_wire

d 1
Tr 0
Tf 1.000000 1.000000 1.000000
illum 2
Ka 0.500000 0.500000 0.500000
Kd 0.500000 0.500000 0.500000
Ks 0.117647 0.117647 0.117647
Ke 0.000000 0.000000 0.000000

map_Ka ./texture.png
map_Kd ./texture.png

newmtl solid_004_wire

d 1
Tr 0
Tf 1.000000 1.000000 1.000000
illum 2
Ka 0.500000 0.500000 0.500000
Kd 0.500000 0.500000 0.500000
Ks 0.098039 0.098039 0.098039
Ke 0.000000 0.000000 0.000000

map_Ka ./texture.png
map_Kd ./texture.png

newmtl solid_005_wire

d 1
Tr 0
Tf 1.000000 1.000000 1.000000
illum 2
Ka 0.500000 0.500000 0.500000
Kd 0.500000 0.500000 0.500000
Ks 0.137255 0.137255 0.137255
Ke 0.000000 0.000000 0.000000

map_Ka ./texture.png
map_Kd ./texture.png
weixi-feng commented 1 year ago

Hi,

Thanks for the question! I must have forgotten to update this part, as this is a legacy issue from ATISS. Please follow the solution here by replacing line 31 in utils.py with the code block.

In fact, I believe all places with TexturedMesh.from_file should be replaced with the code block for simple_3dviz to work. I will double-check and update the repo later. Please let me know if you still encounter problems.

weixi-feng commented 1 year ago

Hi,

I have updated the code to fix the render issue. Closing the issue now but feel free to re-open it if the issue persists.