Skip to content

Add false risk detection#39

Open
ramyacm23 wants to merge 6 commits into
Brijeshthummar02:masterfrom
ramyacm23:add-false-risk-detection
Open

Add false risk detection#39
ramyacm23 wants to merge 6 commits into
Brijeshthummar02:masterfrom
ramyacm23:add-false-risk-detection

Conversation

@ramyacm23

Copy link
Copy Markdown

📌 Related Issue

Closes #18


🧠 Description

This PR introduces a secondary safety-checking mechanism to reduce the risk of dangerous false negatives in brain tumor detection.

Previously, the model could return "No Tumor" predictions without any mechanism to identify potentially suspicious or uncertain negative outputs. This update adds uncertainty-aware review logic that flags risky predictions as UNCERTAIN_SCAN and recommends manual review.

The enhancement improves prediction reliability for edge-case MRI scans such as:

  • Small tumors
  • Low-contrast scans
  • Motion artifacts
  • Rare tumor structures
  • Out-of-distribution samples

✨ Changes Implemented

🔍 Uncertainty Estimation

  • Added Monte Carlo Dropout support during inference

  • Implemented repeated stochastic forward passes

  • Computes:

    • Tumor probability variance
    • Standard deviation
    • Model vote disagreement

⚠️ Safety Review Logic

Negative predictions are flagged when:

  • Confidence score is below 0.75
  • Tumor probability variance exceeds threshold

🩺 Prediction Metadata

Added:

  • prediction_status
  • requires_manual_review
  • safety_check

🎨 Frontend Improvements

  • Updated UI to display:

    • Review Recommended
    • UNCERTAIN_SCAN status for suspicious negative scans

🛠️ Runtime Stability Improvements

  • Missing Cloudinary configuration no longer crashes startup
  • Missing MongoDB dependency handled gracefully
  • Notebook-only imports no longer block application import
  • Application can boot even when model weights are unavailable
  • Predictions remain disabled until weights are added

📊 Example Responses

✅ Confident Negative Scan

{
  "prediction_status": "CLEAR",
  "requires_manual_review": false
}

⚠️ Suspicious Negative Scan

{
  "prediction_status": "UNCERTAIN_SCAN",
  "requires_manual_review": true
}

✅ Verification & Testing

  • Python syntax check passed for app.py
  • Python syntax check passed for utilities.py
  • Frontend JS syntax check passed for static/js/script.js
  • Flask application boots successfully
  • /api/health endpoint returns healthy status

⚠️ Notes

Full prediction testing could not be completed locally because:

  • weights.hdf5
  • weights_seg.hdf5

are not present in the current workspace.


🧪 Type of Change

  • 🐛 Bug Fix
  • ✨ New Feature
  • 🛡️ Safety Enhancement
  • 🎨 UI Improvement
  • 🛠️ Backend Improvement

@Brijeshthummar02

Copy link
Copy Markdown
Owner

@ramyacm23 display me this on local by scanning any Tumor MRI.

image

@ramyacm23

Copy link
Copy Markdown
Author

@ramyacm23 display me this on local by scanning any Tumor MRI.

image

okay

@ramyacm23

Copy link
Copy Markdown
Author

@ramyacm23 display me this on local by scanning any Tumor MRI.

image
Screenshot 2026-05-29 184254 Screenshot 2026-05-29 184311 Screenshot 2026-05-29 184302

@ramyacm23

Copy link
Copy Markdown
Author

@Brijeshthummar02 , kindly check with it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: Add False-Negative Risk Detection & Safety Alert Layer

2 participants