Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,45 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
|
|
|
4 |
def load_mesh_with_info(mesh_file):
|
5 |
if not mesh_file:
|
6 |
return None, "No file selected"
|
7 |
|
8 |
-
file_size = os.path.getsize(mesh_file) / 1024
|
9 |
return mesh_file, f"File: {os.path.basename(mesh_file)}, Size: {file_size:.2f} KB"
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
["files/model1.glb"],
|
18 |
["files/model2.glb"],
|
19 |
["files/model3.glb"],
|
20 |
["files/model4.glb"],
|
21 |
-
]
|
22 |
-
|
23 |
-
|
|
|
|
|
24 |
|
25 |
if __name__ == "__main__":
|
26 |
demo.launch()
|
27 |
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
|
4 |
+
|
5 |
def load_mesh_with_info(mesh_file):
|
6 |
if not mesh_file:
|
7 |
return None, "No file selected"
|
8 |
|
9 |
+
file_size = os.path.getsize(mesh_file) / 1024
|
10 |
return mesh_file, f"File: {os.path.basename(mesh_file)}, Size: {file_size:.2f} KB"
|
11 |
|
12 |
+
|
13 |
+
with gr.Blocks() as demo:
|
14 |
+
gr.Markdown(
|
15 |
+
"""
|
16 |
+
# [huggingface.co/spaces/sudo-soldier/three](https://huggingface.co/spaces/sudo-soldier/three)
|
17 |
+
"""
|
18 |
+
)
|
19 |
+
|
20 |
+
with gr.Row():
|
21 |
+
model_input = gr.Model3D(label="Upload a 3D Model")
|
22 |
+
file_info = gr.Text(label="File Info")
|
23 |
+
|
24 |
+
model_output = gr.Model3D(clear_color=[0.1, 0.1, 0.1, 1.0], label="Preview Model")
|
25 |
+
|
26 |
+
|
27 |
+
model_input.change(load_mesh_with_info, inputs=model_input, outputs=[model_output, file_info])
|
28 |
+
|
29 |
+
|
30 |
+
examples = [
|
31 |
["files/model1.glb"],
|
32 |
["files/model2.glb"],
|
33 |
["files/model3.glb"],
|
34 |
["files/model4.glb"],
|
35 |
+
]
|
36 |
+
|
37 |
+
|
38 |
+
demo.examples = examples
|
39 |
+
|
40 |
|
41 |
if __name__ == "__main__":
|
42 |
demo.launch()
|
43 |
|
44 |
+
|
45 |
+
|