Fahimeh Orvati Nia commited on
Commit
95cc07c
·
1 Parent(s): b989947
Files changed (1) hide show
  1. app.py +19 -0
app.py CHANGED
@@ -5,6 +5,7 @@ from wrapper import run_pipeline_on_image
5
  import numpy as np
6
  from PIL import Image
7
  from itertools import product
 
8
 
9
  def process(image_path):
10
  if not image_path:
@@ -15,8 +16,26 @@ def process(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)
 
5
  import numpy as np
6
  from PIL import Image
7
  from itertools import product
8
+ import logging
9
 
10
  def process(image_path):
11
  if not image_path:
 
16
  ext = src.suffix.lstrip('.') or 'tif'
17
  img_path = Path(tmpdir) / f"input.{ext}"
18
  try:
19
+ try:
20
+ # Log original file stats
21
+ size_bytes = src.stat().st_size if src.exists() else 0
22
+ try:
23
+ with Image.open(src) as im_src:
24
+ frames = getattr(im_src, 'n_frames', 1)
25
+ logging.info(f"Uploaded file: path={src}, size_bytes={size_bytes}, mode={im_src.mode}, size={im_src.size}, frames={frames}")
26
+ except Exception:
27
+ logging.info(f"Uploaded file: path={src}, size_bytes={size_bytes} (PIL open failed)")
28
+ except Exception:
29
+ pass
30
  img_bytes = src.read_bytes()
31
  img_path.write_bytes(img_bytes)
32
+ # Log copied file as read by PIL
33
+ try:
34
+ with Image.open(img_path) as im_tmp:
35
+ frames_tmp = getattr(im_tmp, 'n_frames', 1)
36
+ logging.info(f"Temp input: path={img_path}, mode={im_tmp.mode}, size={im_tmp.size}, frames={frames_tmp}")
37
+ except Exception:
38
+ logging.info(f"Temp input: path={img_path} (PIL open failed)")
39
  except Exception:
40
  # Fallback: save via PIL if direct copy fails
41
  Image.open(src).save(img_path)