Fahimeh Orvati Nia
commited on
Commit
·
88a828f
1
Parent(s):
4399632
- sorghum_pipeline/pipeline.py +15 -5
sorghum_pipeline/pipeline.py
CHANGED
|
@@ -50,16 +50,26 @@ class SorghumPipeline:
|
|
| 50 |
import time
|
| 51 |
|
| 52 |
start = time.perf_counter()
|
| 53 |
-
|
| 54 |
-
# Load image
|
| 55 |
import tifffile
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
print("Debug: Uploaded image shape: ", arr.shape)
|
| 60 |
plants = {
|
| 61 |
"demo": {
|
| 62 |
-
"raw_image": (
|
| 63 |
"plant_name": "demo",
|
| 64 |
}
|
| 65 |
}
|
|
|
|
| 50 |
import time
|
| 51 |
|
| 52 |
start = time.perf_counter()
|
| 53 |
+
import imghdr
|
|
|
|
| 54 |
import tifffile
|
| 55 |
+
import cv2
|
| 56 |
+
from PIL import Image
|
| 57 |
+
|
| 58 |
+
kind = imghdr.what(single_image_path)
|
| 59 |
|
| 60 |
+
if kind == "tiff":
|
| 61 |
+
arr = tifffile.imread(single_image_path)
|
| 62 |
+
print("DEBUG loaded TIFF:", arr.shape, arr.dtype)
|
| 63 |
+
img = Image.fromarray(arr) # keep pipeline compatibility
|
| 64 |
+
else:
|
| 65 |
+
arr = cv2.imread(single_image_path, cv2.IMREAD_UNCHANGED)
|
| 66 |
+
print("DEBUG loaded non-TIFF:", arr.shape, arr.dtype)
|
| 67 |
+
img = Image.fromarray(arr)
|
| 68 |
+
|
| 69 |
print("Debug: Uploaded image shape: ", arr.shape)
|
| 70 |
plants = {
|
| 71 |
"demo": {
|
| 72 |
+
"raw_image": (img, Path(single_image_path).name),
|
| 73 |
"plant_name": "demo",
|
| 74 |
}
|
| 75 |
}
|