Fahimeh Orvati Nia commited on
Commit
2716edf
·
1 Parent(s): 591c53e
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(image):
10
- if image is None:
11
  return None, None, None, None, [], ""
12
  with tempfile.TemporaryDirectory() as tmpdir:
13
- ext = image.format.lower() if image.format else 'png'
 
 
14
  img_path = Path(tmpdir) / f"input.{ext}"
15
- image.save(img_path)
 
 
 
 
 
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("# 🌿 Sorghum Plant Analysis Demo")
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="pil", label="Upload Image")
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