cronos3k commited on
Commit
8773046
·
verified ·
1 Parent(s): 37c335c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -136,13 +136,21 @@ def export_full_quality_glb(
136
  ) -> Tuple[str, str]:
137
  """
138
  Export a full-quality GLB file from the 3D model state.
139
- Uses the optimized export_full_quality_glb from postprocessing utils.
140
  """
141
  user_dir = os.path.join(TMP_DIR, str(req.session_hash))
142
  gs, mesh, trial_id = unpack_state(state)
143
 
 
 
 
 
 
 
 
 
 
144
  glb_path = os.path.join(user_dir, f"{trial_id}_full.glb")
145
- postprocessing_utils.export_full_quality_glb(gs, mesh, glb_path)
146
  return glb_path, glb_path
147
 
148
  @spaces.GPU
@@ -153,7 +161,7 @@ def extract_glb(
153
  req: gr.Request,
154
  ) -> Tuple[str, str]:
155
  """
156
- Extract a GLB file from the 3D model with reduction settings.
157
  """
158
  user_dir = os.path.join(TMP_DIR, str(req.session_hash))
159
  gs, mesh, trial_id = unpack_state(state)
@@ -264,7 +272,4 @@ if __name__ == "__main__":
264
  pipeline = TrellisImageTo3DPipeline.from_pretrained("JeffreyXiang/TRELLIS-image-large")
265
  pipeline.cuda()
266
  try:
267
- pipeline.preprocess_image(Image.fromarray(np.zeros((512, 512, 3), dtype=np.uint8))) # Preload rembg
268
- except:
269
- pass
270
- demo.launch()
 
136
  ) -> Tuple[str, str]:
137
  """
138
  Export a full-quality GLB file from the 3D model state.
 
139
  """
140
  user_dir = os.path.join(TMP_DIR, str(req.session_hash))
141
  gs, mesh, trial_id = unpack_state(state)
142
 
143
+ glb = postprocessing_utils.to_glb(
144
+ gs,
145
+ mesh,
146
+ simplify=0.0, # No simplification
147
+ fill_holes=True,
148
+ fill_holes_max_size=0.04,
149
+ texture_size=2048, # Maximum texture resolution
150
+ verbose=False
151
+ )
152
  glb_path = os.path.join(user_dir, f"{trial_id}_full.glb")
153
+ glb.export(glb_path)
154
  return glb_path, glb_path
155
 
156
  @spaces.GPU
 
161
  req: gr.Request,
162
  ) -> Tuple[str, str]:
163
  """
164
+ Extract a GLB file from the 3D model.
165
  """
166
  user_dir = os.path.join(TMP_DIR, str(req.session_hash))
167
  gs, mesh, trial_id = unpack_state(state)
 
272
  pipeline = TrellisImageTo3DPipeline.from_pretrained("JeffreyXiang/TRELLIS-image-large")
273
  pipeline.cuda()
274
  try:
275
+ pipeline.