Fahimeh Orvati Nia
commited on
Commit
·
ca48751
1
Parent(s):
34280b7
update
Browse files- __pycache__/wrapper.cpython-312.pyc +0 -0
- app.py +110 -0
- plant48_frame8.tif +3 -0
- precomputed_demo/Vegetation_indices_images/gndvi.png +3 -0
- precomputed_demo/Vegetation_indices_images/ndvi.png +3 -0
- precomputed_demo/Vegetation_indices_images/savi.png +3 -0
- precomputed_demo/results/composite.png +3 -0
- precomputed_demo/results/input_image.png +3 -0
- precomputed_demo/results/mask.png +3 -0
- precomputed_demo/results/overlay.png +3 -0
- precomputed_demo/results/size.size_analysis.png +3 -0
- precomputed_demo/results/yolo_tips.png +3 -0
- precomputed_demo/texture_output/hog_green.png +3 -0
- precomputed_demo/texture_output/lac1_green.png +3 -0
- precomputed_demo/texture_output/lbp_green.png +3 -0
- requirements.txt +1 -0
- sorghum_pipeline/__pycache__/pipeline.cpython-312.pyc +0 -0
- sorghum_pipeline/data/__pycache__/preprocessor.cpython-312.pyc +0 -0
- sorghum_pipeline/features/__pycache__/morphology.cpython-312.pyc +0 -0
- sorghum_pipeline/output/__pycache__/manager.cpython-312.pyc +0 -0
- sorghum_pipeline/segmentation/__pycache__/manager.cpython-312.pyc +0 -0
__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
|
precomputed_demo/Vegetation_indices_images/gndvi.png
ADDED
|
Git LFS Details
|
precomputed_demo/Vegetation_indices_images/ndvi.png
ADDED
|
Git LFS Details
|
precomputed_demo/Vegetation_indices_images/savi.png
ADDED
|
Git LFS Details
|
precomputed_demo/results/composite.png
ADDED
|
Git LFS Details
|
precomputed_demo/results/input_image.png
ADDED
|
Git LFS Details
|
precomputed_demo/results/mask.png
ADDED
|
Git LFS Details
|
precomputed_demo/results/overlay.png
ADDED
|
Git LFS Details
|
precomputed_demo/results/size.size_analysis.png
ADDED
|
Git LFS Details
|
precomputed_demo/results/yolo_tips.png
ADDED
|
Git LFS Details
|
precomputed_demo/texture_output/hog_green.png
ADDED
|
Git LFS Details
|
precomputed_demo/texture_output/lac1_green.png
ADDED
|
Git LFS Details
|
precomputed_demo/texture_output/lbp_green.png
ADDED
|
Git LFS Details
|
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
|
|
|