File size: 2,445 Bytes
f3b5bae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
67
68
69
70
71
72
73
74
75
76
77
import gradio as gr
from PIL import Image, ImageOps


def run_model(

    image: Image.Image,

    log_relative_depth: bool,

    export_glb: bool,

    export_ply: bool,

):
    if image is None:
        return "Please upload an image.", None

    # Dummy "processing": convert to grayscale as a stand‑in for your real model
    processed = ImageOps.grayscale(image)

    log_lines = [
        "✔ Received image",
        f"  - size: {image.size[0]} x {image.size[1]}",
        f"  - log_relative_depth: {log_relative_depth}",
        f"  - export_glb_meshes: {export_glb}",
        f"  - export_ply_meshes: {export_ply}",
        "",
        "This is a placeholder. Replace run_model() with your real pipeline.",
    ]

    # Gallery expects a list of images
    return "\n".join(log_lines), [processed]


with gr.Blocks(theme="gradio/soft") as demo:
    gr.Markdown("# SAM3D‑style Demo\nA playground layout similar to advanced Spaces.")

    with gr.Tab("Inputs"):
        with gr.Row():
            # LEFT: image + options
            with gr.Column(scale=1):
                image_in = gr.Image(
                    label="Image",
                    type="pil",
                    height=360,
                    tool="editor",
                )
                gr.Markdown("### Options")
                log_depth = gr.Checkbox(label="Log relative depth", value=False)
                export_glb = gr.Checkbox(label="Export GLB meshes", value=False)
                export_ply = gr.Checkbox(label="Export PLY meshes", value=False)
                run_btn = gr.Button("Run", variant="primary", size="sm")

            # RIGHT: viewer / logs (placeholder)
            with gr.Column(scale=2):
                gr.Markdown("### Viewer / Logs")
                logs_out = gr.Textbox(
                    label="Logs",
                    lines=18,
                    max_lines=30,
                    show_label=False,
                )

    with gr.Tab("Outputs"):
        gr.Markdown("### Results")
        gallery_out = gr.Gallery(
            label="Output",
            show_label=False,
            columns=2,
            height=360,
        )

    # Wire button
    run_btn.click(
        fn=run_model,
        inputs=[image_in, log_depth, export_glb, export_ply],
        outputs=[logs_out, gallery_out],
    )

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