Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,63 +1,27 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
|
4 |
-
def
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
]
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
if not os.path.exists(file_path):
|
23 |
-
print(f"Error: {file_path} does not exist.")
|
24 |
-
else:
|
25 |
-
print(f"Found: {file_path}")
|
26 |
-
|
27 |
-
with gr.Blocks() as demo:
|
28 |
-
gr.Markdown(
|
29 |
-
"""
|
30 |
-
# [Three](https://huggingface.co/spaces/sudo-soldier/three)
|
31 |
-
"""
|
32 |
-
)
|
33 |
-
|
34 |
-
with gr.Row():
|
35 |
-
model_input = gr.Model3D(label="Upload a 3D Model")
|
36 |
-
file_info = gr.Textbox(label="File Info", interactive=False)
|
37 |
-
|
38 |
-
model_output = gr.Model3D(clear_color=[0.1, 0.1, 0.1, 1.0], label="Preview Model")
|
39 |
-
|
40 |
-
def handle_model_input(selected_model):
|
41 |
-
if selected_model:
|
42 |
-
file_info_str = f"File: {os.path.basename(selected_model)}, Size: {os.path.getsize(selected_model) / 1024:.2f} KB"
|
43 |
-
return selected_model, file_info_str
|
44 |
-
|
45 |
-
model_input.change(handle_model_input, inputs=model_input, outputs=[model_output, file_info])
|
46 |
-
|
47 |
-
examples = gr.Examples(
|
48 |
-
examples=[
|
49 |
-
[os.path.join(files_dir, "model1.glb")],
|
50 |
-
[os.path.join(files_dir, "model2.glb")],
|
51 |
-
[os.path.join(files_dir, "model3.glb")],
|
52 |
-
[os.path.join(files_dir, "model4.glb")]
|
53 |
-
],
|
54 |
-
inputs=model_input,
|
55 |
-
outputs=[model_output, file_info]
|
56 |
-
)
|
57 |
|
58 |
if __name__ == "__main__":
|
59 |
demo.launch()
|
60 |
-
demo.launch()
|
61 |
|
62 |
|
63 |
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
|
4 |
+
def load_mesh(mesh_file_name):
|
5 |
+
return mesh_file_name
|
6 |
+
|
7 |
+
demo = gr.Interface(
|
8 |
+
fn=load_mesh,
|
9 |
+
inputs=gr.Model3D(),
|
10 |
+
outputs=gr.Model3D(
|
11 |
+
clear_color=(0.0, 0.0, 0.0, 0.0), label="3D Model", display_mode="wireframe"),
|
12 |
+
examples=[
|
13 |
+
[os.path.join(os.path.dirname(__file__), "files/model1.glb")],
|
14 |
+
[os.path.join(os.path.dirname(__file__), "files/model2.glb")],
|
15 |
+
[os.path.join(os.path.dirname(__file__), "files/model3.glb")],
|
16 |
+
[os.path.join(os.path.dirname(__file__), "files/model4.glb")],
|
17 |
+
["https://huggingface.co/datasets/dylanebert/3dgs/resolve/main/bonsai/bonsai-7k-mini.splat"],
|
18 |
+
["https://huggingface.co/datasets/dylanebert/3dgs/resolve/main/luigi/luigi.ply"],
|
19 |
+
],
|
20 |
+
cache_examples=True
|
21 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
if __name__ == "__main__":
|
24 |
demo.launch()
|
|
|
25 |
|
26 |
|
27 |
|