File size: 1,484 Bytes
3e9df0c
 
 
fe3c2bc
 
 
 
5d19fd0
fe3c2bc
3e9df0c
5d19fd0
 
fbd48b2
5d19fd0
 
 
 
 
 
 
fbd48b2
5d19fd0
 
a5f7088
 
 
 
5d19fd0
21a6230
 
 
3c31be1
21a6230
 
 
 
 
 
 
 
 
 
 
 
fbd48b2
 
 
 
 
 
 
 
 
 
21a6230
3e9df0c
ca0eb10
fe3c2bc
21a6230
 
3c31be1
704e4c9
5d19fd0
a5f7088
fbd48b2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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  # Convert to KB
    return mesh_file, f"File: {os.path.basename(mesh_file)}, Size: {file_size:.2f} KB"

files_dir = "files"


model_files = [
    "model1.glb", 
    "model2.glb", 
    "model3.glb", 
    "model4.glb"
]


for model_file in model_files:
    file_path = os.path.join(files_dir, model_file)
    if not os.path.exists(file_path):
        print(f"Error: {file_path} does not exist.")
    else:
        print(f"Found: {file_path}")

with gr.Blocks() as demo:
    gr.Markdown(
        """
        # [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 = gr.Examples(
        examples=[
            [os.path.join(files_dir, "model1.glb")],
            [os.path.join(files_dir, "model2.glb")],
            [os.path.join(files_dir, "model3.glb")],
            [os.path.join(files_dir, "model4.glb")]
        ],
        inputs=model_input,
        outputs=[model_output, file_info]
    )

if __name__ == "__main__":
    demo.launch()