|
|
import gradio as gr |
|
|
from PIL import Image, ImageOps |
|
|
|
|
|
def demo_process(image): |
|
|
"""Simple placeholder: |
|
|
- returns original |
|
|
- grayscale version |
|
|
- inverted colors |
|
|
""" |
|
|
if image is None: |
|
|
return [] |
|
|
|
|
|
|
|
|
original = image |
|
|
|
|
|
|
|
|
gray = ImageOps.grayscale(image) |
|
|
|
|
|
|
|
|
inverted = ImageOps.invert(image.convert("RGB")) |
|
|
|
|
|
return [original, gray, inverted] |
|
|
|
|
|
|
|
|
with gr.Blocks(theme=gr.themes.Soft()) as demo: |
|
|
gr.Markdown("# 🌿 Plant Analysis Demo\nUpload an image and see example outputs.") |
|
|
|
|
|
with gr.Row(): |
|
|
with gr.Column(scale=1): |
|
|
inp = gr.Image(type="pil", label="Upload Image") |
|
|
run = gr.Button("Run Demo", variant="primary") |
|
|
with gr.Column(scale=2): |
|
|
gallery = gr.Gallery(label="Outputs").style(grid=[3], height="auto") |
|
|
|
|
|
run.click(demo_process, inputs=inp, outputs=gallery) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
demo.launch() |
|
|
|