Spaces:
mashroo
/
Runtime error

YoussefAnso commited on
Commit
a34ef67
·
1 Parent(s): e5c94c9

Refactor generate3d function in inference.py to streamline mesh export process. Removed manual MTL file handling and updated export calls to enhance code clarity and maintainability.

Browse files
Files changed (1) hide show
  1. inference.py +3 -17
inference.py CHANGED
@@ -75,20 +75,6 @@ def generate3d(model, rgb, ccm, device):
75
  texture_path = base_path + ".png"
76
  mtl_path = base_path + ".mtl"
77
 
78
- model.export_mesh_geometry(data_config, obj_path) # writes .obj with UVs
79
- model.export_texture_image(data_config, texture_path) # saves PNG
80
-
81
- # Write MTL file manually
82
- with open(mtl_path, "w") as f:
83
- f.write("newmtl material0\n")
84
- f.write("Kd 1.000000 1.000000 1.000000\n")
85
- f.write(f"map_Kd {os.path.basename(texture_path)}\n")
86
-
87
- # Append .mtl reference to OBJ file
88
- with open(obj_path, "r") as original:
89
- lines = original.readlines()
90
- with open(obj_path, "w") as modified:
91
- modified.write(f"mtllib {os.path.basename(mtl_path)}\n")
92
- modified.writelines(lines)
93
-
94
- return obj_path
 
75
  texture_path = base_path + ".png"
76
  mtl_path = base_path + ".mtl"
77
 
78
+ model.export_mesh(data_config, base_path, tri_fea_2=triplane_feature2) # writes .obj
79
+
80
+ return obj_path