Rodiyah commited on
Commit
ba282ce
·
verified ·
1 Parent(s): e473c8a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -19
app.py CHANGED
@@ -18,9 +18,6 @@ device = torch.device("cpu")
18
  save_dir = "/home/user/app/saved_predictions"
19
  os.makedirs(save_dir, exist_ok=True)
20
 
21
- # Placeholder image for invalid uploads
22
- invalid_img = Image.new("RGB", (224, 224), color=(200, 200, 200))
23
-
24
  # -----------------------
25
  # Load model
26
  # -----------------------
@@ -42,22 +39,6 @@ transform = transforms.Compose([
42
  [0.229, 0.224, 0.225])
43
  ])
44
 
45
- # -----------------------
46
- # Helper: basic fundus check
47
- # -----------------------
48
- def looks_like_fundus(image):
49
- """
50
- Basic heuristic to check if an image is likely a retinal fundus scan.
51
- Fundus images tend to have a bright circular region (retina)
52
- with a darker background.
53
- """
54
- img = np.array(image.convert("L").resize((224, 224)))
55
- thresh = img > 40 # bright region
56
- white_ratio = np.sum(thresh) / img.size
57
-
58
- # Fundus images usually occupy ~40–75% of the area
59
- return 0.40 < white_ratio < 0.75
60
-
61
  # -----------------------
62
  # Predict and save
63
  # -----------------------
 
18
  save_dir = "/home/user/app/saved_predictions"
19
  os.makedirs(save_dir, exist_ok=True)
20
 
 
 
 
21
  # -----------------------
22
  # Load model
23
  # -----------------------
 
39
  [0.229, 0.224, 0.225])
40
  ])
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  # -----------------------
43
  # Predict and save
44
  # -----------------------