Fahimeh Orvati Nia commited on
Commit
1c4433a
·
1 Parent(s): 8633967
Files changed (1) hide show
  1. app.py +2 -28
app.py CHANGED
@@ -7,34 +7,8 @@ from PIL import Image
7
  from itertools import product
8
 
9
  def show_preview(image):
10
- """Show pseudo-RGB composite preview."""
11
- if image is None:
12
- return None
13
-
14
- try:
15
- # Process to pseudo-RGB composite (same as pipeline does)
16
- d = image.size[0] // 2
17
- boxes = [(j, i, j + d, i + d) for i, j in product(range(0, image.height, d), range(0, image.width, d))]
18
- stack = np.stack([np.array(image.crop(box), dtype=float) for box in boxes], axis=-1)
19
- green, red, red_edge, nir = np.split(stack, 4, axis=-1)
20
-
21
- # Pseudo-RGB: (green, red_edge, red)
22
- composite = np.concatenate([green, red_edge, red], axis=-1)
23
-
24
- # Normalize to uint8
25
- composite = np.nan_to_num(composite, nan=0.0, posinf=0.0, neginf=0.0)
26
- ptp = np.ptp(composite)
27
- if ptp > 0:
28
- normalized = (composite - composite.min()) / (ptp + 1e-6) * 255
29
- else:
30
- normalized = np.zeros_like(composite)
31
- composite_uint8 = np.clip(normalized, 0, 255).astype(np.uint8)
32
-
33
- # Convert to PIL for display
34
- return Image.fromarray(composite_uint8)
35
- except Exception as e:
36
- # Fallback: return original if processing fails
37
- return image
38
 
39
  def process(image):
40
  if image is None:
 
7
  from itertools import product
8
 
9
  def show_preview(image):
10
+ """Show uploaded image as-is."""
11
+ return image
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  def process(image):
14
  if image is None: