fahimehorvatinia commited on
Commit
4768cde
·
unverified ·
1 Parent(s): 61b3c2b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -30
app.py CHANGED
@@ -1,39 +1,23 @@
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() 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
- # Removed .style() for compatibility
34
- gallery = gr.Gallery(label="Outputs")
35
-
36
- run.click(demo_process, inputs=inp, outputs=gallery)
37
 
38
  if __name__ == "__main__":
39
  demo.launch()
 
1
  import gradio as gr
2
+ import tempfile
3
+ from plant_analysis_demo.wrapper import run_pipeline_on_image
4
 
5
+ def process(image):
 
 
 
 
 
6
  if image is None:
7
  return []
8
+ with tempfile.TemporaryDirectory() as tmpdir:
9
+ # Save PIL image to temp file
10
+ img_path = Path(tmpdir) / "input.png"
11
+ image.save(img_path)
12
+ outputs = run_pipeline_on_image(str(img_path), tmpdir, save_artifacts=True)
13
+ return list(outputs.values())
14
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  with gr.Blocks() as demo:
16
+ gr.Markdown("# 🌿 Sorghum Single-Image Demo")
17
+ inp = gr.Image(type="pil", label="Upload Image")
18
+ run = gr.Button("Run Pipeline", variant="primary")
19
+ gallery = gr.Gallery(label="Outputs")
20
+ run.click(process, inputs=inp, outputs=gallery)
 
 
 
 
 
 
21
 
22
  if __name__ == "__main__":
23
  demo.launch()