Spaces:
Sleeping
Sleeping
import gradio as gr | |
import os | |
def load_mesh_with_info(mesh_file): | |
if not mesh_file: | |
return None, "No file selected" | |
file_size = os.path.getsize(mesh_file) / 1024 | |
return mesh_file, f"File: {os.path.basename(mesh_file)}, Size: {file_size:.2f} KB" | |
with gr.Blocks() as demo: | |
gr.Markdown( | |
""" | |
# [huggingface.co/spaces/sudo-soldier/three](https://huggingface.co/spaces/sudo-soldier/three) | |
""" | |
) | |
with gr.Row(): | |
model_input = gr.Model3D(label="Upload a 3D Model") | |
file_info = gr.Text(label="File Info") | |
model_output = gr.Model3D(clear_color=[0.1, 0.1, 0.1, 1.0], label="Preview Model") | |
model_input.change(load_mesh_with_info, inputs=model_input, outputs=[model_output, file_info]) | |
examples = [ | |
["files/model1.glb"], | |
["files/model2.glb"], | |
["files/model3.glb"], | |
["files/model4.glb"], | |
] | |
demo.examples = examples | |
if __name__ == "__main__": | |
demo.launch() | |