import gradio as gr import trimesh import base64 import io def modify_texture(): # Load the GLB file mesh = trimesh.load("train.glb") # Load the default texture image with open("defect.jpg", "rb") as f: default_texture_data = f.read() # Set the texture to the mesh mesh.visual.material.texture.image = default_texture_data # Export the modified mesh to GLB format modified_mesh_data = mesh.export(file_type="glb") # Convert the modified mesh data to BytesIO object output_file = io.BytesIO(modified_mesh_data) return output_file gr.Interface( fn=modify_texture, inputs=[], outputs=gr.File(label="Download Modified GLB File"), title="GLB Texture Modifier" ).launch()