bl / app.py
AmeerUlAman's picture
Upload app.py
f3b5bae verified
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()