import argparse import json import pickle import sys from pathlib import Path import gradio as gr import numpy as np import pandas as pd import torch import torch.nn as nn import torch.nn.functional as F # Allow imports from ./deepseenet without requiring it to be a package. PROJECT_ROOT = Path(__file__).resolve().parent DEEPSEENET_DIR = PROJECT_ROOT / "deepseenet" sys.path.insert(0, str(DEEPSEENET_DIR)) from augmentations import get_val_transforms # noqa: E402 from model import DeepSeeNet # noqa: E402 N_CLASSES = { "DRUS": 3, "PIG": 2, } LABELS = { "DRUS": ["small_none", "medium", "large"], "PIG": ["no_pigment", "pigment"], } APP_CSS = """ #terms-overlay { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 32px; background: rgba(255, 255, 255, 0.72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); } #terms-card { width: min(800px, calc(100vw - 64px)); max-height: 86vh; overflow-y: auto; padding: 24px 28px; border: 1px solid #d9d9df; border-radius: 8px; background: #f3f3f5; box-shadow: 0 12px 36px rgba(0, 0, 0, 0.12); color: #1f2933; } #terms-card h1 { margin-top: 0; font-size: 1.55rem; } #terms-card h2 { margin-top: 1.35rem; font-size: 1.15rem; } #terms-card p, #terms-card ul { font-size: 0.95rem; line-height: 1.55; margin-left: 1.1rem; } #terms-card li { margin-bottom: 0.35rem; } #acknowledge-btn { width: 100%; margin-top: 16px; padding: 10px 14px; border: none; border-radius: 6px; background: #2563eb; color: white; font-weight: 600; cursor: pointer; } #acknowledge-btn:hover { background: #1d4ed8; } """ ACKNOWLEDGEMENT_TEXT = "I acknowledge and continue" TERMS_OVERLAY_HTML = f"""
This demo is a modernized research implementation based on the original AMD risk prediction work. It is provided solely for research, educational, and reproducibility purposes.
This Gradio demo and its associated model outputs are provided for research, educational, and reproducibility purposes only, and are not intended for clinical diagnosis, treatment, screening, triage, patient management, or any other medical decision-making purpose.
This demo implementation has not been clinically validated for routine patient care and has not been reviewed, cleared, or approved by any regulatory authority, including the U.S. Food and Drug Administration.
Do not upload protected health information, personally identifiable information, or patient data unless you have the necessary rights, permissions, and safeguards to do so.
By using this demo, you acknowledge that:
This project is a modernized reimplementation of the DeepSeeNet AMD risk prediction work. Please cite the original publication when using this project:
Peng Y, Keenan TD, Chen Q, Agrón E, Allot A, Wong WT, Chew EY, Lu Z. Predicting risk of late age-related macular degeneration using deep learning. NPJ Digital Medicine. 2020 Aug 27;3(1):111.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.