Fahimeh Orvati Nia commited on
Commit
2a055cf
·
1 Parent(s): 93d0941
Files changed (2) hide show
  1. app.py +48 -6
  2. requirements.txt +3 -1
app.py CHANGED
@@ -4,7 +4,7 @@ from pathlib import Path
4
  from wrapper import run_pipeline_on_image
5
  from PIL import Image
6
 
7
-
8
  def process(file_path):
9
  if not file_path:
10
  return None, None, None, None, None, [], ""
@@ -57,7 +57,26 @@ def process(file_path):
57
 
58
  stats_text = outputs.get('StatsText', '')
59
 
60
- return size_img, composite, mask, overlay, input_img, yolo_img, texture_img, hog_img, lac1_img, gallery_items, stats_text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
 
63
  with gr.Blocks() as demo:
@@ -74,26 +93,49 @@ with gr.Blocks() as demo:
74
  )
75
  run = gr.Button("Run Pipeline", variant="primary")
76
 
 
 
 
 
77
  with gr.Row():
78
- size_img = gr.Image(type="pil", label="Morphology Size", interactive=False)
79
  composite_img = gr.Image(type="pil", label="Composite (Segmentation Input)", interactive=False)
80
  mask_img = gr.Image(type="pil", label="Mask", interactive=False)
81
  overlay_img = gr.Image(type="pil", label="Segmentation Overlay", interactive=False)
82
- input_img = gr.Image(type="pil", label="Input Image", interactive=False)
83
 
 
84
  with gr.Row():
85
- yolo_img = gr.Image(type="pil", label="YOLO Tips", interactive=False)
86
  texture_img = gr.Image(type="pil", label="Texture LBP (Green Band)", interactive=False)
87
  hog_img = gr.Image(type="pil", label="Texture HOG (Green Band)", interactive=False)
88
  lac1_img = gr.Image(type="pil", label="Texture Lac1 (Green Band)", interactive=False)
 
 
89
 
90
  gallery = gr.Gallery(label="Vegetation Indices", columns=3, height="auto")
 
 
 
 
 
 
 
91
  stats = gr.Textbox(label="Statistics", lines=4)
92
 
93
  run.click(
94
  process,
95
  inputs=inp,
96
- outputs=[size_img, composite_img, mask_img, overlay_img, input_img, yolo_img, texture_img, hog_img, lac1_img, gallery, stats]
 
 
 
 
 
 
 
 
 
 
 
 
97
  )
98
 
99
  if __name__ == "__main__":
 
4
  from wrapper import run_pipeline_on_image
5
  from PIL import Image
6
 
7
+ ##add the process function
8
  def process(file_path):
9
  if not file_path:
10
  return None, None, None, None, None, [], ""
 
57
 
58
  stats_text = outputs.get('StatsText', '')
59
 
60
+ # Output order matches UI components defined below
61
+ # Row 1: Input image (slightly larger)
62
+ # Row 2: Composite, Mask, Overlay
63
+ # Row 3: Texture images (LBP, HOG, Lac1)
64
+ # Row 4: Vegetation indices (gallery)
65
+ # Row 5: Morphology Size and YOLO Tips
66
+ # Final: Stats table
67
+ return (
68
+ input_img,
69
+ composite,
70
+ mask,
71
+ overlay,
72
+ texture_img,
73
+ hog_img,
74
+ lac1_img,
75
+ gallery_items,
76
+ size_img,
77
+ yolo_img,
78
+ stats_text,
79
+ )
80
 
81
 
82
  with gr.Blocks() as demo:
 
93
  )
94
  run = gr.Button("Run Pipeline", variant="primary")
95
 
96
+ # Row 1: input image, slightly larger
97
+ with gr.Row():
98
+ input_img = gr.Image(type="pil", label="Input Image", interactive=False, height=380)
99
+ # Row 2: composite, mask, overlay
100
  with gr.Row():
 
101
  composite_img = gr.Image(type="pil", label="Composite (Segmentation Input)", interactive=False)
102
  mask_img = gr.Image(type="pil", label="Mask", interactive=False)
103
  overlay_img = gr.Image(type="pil", label="Segmentation Overlay", interactive=False)
 
104
 
105
+ # Row 3: textures
106
  with gr.Row():
 
107
  texture_img = gr.Image(type="pil", label="Texture LBP (Green Band)", interactive=False)
108
  hog_img = gr.Image(type="pil", label="Texture HOG (Green Band)", interactive=False)
109
  lac1_img = gr.Image(type="pil", label="Texture Lac1 (Green Band)", interactive=False)
110
+
111
+ # Row 4: vegetation indices
112
 
113
  gallery = gr.Gallery(label="Vegetation Indices", columns=3, height="auto")
114
+
115
+ # Row 5: morphology and YOLO tips
116
+ with gr.Row():
117
+ size_img = gr.Image(type="pil", label="Morphology Size", interactive=False)
118
+ yolo_img = gr.Image(type="pil", label="YOLO Tips", interactive=False)
119
+
120
+ # Final: statistics table
121
  stats = gr.Textbox(label="Statistics", lines=4)
122
 
123
  run.click(
124
  process,
125
  inputs=inp,
126
+ outputs=[
127
+ input_img,
128
+ composite_img,
129
+ mask_img,
130
+ overlay_img,
131
+ texture_img,
132
+ hog_img,
133
+ lac1_img,
134
+ gallery,
135
+ size_img,
136
+ yolo_img,
137
+ stats,
138
+ ]
139
  )
140
 
141
  if __name__ == "__main__":
requirements.txt CHANGED
@@ -1,3 +1,4 @@
 
1
  gradio
2
  pillow
3
  numpy
@@ -11,4 +12,5 @@ scipy
11
  matplotlib
12
  plantcv
13
  kornia
14
- timm
 
 
1
+ #all the requirements for the pipeline
2
  gradio
3
  pillow
4
  numpy
 
12
  matplotlib
13
  plantcv
14
  kornia
15
+ timm
16
+ ultralytics