Fahimeh Orvati Nia
commited on
Commit
·
2716edf
1
Parent(s):
591c53e
update
Browse files
app.py
CHANGED
|
@@ -6,13 +6,20 @@ import numpy as np
|
|
| 6 |
from PIL import Image
|
| 7 |
from itertools import product
|
| 8 |
|
| 9 |
-
def process(
|
| 10 |
-
if
|
| 11 |
return None, None, None, None, [], ""
|
| 12 |
with tempfile.TemporaryDirectory() as tmpdir:
|
| 13 |
-
|
|
|
|
|
|
|
| 14 |
img_path = Path(tmpdir) / f"input.{ext}"
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
outputs = run_pipeline_on_image(str(img_path), tmpdir, save_artifacts=True)
|
| 17 |
|
| 18 |
def load_pil(path_str):
|
|
@@ -40,12 +47,12 @@ def process(image):
|
|
| 40 |
return size_img, composite, mask, overlay, texture_img, gallery_items, stats_text
|
| 41 |
|
| 42 |
with gr.Blocks() as demo:
|
| 43 |
-
gr.Markdown("# 🌿
|
| 44 |
gr.Markdown("Upload a sorghum plant image to compute and visualize composite, mask, overlay, texture (LBP), vegetation indices, and statistics.")
|
| 45 |
|
| 46 |
with gr.Row():
|
| 47 |
with gr.Column():
|
| 48 |
-
inp = gr.Image(type="
|
| 49 |
run = gr.Button("Run Pipeline", variant="primary")
|
| 50 |
|
| 51 |
with gr.Row():
|
|
|
|
| 6 |
from PIL import Image
|
| 7 |
from itertools import product
|
| 8 |
|
| 9 |
+
def process(image_path):
|
| 10 |
+
if not image_path:
|
| 11 |
return None, None, None, None, [], ""
|
| 12 |
with tempfile.TemporaryDirectory() as tmpdir:
|
| 13 |
+
# Copy uploaded file as-is to preserve format/bit-depth
|
| 14 |
+
src = Path(image_path)
|
| 15 |
+
ext = src.suffix.lstrip('.') or 'tif'
|
| 16 |
img_path = Path(tmpdir) / f"input.{ext}"
|
| 17 |
+
try:
|
| 18 |
+
img_bytes = src.read_bytes()
|
| 19 |
+
img_path.write_bytes(img_bytes)
|
| 20 |
+
except Exception:
|
| 21 |
+
# Fallback: save via PIL if direct copy fails
|
| 22 |
+
Image.open(src).save(img_path)
|
| 23 |
outputs = run_pipeline_on_image(str(img_path), tmpdir, save_artifacts=True)
|
| 24 |
|
| 25 |
def load_pil(path_str):
|
|
|
|
| 47 |
return size_img, composite, mask, overlay, texture_img, gallery_items, stats_text
|
| 48 |
|
| 49 |
with gr.Blocks() as demo:
|
| 50 |
+
gr.Markdown("# 🌿 Automated Plant Analysis Demo")
|
| 51 |
gr.Markdown("Upload a sorghum plant image to compute and visualize composite, mask, overlay, texture (LBP), vegetation indices, and statistics.")
|
| 52 |
|
| 53 |
with gr.Row():
|
| 54 |
with gr.Column():
|
| 55 |
+
inp = gr.Image(type="filepath", label="Upload Image")
|
| 56 |
run = gr.Button("Run Pipeline", variant="primary")
|
| 57 |
|
| 58 |
with gr.Row():
|
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
|
|
|