MahatirTusher commited on
Commit
08b3f85
Β·
verified Β·
1 Parent(s): c297d97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +330 -289
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.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])
15
- ])
16
-
17
- def load_model():
18
- model = models.vit_b_16(weights=None)
19
- if isinstance(model.heads, torch.nn.Sequential):
20
- in_features = model.heads[0].in_features
21
- else:
22
- in_features = model.heads.in_features
23
- model.heads = torch.nn.Linear(in_features, len(class_labels))
24
- state_dict = torch.load("best_model.pt", map_location=torch.device('cpu'))
25
- model.load_state_dict(state_dict)
26
- model.eval()
27
- return model
28
-
29
- model = load_model()
30
-
31
- def predict_retinopathy(image):
32
- if image is None:
33
- return "Please upload an image for analysis."
34
-
35
- image = transform(image).unsqueeze(0)
36
- with torch.no_grad():
37
- output = model(image)
38
- probabilities = torch.nn.functional.softmax(output[0], dim=0)
39
- prediction = torch.argmax(probabilities).item()
40
-
41
- result_text = "<div style='text-align: center; padding: 20px; background-color: #46a7f7; border-radius: 10px; margin: 20px 0;'>"
42
- result_text += "<h2>πŸ‘οΈ Analysis Results</h2>"
43
- result_text += f"<h3>Primary Classification: {class_labels[prediction]}</h3>"
44
- result_text += "</div>"
45
-
46
- result_text += "<table style='width: 100%; border-collapse: collapse; margin: 20px 0;'>"
47
- result_text += "<tr><th style='padding: 10px; text-align: left; background-color: #46a7f7;'>Classification</th>"
48
- result_text += "<th style='padding: 10px; text-align: right; background-color: #46a7f7;'>Confidence</th></tr>"
49
-
50
- for i, label in enumerate(class_labels):
51
- prob = probabilities[i] * 100
52
- color = f"hsl({120 - prob}, 70%, 50%)"
53
- result_text += f"<tr style='border-bottom: 1px solid #dee2e6;'>"
54
- result_text += f"<td style='padding: 10px;'>{label}</td>"
55
- result_text += f"<td style='padding: 10px; text-align: right;'>"
56
- result_text += f"<span style='color: {color}; font-weight: bold;'>{prob:.2f}%</span></td></tr>"
57
-
58
- result_text += "</table>"
59
- return result_text
60
-
61
- # Custom CSS for enhanced styling
62
- custom_css = """
63
- footer {display: none !important;}
64
- .container {max-width: 1000px; margin: auto; padding: 20px;}
65
- .header {text-align: center; margin-bottom: 40px;}
66
- .main-title {color: #2c3e50; font-size: 2.5em; margin-bottom: 20px;}
67
- .subtitle {color: #34495e; font-size: 1.2em; line-height: 1.6;}
68
- .input-section {background: #f8f9fa; padding: 30px; border-radius: 15px; margin: 20px 0;}
69
- .disclaimer {background: #fff3cd; color: #856404; padding: 15px; border-radius: 8px; margin-top: 30px;}
70
- .info-box {background: #e3f2fd; padding: 20px; border-radius: 10px; margin: 15px 0;}
71
- .warning-box {background: #ffebee; padding: 20px; border-radius: 10px; margin: 15px 0;}
72
- """
73
-
74
- # Create Gradio UI with enhanced styling
75
- with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
76
- # Header Section
77
- gr.HTML("""
78
- <div class="header">
79
- <h1 class="main-title">πŸ‘οΈ Welcome to EarlyMed Diabetic Retinopathy Scanner</h1>
80
- </div>
81
- """)
82
-
83
- # Introduction
84
- gr.Markdown("""
85
- Welcome to EarlyMedβ€”an initiative by our team at VIT-AP University dedicated to empowering you with early health insights.
86
- Leveraging AI for early detection, our mission is simple: "Early Detection, Smarter Decision."
87
- Our Diabetic Retinopathy detection project is one of our key efforts to help you stay informed before visiting a doctor.
88
- """)
89
-
90
- # What is Diabetic Retinopathy Section
91
- gr.Markdown("""
92
- ## πŸ” Understanding Diabetic Retinopathy (DR)
93
-
94
- Diabetic Retinopathy is a diabetes complication that affects the eyes. It's caused by damage to the blood vessels
95
- in the tissue at the back of the eye (retina). Poorly controlled blood sugar is a risk factor.
96
- Early detection can prevent vision loss.
97
-
98
- ### Primary Symptoms of DR:
99
-
100
- * **Blurred or fluctuating vision**
101
- * **Impaired color vision**
102
- * **Dark or empty areas in your vision**
103
- * **Floaters (spots or dark strings floating in your vision)**
104
- * **Vision loss**
105
- * **Difficulty seeing at night**
106
-
107
- ### Risk Factors:
108
-
109
- * Duration of diabetes
110
- * Poor control of blood sugar level
111
- * High blood pressure
112
- * High cholesterol
113
- * Pregnancy
114
- * Tobacco use
115
- * Being of Hispanic, Native American, or African heritage
116
- """)
117
-
118
- # Image Upload Section
119
- with gr.Row():
120
- with gr.Column():
121
- gr.Markdown("### πŸ“€ Upload Retinal Image")
122
- image_input = gr.Image(
123
- type="pil",
124
- label="Upload a Fundus (Retinal) Image",
125
- elem_classes="input-section"
126
- )
127
- submit_btn = gr.Button(
128
- "πŸ” Analyze Image",
129
- variant="primary",
130
- size="lg"
131
- )
132
-
133
- # Results Section
134
- diagnosis_output = gr.HTML()
135
-
136
- submit_btn.click(
137
- fn=predict_retinopathy,
138
- inputs=image_input,
139
- outputs=diagnosis_output
140
- )
141
-
142
- # Understanding Stages
143
- gr.Markdown("""
144
- ## πŸ“Š Understanding DR Stages and Required Actions
145
-
146
- ### No DR Stage
147
- **What it means:**
148
- * No visible signs of diabetic retinopathy
149
- * Normal retinal appearance
150
- * Blood vessels appear healthy
151
-
152
- **Required Actions:**
153
- * Continue regular eye check-ups (yearly for diabetic patients)
154
- * Maintain blood sugar control
155
- * Follow healthy lifestyle recommendations
156
-
157
- ### Mild Stage
158
- **What it means:**
159
- * Small areas of balloon-like swelling in the retina's tiny blood vessels
160
- * Microaneurysms detected
161
- * Early changes that don't typically affect vision
162
-
163
- **Required Actions:**
164
- * Schedule follow-up with an ophthalmologist within 6-12 months
165
- * Improve blood sugar control
166
- * Monitor blood pressure and cholesterol
167
- * Consider more frequent eye screenings
168
-
169
- ### Moderate Stage
170
- **What it means:**
171
- * More extensive damage to blood vessels
172
- * Blood vessels may begin to leak
173
- * Some retinal swelling might be present
174
-
175
- **Required Actions:**
176
- * Consult with an ophthalmologist within 3-6 months
177
- * Possible referral to a retina specialist
178
- * Strict blood sugar, blood pressure, and cholesterol management
179
- * Discuss potential early interventions
180
-
181
- ### Severe Stage
182
- **What it means:**
183
- * Significant blockage of blood vessels
184
- * Retina being deprived of proper blood supply
185
- * Increased risk for vision-threatening complications
186
-
187
- **Required Actions:**
188
- * Urgent consultation with a retina specialist
189
- * Possible laser treatment consideration
190
- * Intensive monitoring of diabetes management
191
- * Prepare for possible treatments
192
-
193
- ### Proliferative DR Stage
194
- **What it means:**
195
- * Advanced disease with new abnormal blood vessels growing
196
- * High risk of vitreous hemorrhage
197
- * Potential retinal detachment
198
- * Significant threat to vision
199
-
200
- **Required Actions:**
201
- * Immediate specialist intervention
202
- * Likely need for laser treatment or surgery
203
- * Aggressive management of all contributing factors
204
- * Regular monitoring post-treatment
205
- """)
206
-
207
- # Technical Details
208
- gr.Markdown("""
209
- ## πŸ”¬ How Our AI Works
210
-
211
- * **Image Processing:** Fundus (retinal) images are resized and normalized to match the model's input specifications.
212
- * **Feature Extraction:** Our advanced Vision Transformer scans the image to detect subtle changes in blood vessels, microaneurysms, exudates, and other retinal features.
213
- * **Classification:** Based on the extracted features, the AI classifies the image into one of five categories:
214
- * **No DR**
215
- * **Mild**
216
- * **Moderate**
217
- * **Severe**
218
- * **Proliferative DR**
219
-
220
- ## 🎯 Why It Is Reliable
221
-
222
- * **Robust Training:** Trained on thousands of diverse retinal images, our model has learned to recognize even the faintest indicators of DR.
223
- * **Rigorous Validation:** Extensive testing and validation protocols ensure the model's predictions are accurate and trustworthy.
224
- * **Continuous Improvement:** Regular updates and refinements keep the model up-to-date with the latest ophthalmological insights and technological advancements.
225
- * **Cutting-Edge Technology:** Utilizing state-of-the-art Vision Transformer architecture, our AI leverages modern deep learning techniques to provide early and reliable health insights.
226
- """)
227
-
228
- # Treatment and Support Information
229
- gr.Markdown("""
230
- ## πŸ’‰ Treatment Approaches
231
-
232
- ### Standard Treatment Options:
233
- * **Laser Treatment (Photocoagulation):** Seals or destroys leaking blood vessels
234
- * **Anti-VEGF Injections:** Reduces growth of abnormal blood vessels
235
- * **Vitrectomy:** Surgical removal of vitreous gel and blood
236
- * **Corticosteroid Injections:** Reduces inflammation and swelling
237
-
238
- ### Supportive Care:
239
- * Blood sugar control
240
- * Blood pressure management
241
- * Regular eye examinations
242
- * Vision rehabilitation if needed
243
- * Psychological support
244
-
245
- ### Long-term Considerations:
246
- * Lifestyle modifications
247
- * Regular monitoring of diabetes
248
- * Adherence to medication regimens
249
- * Regular ophthalmologic follow-ups
250
- """)
251
-
252
- # Prevention and Early Detection
253
- gr.Markdown("""
254
- ## πŸ›‘οΈ Prevention and Early Detection
255
-
256
- ### Risk Reduction Strategies:
257
- * Maintaining optimal blood sugar levels
258
- * Controlling blood pressure
259
- * Managing cholesterol levels
260
- * Regular exercise
261
- * Healthy diet low in refined carbohydrates
262
- * Avoiding tobacco use
263
-
264
- ### When to Seek Medical Attention:
265
- * Sudden vision changes
266
- * Eye pain or redness
267
- * Floaters or spots in vision
268
- * Blurred vision
269
- * Any noticeable change in visual acuity
270
- """)
271
- # Disclaimer
272
- gr.Markdown("""
273
- ---
274
- ### ⚠️ Important Medical Disclaimer
275
-
276
- This AI-powered tool is designed to assist in the early detection of Diabetic Retinopathy (DR) through
277
- retinal image analysis. We strongly urge users to consult an ophthalmologist for appropriate medical
278
- guidance after getting the diagnosis.
279
-
280
- **Please Note:**
281
- * Results should be verified by healthcare professionals
282
- * Consult a qualified ophthalmologist for proper treatment
283
-
284
- This initiative is developed by our team at VIT-AP University with the goal of empowering individuals to be more
285
- aware of their eye health before visiting a doctor. Our mission is to leverage AI for early detection and better
286
- healthcare awareness.
287
- """)
288
-
289
- if __name__ == "__main__":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()