Rodiyah commited on
Commit
71694f1
·
verified ·
1 Parent(s): 62979ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -41,8 +41,11 @@ transform = transforms.Compose([
41
  # Predict and save
42
  def predict_retinopathy(image):
43
  # Validate image
44
- if not looks_like_fundus(image):
45
- return None, "❌ Please upload a valid retinal (fundus) scan."
 
 
 
46
 
47
  timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
48
  img = image.convert("RGB").resize((224, 224))
@@ -67,7 +70,10 @@ def predict_retinopathy(image):
67
  filename = f"{timestamp}_{label}_{confidence:.2f}.png"
68
  cam_pil.save(os.path.join(save_dir, filename))
69
 
70
- return cam_pil, f"{label} (Confidence: {confidence:.2f})"
 
 
 
71
 
72
  # Gradio app
73
  gr.Interface(
 
41
  # Predict and save
42
  def predict_retinopathy(image):
43
  # Validate image
44
+ if not looks_like_fundus(image):
45
+ return (
46
+ invalid_img,
47
+ "❌ Invalid image detected.\n\nPlease upload a *retinal fundus scan* for accurate Diabetic Retinopathy assessment."
48
+ )
49
 
50
  timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
51
  img = image.convert("RGB").resize((224, 224))
 
70
  filename = f"{timestamp}_{label}_{confidence:.2f}.png"
71
  cam_pil.save(os.path.join(save_dir, filename))
72
 
73
+ return (
74
+ cam_pil,
75
+ f"{label} (Confidence: {confidence:.2f})"
76
+ )
77
 
78
  # Gradio app
79
  gr.Interface(