TKOSEI commited on
Commit
10f4a0b
·
verified ·
1 Parent(s): d7244fa

preview rotated model

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -478,8 +478,14 @@ def process_image_and_generate_stl(image_input, depth_near, depth_far, thickness
478
  prepare_for_3d_printing=True,
479
  lift_height=-lift
480
  )
481
-
482
- return stl_path, stl_path # Return the path to the generated STL file
 
 
 
 
 
 
483
 
484
 
485
  # Gradio Interface definition
 
478
  prepare_for_3d_printing=True,
479
  lift_height=-lift
480
  )
481
+ preview_path = stl_path.replace(".stl", "_preview.stl")
482
+ mesh = trimesh.load(stl_path)
483
+ rot = trimesh.transformations.rotation_matrix(np.radians(180), [0, 0, 1])
484
+ rot2 = trimesh.transformations.rotation_matrix(np.radians(-90),[0, 1, 0])
485
+ mesh.apply_transform(rot)
486
+ mesh.apply_transform(rot2)
487
+ mesh.export(preview_path)
488
+ return stl_path, preview_path # Return the path to the generated STL file
489
 
490
 
491
  # Gradio Interface definition