Fahimeh Orvati Nia commited on
Commit
ca48751
·
1 Parent(s): 34280b7
__pycache__/wrapper.cpython-312.pyc CHANGED
Binary files a/__pycache__/wrapper.cpython-312.pyc and b/__pycache__/wrapper.cpython-312.pyc differ
 
app.py CHANGED
@@ -4,6 +4,9 @@ from pathlib import Path
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:
@@ -78,6 +81,94 @@ def process(file_path):
78
  stats_text,
79
  )
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
  with gr.Blocks() as demo:
83
  gr.Markdown("# 🌿 Automated Plant Analysis Demo")
@@ -138,5 +229,24 @@ with gr.Blocks() as demo:
138
  ]
139
  )
140
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  if __name__ == "__main__":
142
  demo.launch()
 
4
  from wrapper import run_pipeline_on_image
5
  from PIL import Image
6
 
7
+ # Precomputed demo outputs inside the repo (placed by you once)
8
+ PRECOMPUTED_DIR = (Path(__file__).resolve().parent / "precomputed_demo")
9
+
10
  ##add the process function
11
  def process(file_path):
12
  if not file_path:
 
81
  stats_text,
82
  )
83
 
84
+ def _load_pil(path: Path):
85
+ try:
86
+ if not path or not path.exists():
87
+ return None
88
+ im = Image.open(path)
89
+ out = im.copy()
90
+ im.close()
91
+ return out
92
+ except Exception:
93
+ return None
94
+
95
+ def _first_existing(paths):
96
+ for p in paths:
97
+ if p and p.exists():
98
+ return p
99
+ return None
100
+
101
+ def load_precomputed():
102
+ base = PRECOMPUTED_DIR
103
+ if not base.exists():
104
+ return None, None, None, None, None, None, None, [], None, None, ""
105
+
106
+ # Common subdirs
107
+ results = base / "results"
108
+ veg = base / "Vegetation_indices_images"
109
+ tex = base / "texture_output"
110
+
111
+ input_img = _load_pil(_first_existing([
112
+ base / "input_image.png",
113
+ base / "input_image.tif",
114
+ base / "input.png",
115
+ ]))
116
+ composite = _load_pil(_first_existing([
117
+ results / "composite.png",
118
+ ]))
119
+ mask = _load_pil(results / "mask.png")
120
+ overlay = _load_pil(results / "overlay.png")
121
+
122
+ texture_img = _load_pil(_first_existing([
123
+ tex / "lbp_green.png",
124
+ tex / "lbp.png",
125
+ ]))
126
+ hog_img = _load_pil(_first_existing([
127
+ tex / "hog_green.png",
128
+ tex / "hog.png",
129
+ ]))
130
+ lac1_img = _load_pil(_first_existing([
131
+ tex / "lac1_green.png",
132
+ tex / "lacunarity.png",
133
+ ]))
134
+
135
+ # Vegetation gallery in order
136
+ veg_order = ["ndvi.png", "gndvi.png", "savi.png"]
137
+ gallery_items = []
138
+ for fname in veg_order:
139
+ p = veg / fname
140
+ img = _load_pil(p)
141
+ if img is not None:
142
+ gallery_items.append(img)
143
+
144
+ size_img = _load_pil(results / "size.size_analysis.png")
145
+ yolo_img = _load_pil(results / "yolo_tips.png")
146
+
147
+ stats_txt_path = _first_existing([
148
+ base / "stats.txt",
149
+ results / "stats.txt",
150
+ ])
151
+ stats_text = ""
152
+ if stats_txt_path and stats_txt_path.exists():
153
+ try:
154
+ stats_text = stats_txt_path.read_text()
155
+ except Exception:
156
+ stats_text = ""
157
+
158
+ return (
159
+ input_img,
160
+ composite,
161
+ mask,
162
+ overlay,
163
+ texture_img,
164
+ hog_img,
165
+ lac1_img,
166
+ gallery_items,
167
+ size_img,
168
+ yolo_img,
169
+ stats_text,
170
+ )
171
+
172
 
173
  with gr.Blocks() as demo:
174
  gr.Markdown("# 🌿 Automated Plant Analysis Demo")
 
229
  ]
230
  )
231
 
232
+ # Preload with precomputed images (no pipeline run on startup)
233
+ demo.load(
234
+ load_precomputed,
235
+ inputs=None,
236
+ outputs=[
237
+ input_img,
238
+ composite_img,
239
+ mask_img,
240
+ overlay_img,
241
+ texture_img,
242
+ hog_img,
243
+ lac1_img,
244
+ gallery,
245
+ size_img,
246
+ yolo_img,
247
+ stats,
248
+ ],
249
+ )
250
+
251
  if __name__ == "__main__":
252
  demo.launch()
plant48_frame8.tif ADDED

Git LFS Details

  • SHA256: 80ef9c9e94fe90a39d3846a2aa119e961258bee8bbc1dd8f0fa89ce427fae933
  • Pointer size: 132 Bytes
  • Size of remote file: 2.1 MB
precomputed_demo/Vegetation_indices_images/gndvi.png ADDED

Git LFS Details

  • SHA256: 26a0553234ba251e4a608d1bb6734186b25fe1729df4c8ee1a5c9203532131a1
  • Pointer size: 130 Bytes
  • Size of remote file: 95.9 kB
precomputed_demo/Vegetation_indices_images/ndvi.png ADDED

Git LFS Details

  • SHA256: 8cdffdb419c53449f16d62a6930b9d119b6c81c482de2ab4c7b8bed0778e2198
  • Pointer size: 130 Bytes
  • Size of remote file: 95.4 kB
precomputed_demo/Vegetation_indices_images/savi.png ADDED

Git LFS Details

  • SHA256: 13b42b77719ebde6e008b8f5b8039c8cd4266478ffa1205d8cf0c6cac4072885
  • Pointer size: 130 Bytes
  • Size of remote file: 88.1 kB
precomputed_demo/results/composite.png ADDED

Git LFS Details

  • SHA256: d798d9dd28ed6910ba0c3ca0db4a4e6efd8790db67cd3c62635ba0e3183c0eb6
  • Pointer size: 131 Bytes
  • Size of remote file: 410 kB
precomputed_demo/results/input_image.png ADDED

Git LFS Details

  • SHA256: 1512287352118bba54beb4982a066c5c56aea120beaf31174b3bba5493ae6d5f
  • Pointer size: 132 Bytes
  • Size of remote file: 1.49 MB
precomputed_demo/results/mask.png ADDED

Git LFS Details

  • SHA256: 046f91948e23f8016d21a9f267287bd164741b727811dbeb51e6ba812b052117
  • Pointer size: 130 Bytes
  • Size of remote file: 98.9 kB
precomputed_demo/results/overlay.png ADDED

Git LFS Details

  • SHA256: c31da4dc7d38bb5d53584365cafc12d7b4f4dc482453a5de8388938296ecf33d
  • Pointer size: 131 Bytes
  • Size of remote file: 469 kB
precomputed_demo/results/size.size_analysis.png ADDED

Git LFS Details

  • SHA256: 4212ece6cff1406fd48b088fed76d942cb6fe55dbaa4fe686c78c9f2d27978b4
  • Pointer size: 131 Bytes
  • Size of remote file: 381 kB
precomputed_demo/results/yolo_tips.png ADDED

Git LFS Details

  • SHA256: b883a9363c08df03515bfd4925dbf654fc7cdd6ed3e54bbd205db7ac1cee3e8d
  • Pointer size: 131 Bytes
  • Size of remote file: 127 kB
precomputed_demo/texture_output/hog_green.png ADDED

Git LFS Details

  • SHA256: d7069f55e3e474d9f9f3a5e53c73da1cd4187dc158608dfcb2a4153789cf5c3f
  • Pointer size: 130 Bytes
  • Size of remote file: 87.9 kB
precomputed_demo/texture_output/lac1_green.png ADDED

Git LFS Details

  • SHA256: 308bf7038752f99f9f1c110ade11df8733467cb60e514ebcf30144d54981059f
  • Pointer size: 130 Bytes
  • Size of remote file: 73 kB
precomputed_demo/texture_output/lbp_green.png ADDED

Git LFS Details

  • SHA256: 9a3bab234aa3f6a8a1b4e78129358bcdff4daf2098d2684dc81503f5156280c3
  • Pointer size: 131 Bytes
  • Size of remote file: 161 kB
requirements.txt CHANGED
@@ -14,3 +14,4 @@ plantcv
14
  kornia
15
  timm
16
  ultralytics
 
 
14
  kornia
15
  timm
16
  ultralytics
17
+ tifffile
sorghum_pipeline/__pycache__/pipeline.cpython-312.pyc CHANGED
Binary files a/sorghum_pipeline/__pycache__/pipeline.cpython-312.pyc and b/sorghum_pipeline/__pycache__/pipeline.cpython-312.pyc differ
 
sorghum_pipeline/data/__pycache__/preprocessor.cpython-312.pyc CHANGED
Binary files a/sorghum_pipeline/data/__pycache__/preprocessor.cpython-312.pyc and b/sorghum_pipeline/data/__pycache__/preprocessor.cpython-312.pyc differ
 
sorghum_pipeline/features/__pycache__/morphology.cpython-312.pyc CHANGED
Binary files a/sorghum_pipeline/features/__pycache__/morphology.cpython-312.pyc and b/sorghum_pipeline/features/__pycache__/morphology.cpython-312.pyc differ
 
sorghum_pipeline/output/__pycache__/manager.cpython-312.pyc CHANGED
Binary files a/sorghum_pipeline/output/__pycache__/manager.cpython-312.pyc and b/sorghum_pipeline/output/__pycache__/manager.cpython-312.pyc differ
 
sorghum_pipeline/segmentation/__pycache__/manager.cpython-312.pyc CHANGED
Binary files a/sorghum_pipeline/segmentation/__pycache__/manager.cpython-312.pyc and b/sorghum_pipeline/segmentation/__pycache__/manager.cpython-312.pyc differ