Illustre commited on
Commit
fa81db4
1 Parent(s): 76c45ee

Update model.py

Browse files
Files changed (1) hide show
  1. model.py +9 -7
model.py CHANGED
@@ -84,16 +84,18 @@ class Model:
84
  delete=False,
85
  mode='w+b')
86
  decode_latent_mesh(self.xm, latent).tri_mesh().write_ply(ply_path)
87
- ply_path.close() # Close the file after writing
88
 
89
- # Open the file in binary mode for reading
90
- with open(ply_path.name, 'rb') as file:
91
- data = file.read()
 
 
92
 
93
- outputs = [ply_path.name, data]
94
-
95
- return outputs
96
 
 
 
97
  def run_text(self,
98
  prompt: str,
99
  seed: int = 0,
 
84
  delete=False,
85
  mode='w+b')
86
  decode_latent_mesh(self.xm, latent).tri_mesh().write_ply(ply_path)
 
87
 
88
+ mesh = trimesh.load(ply_path.name)
89
+ rot = trimesh.transformations.rotation_matrix(-np.pi / 2, [1, 0, 0])
90
+ mesh = mesh.apply_transform(rot)
91
+ rot = trimesh.transformations.rotation_matrix(np.pi, [0, 1, 0])
92
+ mesh = mesh.apply_transform(rot)
93
 
94
+ mesh_path = tempfile.NamedTemporaryFile(suffix='.glb', delete=False)
95
+ mesh.export(mesh_path.name, file_type='glb')
 
96
 
97
+ return mesh_path.name
98
+
99
  def run_text(self,
100
  prompt: str,
101
  seed: int = 0,