Rahatara commited on
Commit
f6cef20
·
verified ·
1 Parent(s): 8121868

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -2,6 +2,8 @@ import gradio as gr
2
  import trimesh
3
  import numpy as np
4
  from PIL import Image
 
 
5
 
6
  def visualize_texture(section):
7
  mesh = trimesh.load('train.glb', force='mesh')
@@ -38,7 +40,11 @@ def visualize_texture(section):
38
  color_visuals = trimesh.visual.TextureVisuals(uv=new_uv, image=im, material=material)
39
  textured_mesh = trimesh.Trimesh(vertices=mesh.vertices, faces=mesh.faces, visual=color_visuals, validate=True, process=False)
40
 
41
- return textured_mesh.export(file_type='glb')
 
 
 
 
42
 
43
  with gr.Blocks() as app:
44
  gr.Markdown("### 3D Model Texture Application")
 
2
  import trimesh
3
  import numpy as np
4
  from PIL import Image
5
+ import tempfile
6
+ import os
7
 
8
  def visualize_texture(section):
9
  mesh = trimesh.load('train.glb', force='mesh')
 
40
  color_visuals = trimesh.visual.TextureVisuals(uv=new_uv, image=im, material=material)
41
  textured_mesh = trimesh.Trimesh(vertices=mesh.vertices, faces=mesh.faces, visual=color_visuals, validate=True, process=False)
42
 
43
+ # Save the mesh to a temporary file
44
+ temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.glb')
45
+ textured_mesh.export(temp_file.name, file_type='glb')
46
+ temp_file.close() # Close the file so it can be read by Gradio
47
+ return temp_file.name
48
 
49
  with gr.Blocks() as app:
50
  gr.Markdown("### 3D Model Texture Application")