sudo-soldier commited on
Commit
73b0b4b
·
verified ·
1 Parent(s): b02a984

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -54
app.py CHANGED
@@ -1,63 +1,27 @@
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 # Size in KB
9
- return mesh_file, f"File: {os.path.basename(mesh_file)}, Size: {file_size:.2f} KB"
10
-
11
- files_dir = "files"
12
-
13
- model_files = [
14
- "model1.glb",
15
- "model2.glb",
16
- "model3.glb",
17
- "model4.glb"
18
- ]
19
-
20
- for model_file in model_files:
21
- file_path = os.path.join(files_dir, model_file)
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