-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
359 lines (316 loc) · 12.5 KB
/
Copy pathindex.html
File metadata and controls
359 lines (316 loc) · 12.5 KB
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
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DermaPath-AI | Advanced Analysis</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
<style>
/* Updated Refined Color Palettes */
:root {
/* Light Mode: Clinical, Trustworthy Blue */
--bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
--container-bg: rgba(255, 255, 255, 0.9);
--text-main: #1e293b;
--text-sub: #64748b;
--accent: #2563eb;
--border: #e2e8f0;
--card-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05);
--scan-overlay: rgba(37, 99, 235, 0.05);
--btn-hover: #1d4ed8;
}
.dark-mode {
/* Dark Mode: Deep Midnight & Neon Accents */
--bg-gradient: radial-gradient(circle at top right, #1e293b, #0f172a);
--container-bg: rgba(30, 41, 59, 0.8);
--text-main: #f8fafc;
--text-sub: #94a3b8;
--accent: #38bdf8;
--border: #334155;
--card-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
--scan-overlay: rgba(56, 189, 248, 0.1);
--btn-hover: #0ea5e9;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: 'Poppins', sans-serif;
}
body {
background: var(--bg-gradient);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.5s ease;
padding: 20px;
}
.container {
background: var(--container-bg);
color: var(--text-main);
width: 100%;
max-width: 460px;
padding: 40px;
border-radius: 30px;
box-shadow: var(--card-shadow);
border: 1px solid var(--border);
text-align: center;
position: relative;
backdrop-filter: blur(12px);
transition: transform 0.3s ease;
animation: fadeIn 0.8s ease-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
.theme-toggle {
position: absolute;
top: 25px;
right: 25px;
cursor: pointer;
width: 45px;
height: 45px;
background: var(--border);
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
font-size: 20px;
transition: all 0.3s ease;
}
.theme-toggle:hover {
transform: scale(1.1);
background: var(--accent);
color: white;
}
h1 { font-size: 28px; margin-bottom: 5px; color: var(--accent); font-weight: 600; }
p { font-size: 14px; color: var(--text-sub); margin-bottom: 30px; letter-spacing: 0.5px; }
.upload-box {
border: 2px dashed var(--accent);
padding: 40px 20px;
border-radius: 20px;
background: var(--scan-overlay);
cursor: pointer;
position: relative;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
margin-bottom: 20px;
}
.upload-box:hover {
border-style: solid;
background: rgba(102, 126, 234, 0.1);
transform: translateY(-3px);
}
#imageInput { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-icon { font-size: 45px; margin-bottom: 15px; display: block; opacity: 0.8; }
#preview {
width: 100%;
border-radius: 16px;
display: none;
margin-bottom: 20px;
box-shadow: 0 8px 16px rgba(0,0,0,0.1);
border: 3px solid white;
}
button {
background: var(--accent);
color: white;
border: none;
width: 100%;
padding: 18px;
border-radius: 15px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
transition: all 0.3s ease;
}
button:hover {
background: var(--btn-hover);
transform: translateY(-2px);
box-shadow: 0 15px 20px -5px rgba(37, 99, 235, 0.4);
}
/* Scan Animation */
.analyzing {
position: relative;
overflow: hidden;
}
.analyzing::after {
content: "";
position: absolute;
top: -100%;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(to bottom, transparent, var(--accent), transparent);
opacity: 0.5;
animation: scanLine 2s infinite linear;
}
@keyframes scanLine {
0% { top: -100%; }
100% { top: 100%; }
}
.loader {
display: none;
width: 35px;
height: 35px;
border: 4px solid var(--border);
border-top: 4px solid var(--accent);
border-radius: 50%;
margin: 25px auto;
animation: spin 1s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }
/* Result Visuals */
.result-card {
background: var(--border);
border-radius: 18px;
text-align: left;
padding: 20px;
margin-top: 25px;
animation: slideUp 0.5s ease-out;
}
.result-safe {
background: rgba(16, 185, 129, 0.12) !important;
border-left: 5px solid #10b981;
}
.result-danger {
background: rgba(244, 63, 94, 0.12) !important;
border-left: 5px solid #f43f5e;
}
.conf-container {
width: 100%;
height: 10px;
background: rgba(0,0,0,0.1);
border-radius: 10px;
margin: 15px 0;
overflow: hidden;
}
.conf-bar { height: 100%; width: 0%; transition: width 1.5s cubic-bezier(0.1, 0, 0.2, 1); background: var(--accent); }
.disclaimer {
font-size: 11px;
color: var(--text-sub);
margin-top: 35px;
line-height: 1.6;
opacity: 0.7;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
</style>
</head>
<body>
<div class="container">
<div class="theme-toggle" onclick="toggleTheme()" id="themeBtn">
<span id="theme-icon">🌙</span>
</div>
<h1>🩺 DermaPath AI</h1>
<p>Precision Deep Learning Diagnostics</p>
<div class="upload-box" id="dropzone">
<span class="upload-icon">📸</span>
<span id="file-label" style="font-weight: 500;">Click or Drag Skin Lesion Photo</span>
<input type="file" id="imageInput" accept="image/*">
</div>
<div id="preview-container" style="position: relative;">
<img id="preview" alt="Scan Preview">
</div>
<button id="analyzeBtn" onclick="performAnalysis()">Launch AI Scan</button>
<div class="loader" id="loader"></div>
<div id="result"></div>
<div class="disclaimer">
<strong>Academic Project:</strong> Results generated by neural networks are for educational purposes only. Always consult a certified Dermatologist for medical concerns.
</div>
</div>
<script>
function toggleTheme() {
const body = document.body;
const icon = document.getElementById("theme-icon");
body.classList.toggle("dark-mode");
const isDark = body.classList.contains("dark-mode");
icon.innerText = isDark ? "☀️" : "🌙";
localStorage.setItem("theme", isDark ? "dark" : "light");
}
// Persist Theme
if (localStorage.getItem("theme") === "dark") {
document.body.classList.add("dark-mode");
document.getElementById("theme-icon").innerText = "☀️";
}
// Image Preview Handling
document.getElementById("imageInput").addEventListener("change", function() {
const file = this.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
const preview = document.getElementById("preview");
preview.src = e.target.result;
preview.style.display = "block";
document.getElementById("file-label").innerText = "Image Selected: " + file.name;
document.getElementById("dropzone").style.padding = "15px";
}
reader.readAsDataURL(file);
}
});
function performAnalysis() {
const fileInput = document.getElementById("imageInput");
const file = fileInput.files[0];
const previewImg = document.getElementById("preview");
const loader = document.getElementById("loader");
const resultDiv = document.getElementById("result");
if (!file) {
alert("Please upload a lesion image first.");
return;
}
// UI State: Loading
loader.style.display = "block";
resultDiv.innerHTML = "";
previewImg.parentElement.classList.add("analyzing");
const formData = new FormData();
formData.append("image", file);
fetch("https://dermapath-ai.onrender.com/predict", {
method: "POST",
body: formData
})
.then(response => response.json())
.then(data => {
loader.style.display = "none";
previewImg.parentElement.classList.remove("analyzing");
const predictionText = data.result.toLowerCase();
let statusClass = "result-card";
let accentColor = "#2563eb"; // default blue
if (predictionText.includes("malignant") || predictionText.includes("cancer")) {
statusClass += " result-danger";
accentColor = "#f43f5e";
} else if (predictionText.includes("benign") || predictionText.includes("normal")) {
statusClass += " result-safe";
accentColor = "#10b981";
}
const confidence = (data.confidence * 100).toFixed(1);
resultDiv.innerHTML = `
<div class="${statusClass}">
<div style="font-size: 11px; text-transform: uppercase; letter-spacing: 2px; font-weight: bold; opacity: 0.8;">Analysis Result</div>
<div style="font-size: 22px; font-weight: 600; margin: 10px 0;">${data.result}</div>
<div style="display: flex; justify-content: space-between; font-size: 14px;">
<span>AI Confidence</span>
<span style="font-weight: 600;">${confidence}%</span>
</div>
<div class="conf-container">
<div class="conf-bar" id="bar" style="background: ${accentColor}"></div>
</div>
<div style="font-size: 13px; line-height: 1.5; font-style: italic; opacity: 0.9;">
${predictionText.includes("malignant") ?
"🚩 High Priority: This lesion shows irregular patterns; please consult a dermatologist immediately." :
"✅ Low Risk: Analysis suggests a benign lesion; continue to monitor the area monthly for any changes."}
</div>
</div>
`;
setTimeout(() => {
document.getElementById('bar').style.width = confidence + "%";
}, 100);
})
.catch(err => {
loader.style.display = "none";
previewImg.parentElement.classList.remove("analyzing");
alert("Analysis failed. Please check your internet connection or try again in a moment.");
});
}
</script>
</body>
</html>