Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from PIL import Image, ImageOps
|
| 3 |
+
|
| 4 |
+
def demo_process(image):
|
| 5 |
+
"""Simple placeholder:
|
| 6 |
+
- returns original
|
| 7 |
+
- grayscale version
|
| 8 |
+
- inverted colors
|
| 9 |
+
"""
|
| 10 |
+
if image is None:
|
| 11 |
+
return []
|
| 12 |
+
|
| 13 |
+
# Original
|
| 14 |
+
original = image
|
| 15 |
+
|
| 16 |
+
# Grayscale
|
| 17 |
+
gray = ImageOps.grayscale(image)
|
| 18 |
+
|
| 19 |
+
# Invert
|
| 20 |
+
inverted = ImageOps.invert(image.convert("RGB"))
|
| 21 |
+
|
| 22 |
+
return [original, gray, inverted]
|
| 23 |
+
|
| 24 |
+
# Build Gradio UI
|
| 25 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 26 |
+
gr.Markdown("# 🌿 Plant Analysis Demo\nUpload an image and see example outputs.")
|
| 27 |
+
|
| 28 |
+
with gr.Row():
|
| 29 |
+
with gr.Column(scale=1):
|
| 30 |
+
inp = gr.Image(type="pil", label="Upload Image")
|
| 31 |
+
run = gr.Button("Run Demo", variant="primary")
|
| 32 |
+
with gr.Column(scale=2):
|
| 33 |
+
gallery = gr.Gallery(label="Outputs").style(grid=[3], height="auto")
|
| 34 |
+
|
| 35 |
+
run.click(demo_process, inputs=inp, outputs=gallery)
|
| 36 |
+
|
| 37 |
+
if __name__ == "__main__":
|
| 38 |
+
demo.launch()
|