Update app.py
Browse files
app.py
CHANGED
|
@@ -1,290 +1,331 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import torch
|
| 3 |
-
import torchvision.models as models
|
| 4 |
-
import torchvision.transforms as transforms
|
| 5 |
-
from PIL import Image
|
| 6 |
-
|
| 7 |
-
# Define class labels for Diabetic Retinopathy
|
| 8 |
-
class_labels = ['No DR', 'Mild', 'Moderate', 'Severe', 'Proliferative DR']
|
| 9 |
-
|
| 10 |
-
# Define image preprocessing function
|
| 11 |
-
transform = transforms.Compose([
|
| 12 |
-
transforms.Resize((224, 224)),
|
| 13 |
-
transforms.ToTensor(),
|
| 14 |
-
transforms.Normalize(mean=[0.
|
| 15 |
-
])
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
model =
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
result_text += "</
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
""
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
#
|
| 91 |
-
gr.
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
*
|
| 115 |
-
*
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
*
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
*
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
*
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
*
|
| 179 |
-
*
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
*
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
*
|
| 191 |
-
*
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
*
|
| 198 |
-
*
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
*
|
| 203 |
-
*
|
| 204 |
-
*
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
*
|
| 212 |
-
*
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
* **
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
* **
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
*
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
*
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
*
|
| 261 |
-
*
|
| 262 |
-
*
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
*
|
| 267 |
-
*
|
| 268 |
-
*
|
| 269 |
-
*
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
demo.launch()
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
import torchvision.models as models
|
| 4 |
+
import torchvision.transforms as transforms
|
| 5 |
+
from PIL import Image
|
| 6 |
+
|
| 7 |
+
# Define class labels for Diabetic Retinopathy
|
| 8 |
+
class_labels = ['No DR', 'Mild', 'Moderate', 'Severe', 'Proliferative DR']
|
| 9 |
+
|
| 10 |
+
# Define image preprocessing function with augmentation
|
| 11 |
+
transform = transforms.Compose([
|
| 12 |
+
transforms.Resize((224, 224)),
|
| 13 |
+
transforms.ToTensor(),
|
| 14 |
+
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
|
| 15 |
+
])
|
| 16 |
+
|
| 17 |
+
# Define augmented transform for training (not used in inference but shown for completeness)
|
| 18 |
+
train_transform = transforms.Compose([
|
| 19 |
+
transforms.Resize((224, 224)),
|
| 20 |
+
transforms.RandomHorizontalFlip(),
|
| 21 |
+
transforms.RandomRotation(20),
|
| 22 |
+
transforms.ColorJitter(brightness=0.1, contrast=0.1),
|
| 23 |
+
transforms.ToTensor(),
|
| 24 |
+
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
|
| 25 |
+
])
|
| 26 |
+
|
| 27 |
+
def load_model():
|
| 28 |
+
# Load a pretrained ResNet-50 model
|
| 29 |
+
model = models.resnet50(pretrained=False)
|
| 30 |
+
# Modify the final layer for 5 class classification
|
| 31 |
+
in_features = model.fc.in_features
|
| 32 |
+
model.fc = torch.nn.Linear(in_features, len(class_labels))
|
| 33 |
+
# Load the saved model weights
|
| 34 |
+
state_dict = torch.load("best_model.pt", map_location=torch.device('cpu'))
|
| 35 |
+
model.load_state_dict(state_dict)
|
| 36 |
+
model.eval()
|
| 37 |
+
return model
|
| 38 |
+
|
| 39 |
+
model = load_model()
|
| 40 |
+
|
| 41 |
+
def predict_retinopathy(image):
|
| 42 |
+
if image is None:
|
| 43 |
+
return "Please upload an image for analysis."
|
| 44 |
+
|
| 45 |
+
# Preprocess the image
|
| 46 |
+
image = transform(image).unsqueeze(0)
|
| 47 |
+
|
| 48 |
+
# Make prediction
|
| 49 |
+
with torch.no_grad():
|
| 50 |
+
output = model(image)
|
| 51 |
+
probabilities = torch.nn.functional.softmax(output[0], dim=0)
|
| 52 |
+
prediction = torch.argmax(probabilities).item()
|
| 53 |
+
|
| 54 |
+
# Create result HTML
|
| 55 |
+
result_text = "<div style='text-align: center; padding: 20px; background-color: #46a7f7; border-radius: 10px; margin: 20px 0;'>"
|
| 56 |
+
result_text += "<h2>ποΈ Analysis Results</h2>"
|
| 57 |
+
result_text += f"<h3>Primary Classification: {class_labels[prediction]} (Stage {prediction})</h3>"
|
| 58 |
+
result_text += "</div>"
|
| 59 |
+
|
| 60 |
+
result_text += "<table style='width: 100%; border-collapse: collapse; margin: 20px 0;'>"
|
| 61 |
+
result_text += "<tr><th style='padding: 10px; text-align: left; background-color: #46a7f7;'>Classification</th>"
|
| 62 |
+
result_text += "<th style='padding: 10px; text-align: right; background-color: #46a7f7;'>Confidence</th></tr>"
|
| 63 |
+
|
| 64 |
+
for i, label in enumerate(class_labels):
|
| 65 |
+
prob = probabilities[i] * 100
|
| 66 |
+
color = f"hsl({120 - prob}, 70%, 50%)"
|
| 67 |
+
result_text += f"<tr style='border-bottom: 1px solid #dee2e6;'>"
|
| 68 |
+
result_text += f"<td style='padding: 10px;'>{label} (Stage {i})</td>"
|
| 69 |
+
result_text += f"<td style='padding: 10px; text-align: right;'>"
|
| 70 |
+
result_text += f"<span style='color: {color}; font-weight: bold;'>{prob:.2f}%</span></td></tr>"
|
| 71 |
+
|
| 72 |
+
result_text += "</table>"
|
| 73 |
+
return result_text
|
| 74 |
+
|
| 75 |
+
# Custom CSS for enhanced styling
|
| 76 |
+
custom_css = """
|
| 77 |
+
footer {display: none !important;}
|
| 78 |
+
.container {max-width: 1000px; margin: auto; padding: 20px;}
|
| 79 |
+
.header {text-align: center; margin-bottom: 40px;}
|
| 80 |
+
.main-title {color: #2c3e50; font-size: 2.5em; margin-bottom: 20px;}
|
| 81 |
+
.subtitle {color: #34495e; font-size: 1.2em; line-height: 1.6;}
|
| 82 |
+
.input-section {background: #f8f9fa; padding: 30px; border-radius: 15px; margin: 20px 0;}
|
| 83 |
+
.disclaimer {background: #fff3cd; color: #856404; padding: 15px; border-radius: 8px; margin-top: 30px;}
|
| 84 |
+
.info-box {background: #e3f2fd; padding: 20px; border-radius: 10px; margin: 15px 0;}
|
| 85 |
+
.warning-box {background: #ffebee; padding: 20px; border-radius: 10px; margin: 15px 0;}
|
| 86 |
+
"""
|
| 87 |
+
|
| 88 |
+
# Create Gradio UI with enhanced styling
|
| 89 |
+
with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
|
| 90 |
+
# Header Section
|
| 91 |
+
gr.HTML("""
|
| 92 |
+
<div class="header">
|
| 93 |
+
<h1 class="main-title">ποΈ Welcome to EarlyMed Diabetic Retinopathy Scanner</h1>
|
| 94 |
+
</div>
|
| 95 |
+
""")
|
| 96 |
+
|
| 97 |
+
# Introduction
|
| 98 |
+
gr.Markdown("""
|
| 99 |
+
Welcome to EarlyMedβan initiative by our team at VIT-AP University dedicated to empowering you with early health insights.
|
| 100 |
+
Leveraging AI for early detection, our mission is simple: "Early Detection, Smarter Decision."
|
| 101 |
+
Our Diabetic Retinopathy detection project uses a powerful ResNet-50 deep learning model to help you stay informed before visiting a doctor.
|
| 102 |
+
""")
|
| 103 |
+
|
| 104 |
+
# What is Diabetic Retinopathy Section
|
| 105 |
+
gr.Markdown("""
|
| 106 |
+
## π Understanding Diabetic Retinopathy (DR)
|
| 107 |
+
|
| 108 |
+
Diabetic Retinopathy is a diabetes complication that affects the eyes. It's caused by damage to the blood vessels
|
| 109 |
+
in the tissue at the back of the eye (retina). Poorly controlled blood sugar is a risk factor.
|
| 110 |
+
Early detection can prevent vision loss.
|
| 111 |
+
|
| 112 |
+
### Primary Symptoms of DR:
|
| 113 |
+
|
| 114 |
+
* **Blurred or fluctuating vision**
|
| 115 |
+
* **Impaired color vision**
|
| 116 |
+
* **Dark or empty areas in your vision**
|
| 117 |
+
* **Floaters (spots or dark strings floating in your vision)**
|
| 118 |
+
* **Vision loss**
|
| 119 |
+
* **Difficulty seeing at night**
|
| 120 |
+
|
| 121 |
+
### Risk Factors:
|
| 122 |
+
|
| 123 |
+
* Duration of diabetes
|
| 124 |
+
* Poor control of blood sugar level
|
| 125 |
+
* High blood pressure
|
| 126 |
+
* High cholesterol
|
| 127 |
+
* Pregnancy
|
| 128 |
+
* Tobacco use
|
| 129 |
+
* Being of Hispanic, Native American, or African heritage
|
| 130 |
+
""")
|
| 131 |
+
|
| 132 |
+
# Image Upload Section
|
| 133 |
+
with gr.Row():
|
| 134 |
+
with gr.Column():
|
| 135 |
+
gr.Markdown("### π€ Upload Retinal Image")
|
| 136 |
+
image_input = gr.Image(
|
| 137 |
+
type="pil",
|
| 138 |
+
label="Upload a Fundus (Retinal) Image",
|
| 139 |
+
elem_classes="input-section"
|
| 140 |
+
)
|
| 141 |
+
submit_btn = gr.Button(
|
| 142 |
+
"π Analyze Image",
|
| 143 |
+
variant="primary",
|
| 144 |
+
size="lg"
|
| 145 |
+
)
|
| 146 |
+
|
| 147 |
+
# Results Section
|
| 148 |
+
diagnosis_output = gr.HTML()
|
| 149 |
+
|
| 150 |
+
submit_btn.click(
|
| 151 |
+
fn=predict_retinopathy,
|
| 152 |
+
inputs=image_input,
|
| 153 |
+
outputs=diagnosis_output
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
# Understanding Stages
|
| 157 |
+
gr.Markdown("""
|
| 158 |
+
## π Understanding DR Stages and Required Actions
|
| 159 |
+
|
| 160 |
+
### No DR (Stage 0)
|
| 161 |
+
**What it means:**
|
| 162 |
+
* No visible signs of diabetic retinopathy
|
| 163 |
+
* Normal retinal appearance
|
| 164 |
+
* Blood vessels appear healthy
|
| 165 |
+
|
| 166 |
+
**Required Actions:**
|
| 167 |
+
* Continue regular eye check-ups (yearly for diabetic patients)
|
| 168 |
+
* Maintain blood sugar control
|
| 169 |
+
* Follow healthy lifestyle recommendations
|
| 170 |
+
|
| 171 |
+
### Mild DR (Stage 1)
|
| 172 |
+
**What it means:**
|
| 173 |
+
* Small areas of balloon-like swelling in the retina's tiny blood vessels
|
| 174 |
+
* Microaneurysms detected
|
| 175 |
+
* Early changes that don't typically affect vision
|
| 176 |
+
|
| 177 |
+
**Required Actions:**
|
| 178 |
+
* Schedule follow-up with an ophthalmologist within 6-12 months
|
| 179 |
+
* Improve blood sugar control
|
| 180 |
+
* Monitor blood pressure and cholesterol
|
| 181 |
+
* Consider more frequent eye screenings
|
| 182 |
+
|
| 183 |
+
### Moderate DR (Stage 2)
|
| 184 |
+
**What it means:**
|
| 185 |
+
* More extensive damage to blood vessels
|
| 186 |
+
* Blood vessels may begin to leak
|
| 187 |
+
* Some retinal swelling might be present
|
| 188 |
+
|
| 189 |
+
**Required Actions:**
|
| 190 |
+
* Consult with an ophthalmologist within 3-6 months
|
| 191 |
+
* Possible referral to a retina specialist
|
| 192 |
+
* Strict blood sugar, blood pressure, and cholesterol management
|
| 193 |
+
* Discuss potential early interventions
|
| 194 |
+
|
| 195 |
+
### Severe DR (Stage 3)
|
| 196 |
+
**What it means:**
|
| 197 |
+
* Significant blockage of blood vessels
|
| 198 |
+
* Retina being deprived of proper blood supply
|
| 199 |
+
* Increased risk for vision-threatening complications
|
| 200 |
+
|
| 201 |
+
**Required Actions:**
|
| 202 |
+
* Urgent consultation with a retina specialist
|
| 203 |
+
* Possible laser treatment consideration
|
| 204 |
+
* Intensive monitoring of diabetes management
|
| 205 |
+
* Prepare for possible treatments
|
| 206 |
+
|
| 207 |
+
### Proliferative DR (Stage 4)
|
| 208 |
+
**What it means:**
|
| 209 |
+
* Advanced disease with new abnormal blood vessels growing
|
| 210 |
+
* High risk of vitreous hemorrhage
|
| 211 |
+
* Potential retinal detachment
|
| 212 |
+
* Significant threat to vision
|
| 213 |
+
|
| 214 |
+
**Required Actions:**
|
| 215 |
+
* Immediate specialist intervention
|
| 216 |
+
* Likely need for laser treatment or surgery
|
| 217 |
+
* Aggressive management of all contributing factors
|
| 218 |
+
* Regular monitoring post-treatment
|
| 219 |
+
""")
|
| 220 |
+
|
| 221 |
+
# Technical Details
|
| 222 |
+
gr.Markdown("""
|
| 223 |
+
## π¬ How Our AI Works
|
| 224 |
+
|
| 225 |
+
* **Image Preprocessing:**
|
| 226 |
+
* Resizing to 224Γ224 resolution
|
| 227 |
+
* Normalization for better CNN performance
|
| 228 |
+
|
| 229 |
+
* **Deep Learning Model:**
|
| 230 |
+
* Uses ResNet-50, a powerful convolutional neural network
|
| 231 |
+
* Pretrained on ImageNet for feature extraction
|
| 232 |
+
* Final layer modified to classify 5 DR severity levels
|
| 233 |
+
|
| 234 |
+
* **Training Process:**
|
| 235 |
+
* Trained with image augmentation (random flips, rotations, color adjustments)
|
| 236 |
+
* Optimized using CrossEntropy Loss & Adam Optimizer
|
| 237 |
+
* Hyperparameter tuning with grid search for optimal learning rate, batch size, and epochs
|
| 238 |
+
|
| 239 |
+
* **Classification:**
|
| 240 |
+
Based on the extracted features, the AI classifies the image into one of five categories:
|
| 241 |
+
* **No DR (Stage 0)**
|
| 242 |
+
* **Mild (Stage 1)**
|
| 243 |
+
* **Moderate (Stage 2)**
|
| 244 |
+
* **Severe (Stage 3)**
|
| 245 |
+
* **Proliferative DR (Stage 4)**
|
| 246 |
+
|
| 247 |
+
## π― Why It Is Reliable
|
| 248 |
+
|
| 249 |
+
* **Robust Training:** Trained on thousands of diverse retinal images, our model has learned to recognize even the faintest indicators of DR.
|
| 250 |
+
* **Evaluation Metrics:** Model performance evaluated using accuracy, precision, recall, F1-score, and ROC AUC.
|
| 251 |
+
* **Rigorous Validation:** Extensive testing and validation protocols ensure the model's predictions are accurate and trustworthy.
|
| 252 |
+
* **Cutting-Edge Technology:** Utilizing state-of-the-art ResNet-50 architecture, our AI leverages modern deep learning techniques to provide early and reliable health insights.
|
| 253 |
+
""")
|
| 254 |
+
|
| 255 |
+
# Treatment and Support Information
|
| 256 |
+
gr.Markdown("""
|
| 257 |
+
## π Treatment Approaches
|
| 258 |
+
|
| 259 |
+
### Standard Treatment Options:
|
| 260 |
+
* **Laser Treatment (Photocoagulation):** Seals or destroys leaking blood vessels
|
| 261 |
+
* **Anti-VEGF Injections:** Reduces growth of abnormal blood vessels
|
| 262 |
+
* **Vitrectomy:** Surgical removal of vitreous gel and blood
|
| 263 |
+
* **Corticosteroid Injections:** Reduces inflammation and swelling
|
| 264 |
+
|
| 265 |
+
### Supportive Care:
|
| 266 |
+
* Blood sugar control
|
| 267 |
+
* Blood pressure management
|
| 268 |
+
* Regular eye examinations
|
| 269 |
+
* Vision rehabilitation if needed
|
| 270 |
+
* Psychological support
|
| 271 |
+
|
| 272 |
+
### Long-term Considerations:
|
| 273 |
+
* Lifestyle modifications
|
| 274 |
+
* Regular monitoring of diabetes
|
| 275 |
+
* Adherence to medication regimens
|
| 276 |
+
* Regular ophthalmologic follow-ups
|
| 277 |
+
""")
|
| 278 |
+
|
| 279 |
+
# Prevention and Early Detection
|
| 280 |
+
gr.Markdown("""
|
| 281 |
+
## π‘οΈ Prevention and Early Detection
|
| 282 |
+
|
| 283 |
+
### Risk Reduction Strategies:
|
| 284 |
+
* Maintaining optimal blood sugar levels
|
| 285 |
+
* Controlling blood pressure
|
| 286 |
+
* Managing cholesterol levels
|
| 287 |
+
* Regular exercise
|
| 288 |
+
* Healthy diet low in refined carbohydrates
|
| 289 |
+
* Avoiding tobacco use
|
| 290 |
+
|
| 291 |
+
### When to Seek Medical Attention:
|
| 292 |
+
* Sudden vision changes
|
| 293 |
+
* Eye pain or redness
|
| 294 |
+
* Floaters or spots in vision
|
| 295 |
+
* Blurred vision
|
| 296 |
+
* Any noticeable change in visual acuity
|
| 297 |
+
""")
|
| 298 |
+
|
| 299 |
+
# Future Improvements Section
|
| 300 |
+
gr.Markdown("""
|
| 301 |
+
## π Future Improvements
|
| 302 |
+
|
| 303 |
+
Our team is continuously working to improve the Retinopathy Scanner with:
|
| 304 |
+
|
| 305 |
+
* **Larger Dataset Integration:** Expanding our training data for better generalization
|
| 306 |
+
* **Advanced Architectures:** Exploring EfficientNet and Vision Transformers alongside ResNet-50
|
| 307 |
+
* **Mobile Deployment:** Making the scanner accessible on smartphones for wider reach
|
| 308 |
+
* **Multi-modal Integration:** Combining fundus images with OCT scans for more comprehensive diagnosis
|
| 309 |
+
* **Explainable AI Features:** Providing visual explanations for why certain predictions are made
|
| 310 |
+
""")
|
| 311 |
+
|
| 312 |
+
# Disclaimer
|
| 313 |
+
gr.Markdown("""
|
| 314 |
+
---
|
| 315 |
+
### β οΈ Important Medical Disclaimer
|
| 316 |
+
|
| 317 |
+
This AI-powered tool is designed to assist in the early detection of Diabetic Retinopathy (DR) through
|
| 318 |
+
retinal image analysis. We strongly urge users to consult an ophthalmologist for appropriate medical
|
| 319 |
+
guidance after getting the diagnosis.
|
| 320 |
+
|
| 321 |
+
**Please Note:**
|
| 322 |
+
* Results should be verified by healthcare professionals
|
| 323 |
+
* Consult a qualified ophthalmologist for proper treatment
|
| 324 |
+
|
| 325 |
+
This initiative is developed by our team at VIT-AP University with the goal of empowering individuals to be more
|
| 326 |
+
aware of their eye health before visiting a doctor. Our mission is to leverage AI for early detection and better
|
| 327 |
+
healthcare awareness.
|
| 328 |
+
""")
|
| 329 |
+
|
| 330 |
+
if __name__ == "__main__":
|
| 331 |
demo.launch()
|