Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ import io
|
|
| 6 |
|
| 7 |
def visualize_texture():
|
| 8 |
# Load the GLB file
|
| 9 |
-
mesh = trimesh.load('train.glb', force=
|
| 10 |
|
| 11 |
# Load the texture image
|
| 12 |
im = Image.open('defect.jpg')
|
|
@@ -20,10 +20,14 @@ def visualize_texture():
|
|
| 20 |
color_visuals = trimesh.visual.TextureVisuals(uv=uv, image=im, material=material)
|
| 21 |
|
| 22 |
# Apply the texture to the original mesh
|
| 23 |
-
textured_mesh = trimesh.Trimesh(vertices=mesh.vertices, faces=mesh.faces, visual=color_visuals, validate=True, process=
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
|
| 29 |
with gr.Blocks() as app:
|
|
|
|
| 6 |
|
| 7 |
def visualize_texture():
|
| 8 |
# Load the GLB file
|
| 9 |
+
mesh = trimesh.load('train.glb', force='mesh')
|
| 10 |
|
| 11 |
# Load the texture image
|
| 12 |
im = Image.open('defect.jpg')
|
|
|
|
| 20 |
color_visuals = trimesh.visual.TextureVisuals(uv=uv, image=im, material=material)
|
| 21 |
|
| 22 |
# Apply the texture to the original mesh
|
| 23 |
+
textured_mesh = trimesh.Trimesh(vertices=mesh.vertices, faces=mesh.faces, visual=color_visuals, validate=True, process=False)
|
| 24 |
|
| 25 |
+
# Export the modified model to a file
|
| 26 |
+
textured_mesh.export('trainm.glb')
|
| 27 |
+
|
| 28 |
+
# Return the file path
|
| 29 |
+
return 'trainm.glb'
|
| 30 |
+
|
| 31 |
|
| 32 |
|
| 33 |
with gr.Blocks() as app:
|