import argparse from pathlib import Path import gradio as gr import numpy as np import torch import torch.nn.functional as F from augmentations import get_val_transforms from model import DeepSeeNet N_CLASSES = { "ADVAMD": 2, "DRUS": 3, "PIG": 2, } LABELS = { "ADVAMD": ["no_late_amd", "late_amd"], "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(720px, 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; } """ TERMS_AND_CONDITIONS_MD = """ # DeepSeeNet Demo — Research Use Only This demo is a modernized research implementation based on the original DeepSeeNet work. It is provided solely for research, educational, and reproducibility purposes. ## Not for Clinical Use 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. ## Data Privacy Do not upload protected health information, personally identifiable information, or patient data unless you have the necessary rights, permissions, and safeguards to do so. ## User Responsibility By using this demo, you acknowledge that: - You understand this demo is for research and educational purposes only. - You will not use the outputs for diagnosis, treatment, screening, triage, or clinical decision-making. - You are responsible for how you interpret and use any results generated by the demo. - You will not upload protected health information or identifiable patient data unless you are authorized to do so. ## Attribution This project is a modernized reimplementation of DeepSeeNet. Please cite the original DeepSeeNet publication when using this project: Peng Y, Dharssi S, Chen Q, Keenan TD, Agrón E, Wong WT, Chew EY, Lu Z. DeepSeeNet: a deep learning model for automated classification of patient-based age-related macular degeneration severity from color fundus photographs. Ophthalmology. 2019 Apr 1;126(4):565-75. ## License and Warranty Disclaimer 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. """ ACKNOWLEDGEMENT_TEXT = "I acknowledge and continue" TERMS_OVERLAY_HTML = f"""
This demo is a modernized research implementation based on the original DeepSeeNet 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:
Please cite the original DeepSeeNet publication when using this project:
Peng Y, Dharssi S, Chen Q, Keenan TD, Agrón E, Wong WT, Chew EY, Lu Z. DeepSeeNet: a deep learning model for automated classification of patient-based age-related macular degeneration severity from color fundus photographs. Ophthalmology. 2019 Apr 1;126(4):565-75.
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.