-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathocular.html
253 lines (228 loc) · 10.4 KB
/
ocular.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ocular Scan - MED.ai</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
<style>
body {
font-family: 'Roboto', sans-serif;
background-color: #f8f9fa;
}
.navbar {
background-color: #007bff;
}
.navbar-brand {
font-weight: bold;
font-size: 24px;
}
.scan-container {
background-color: white;
border-radius: 10px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
padding: 30px;
margin-top: 50px;
}
.confidence-bar {
background-color: #e9ecef;
border-radius: 5px;
height: 25px;
margin-bottom: 10px;
}
.confidence-fill {
background-color: #0056b3;
height: 100%;
border-radius: 5px;
color: white;
text-align: right;
padding-right: 5px;
line-height: 25px;
transition: width 0.5s ease-in-out;
}
#uploadForm {
margin-bottom: 20px;
}
.image-preview {
max-width: 100%;
height: 200px;
object-fit: cover;
border-radius: 5px;
margin-top: 10px;
}
footer {
background-color: #0056b3;
color: white;
padding: 20px 0;
margin-top: 50px;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark">
<div class="container">
<a href="#" class="logo" style="position: relative; display: inline-block;">
<img src="https://www.freepnglogos.com/uploads/medical-logo-png-14.png" width="65" height="50" alt="Doclab home" style="margin-left: -40px;">
<span style="position: absolute; top: 50%; left: 130%; transform: translate(-50%, -50%); color: white; font-weight: bold; font-family: 'Arial', sans-serif;">Medbot</span>
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link" href="/">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/about">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/contact">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-md-8 offset-md-2">
<div class="scan-container">
<h2 class="text-center mb-4">Ocular Scan Analysis</h2>
<p class="lead text-center mb-4">Upload images of both eyes for our AI to analyze and provide insights.</p>
<form id="uploadForm" action="/predict" method="post" enctype="multipart/form-data">
<div class="mb-3">
<label for="left_image" class="form-label">Left Eye Image:</label>
<input type="file" class="form-control" id="left_image" name="left_image" accept="image/*" required>
<img id="leftPreview" class="image-preview mt-2" src="#" alt="Left eye preview" style="display:none;">
</div>
<div class="mb-3">
<label for="right_image" class="form-label">Right Eye Image:</label>
<input type="file" class="form-control" id="right_image" name="right_image" accept="image/*" required>
<img id="rightPreview" class="image-preview mt-2" src="#" alt="Right eye preview" style="display:none;">
</div>
<div class="text-center">
<button type="submit" class="btn btn-primary">
<i class="fas fa-eye me-2"></i>Analyze Eyes
</button>
</div>
</form>
<div id="loadingIndicator" class="text-center mt-4" style="display:none;">
<div class="spinner-border text-primary" role="status">
<span class="visually-hidden">Loading...</span>
</div>
<p class="mt-2">Analyzing images. Please wait...</p>
</div>
<div id="resultContainer" class="mt-4" style="display:none;">
<h3 class="mb-3">Analysis Results</h3>
<div id="results"></div>
</div>
</div>
</div>
</div>
</div>
<footer class="mt-5">
<div class="container">
<div class="row">
<div class="col-md-4">
<h5>About MED.ai</h5>
<p>MED.ai is a cutting-edge healthcare assistant powered by artificial intelligence, designed to revolutionize the way we approach medical diagnoses and patient care.</p>
</div>
<div class="col-md-4">
<h5>Quick Links</h5>
<ul class="list-unstyled">
<li><a href="/" class="text-white">Home</a></li>
<li><a href="/about" class="text-white">About</a></li>
<li><a href="/contact" class="text-white">Contact</a></li>
<li><a href="#" class="text-white">Privacy Policy</a></li>
</ul>
</div>
<div class="col-md-4">
<h5>Connect with Us</h5>
<ul class="list-unstyled">
<li><a href="https://github.com/Vinit710/MEDAI" target="_blank" class="text-white"><i class="fab fa-github me-2"></i>GitHub</a></li>
<li><a href="#" class="text-white"><i class="fab fa-twitter me-2"></i>Twitter</a></li>
<li><a href="#" class="text-white"><i class="fab fa-linkedin me-2"></i>LinkedIn</a></li>
</ul>
</div>
</div>
<hr class="bg-light">
<div class="row">
<div class="col-md-12 text-center">
<p>© 2024 MED.ai. All rights reserved.</p>
</div>
</div>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script>
function previewImage(input, previewId) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
document.getElementById(previewId).style.display = 'block';
document.getElementById(previewId).src = e.target.result;
}
reader.readAsDataURL(input.files[0]);
}
}
document.getElementById('left_image').addEventListener('change', function() {
previewImage(this, 'leftPreview');
});
document.getElementById('right_image').addEventListener('change', function() {
previewImage(this, 'rightPreview');
});
document.getElementById('uploadForm').onsubmit = async function(event) {
event.preventDefault();
const loadingIndicator = document.getElementById('loadingIndicator');
const resultContainer = document.getElementById('resultContainer');
loadingIndicator.style.display = 'block';
resultContainer.style.display = 'none';
const formData = new FormData(this);
try {
const response = await fetch('/predict', {
method: 'POST',
body: formData
});
if (!response.ok) {
throw new Error('Network response was not ok');
}
const result = await response.json();
displayResults(result.data[0].confidences);
} catch (error) {
console.error('Error:', error);
alert('An error occurred. Please try again.');
} finally {
loadingIndicator.style.display = 'none';
}
};
function displayResults(confidences) {
const resultContainer = document.getElementById('resultContainer');
const resultsDiv = document.getElementById('results');
resultsDiv.innerHTML = '';
confidences.forEach(item => {
const row = document.createElement('div');
row.className = 'mb-3';
const confidenceLabel = document.createElement('p');
confidenceLabel.className = 'mb-1';
confidenceLabel.innerHTML = `<strong>${item.label}:</strong>`;
const confidenceBar = document.createElement('div');
confidenceBar.className = 'confidence-bar';
const confidenceFill = document.createElement('div');
confidenceFill.className = 'confidence-fill';
confidenceFill.style.width = '0%';
confidenceFill.innerText = '0%';
confidenceBar.appendChild(confidenceFill);
row.appendChild(confidenceLabel);
row.appendChild(confidenceBar);
resultsDiv.appendChild(row);
setTimeout(() => {
confidenceFill.style.width = (item.confidence * 100) + '%';
confidenceFill.innerText = (item.confidence * 100).toFixed(2) + '%';
}, 100);
});
resultContainer.style.display = 'block';
}
</script>
</body>
</html>