AmeerUlAman commited on
Commit
c364db2
·
verified ·
1 Parent(s): d9137c4

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +74 -0
app.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from PIL import Image, ImageOps
3
+
4
+
5
+ def run_model(
6
+ image: Image.Image,
7
+ log_relative_depth: bool,
8
+ export_glb: bool,
9
+ export_ply: bool,
10
+ ):
11
+ if image is None:
12
+ return "Please upload an image.", None
13
+
14
+ # Dummy processing: convert to grayscale (replace with your real model)
15
+ processed = ImageOps.grayscale(image)
16
+
17
+ log_lines = [
18
+ "✔ Received image",
19
+ f" - size: {image.size[0]} x {image.size[1]}",
20
+ f" - log_relative_depth: {log_relative_depth}",
21
+ f" - export_glb_meshes: {export_glb}",
22
+ f" - export_ply_meshes: {export_ply}",
23
+ "",
24
+ "This is a placeholder. Replace run_model() with your real pipeline.",
25
+ ]
26
+
27
+ return "\n".join(log_lines), [processed]
28
+
29
+
30
+ with gr.Blocks(theme="gradio/soft") as demo:
31
+ gr.Markdown("# SAM3D‑style Demo\nA playground layout similar to advanced Spaces.")
32
+
33
+ with gr.Tab("Inputs"):
34
+ with gr.Row():
35
+ # LEFT: image + options
36
+ with gr.Column(scale=1):
37
+ image_in = gr.Image(
38
+ label="Image",
39
+ type="pil",
40
+ height=360,
41
+ )
42
+ gr.Markdown("### Options")
43
+ log_depth = gr.Checkbox(label="Log relative depth", value=False)
44
+ export_glb = gr.Checkbox(label="Export GLB meshes", value=False)
45
+ export_ply = gr.Checkbox(label="Export PLY meshes", value=False)
46
+ run_btn = gr.Button("Run", variant="primary", size="sm")
47
+
48
+ # RIGHT: viewer / logs (placeholder)
49
+ with gr.Column(scale=2):
50
+ gr.Markdown("### Viewer / Logs")
51
+ logs_out = gr.Textbox(
52
+ label="Logs",
53
+ lines=18,
54
+ max_lines=30,
55
+ show_label=False,
56
+ )
57
+
58
+ with gr.Tab("Outputs"):
59
+ gr.Markdown("### Results")
60
+ gallery_out = gr.Gallery(
61
+ label="Output",
62
+ show_label=False,
63
+ columns=2,
64
+ height=360,
65
+ )
66
+
67
+ run_btn.click(
68
+ fn=run_model,
69
+ inputs=[image_in, log_depth, export_glb, export_ply],
70
+ outputs=[logs_out, gallery_out],
71
+ )
72
+
73
+ if __name__ == "__main__":
74
+ demo.launch()