File size: 751 Bytes
3834351
4768cde
a32df56
3834351
4768cde
3834351
 
4768cde
 
 
 
 
 
3834351
9226311
4768cde
 
 
 
 
3834351
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
import tempfile
from wrapper import run_pipeline_on_image

def process(image):
    if image is None:
        return []
    with tempfile.TemporaryDirectory() as tmpdir:
        # Save PIL image to temp file
        img_path = Path(tmpdir) / "input.png"
        image.save(img_path)
        outputs = run_pipeline_on_image(str(img_path), tmpdir, save_artifacts=True)
        return list(outputs.values())

with gr.Blocks() as demo:
    gr.Markdown("# 🌿 Sorghum Single-Image Demo")
    inp = gr.Image(type="pil", label="Upload Image")
    run = gr.Button("Run Pipeline", variant="primary")
    gallery = gr.Gallery(label="Outputs")
    run.click(process, inputs=inp, outputs=gallery)

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