Spaces:
Runtime error
Runtime error
Update templates/upload.html
Browse files- templates/upload.html +250 -247
templates/upload.html
CHANGED
|
@@ -1,248 +1,251 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>RetiCheck | AI Diagnosis Portal</title>
|
| 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 |
-
@keyframes
|
| 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 |
-
</div>
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
const
|
| 161 |
-
const
|
| 162 |
-
const
|
| 163 |
-
const
|
| 164 |
-
const
|
| 165 |
-
const
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
const
|
| 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 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>RetiCheck | AI Diagnosis Portal</title>
|
| 7 |
+
|
| 8 |
+
<link rel="manifest" href="/static/manifest.json">
|
| 9 |
+
<meta name="theme-color" content="#38bdf8">
|
| 10 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 11 |
+
<style>
|
| 12 |
+
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Poppins', sans-serif; }
|
| 13 |
+
|
| 14 |
+
body {
|
| 15 |
+
background: radial-gradient(circle at top left, #1e293b, #0f172a);
|
| 16 |
+
min-height: 100vh;
|
| 17 |
+
color: white;
|
| 18 |
+
display: flex; flex-direction: column; align-items: center; justify-content: center;
|
| 19 |
+
padding: 30px;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
.header { text-align: center; margin-bottom: 30px; animation: fadeInDown 1s ease; }
|
| 23 |
+
.logo { font-size: 36px; font-weight: 800; letter-spacing: 1px; }
|
| 24 |
+
.logo span { background: linear-gradient(90deg, #00f2fe, #4facfe); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
|
| 25 |
+
.subtitle { color: #94a3b8; font-size: 16px; margin-top: 5px; }
|
| 26 |
+
|
| 27 |
+
.glass-card {
|
| 28 |
+
background: rgba(255, 255, 255, 0.03);
|
| 29 |
+
backdrop-filter: blur(20px);
|
| 30 |
+
-webkit-backdrop-filter: blur(20px);
|
| 31 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 32 |
+
border-radius: 30px;
|
| 33 |
+
padding: 50px 40px;
|
| 34 |
+
width: 100%;
|
| 35 |
+
max-width: 550px;
|
| 36 |
+
text-align: center;
|
| 37 |
+
box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
|
| 38 |
+
animation: fadeInUp 1s ease;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/* PREMIUM UPLOAD ZONE */
|
| 42 |
+
.upload-zone {
|
| 43 |
+
width: 100%;
|
| 44 |
+
height: 320px;
|
| 45 |
+
background: rgba(0,0,0,0.2);
|
| 46 |
+
border-radius: 25px;
|
| 47 |
+
margin-bottom: 30px;
|
| 48 |
+
position: relative;
|
| 49 |
+
overflow: hidden;
|
| 50 |
+
border: 2px dashed #334155;
|
| 51 |
+
display: flex;
|
| 52 |
+
justify-content: center;
|
| 53 |
+
align-items: center;
|
| 54 |
+
cursor: pointer;
|
| 55 |
+
transition: all 0.3s ease;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
.upload-zone:hover {
|
| 59 |
+
border-color: #00f2fe;
|
| 60 |
+
background: rgba(0, 242, 254, 0.05);
|
| 61 |
+
transform: translateY(-5px);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
.upload-placeholder {
|
| 65 |
+
text-align: center;
|
| 66 |
+
transition: 0.3s;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
.upload-icon {
|
| 70 |
+
font-size: 60px;
|
| 71 |
+
color: #00f2fe;
|
| 72 |
+
margin-bottom: 20px;
|
| 73 |
+
animation: float 3s ease-in-out infinite;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
.upload-text { color: #cbd5e1; font-size: 18px; font-weight: 600; }
|
| 77 |
+
.upload-subtext { color: #64748b; font-size: 14px; margin-top: 8px; }
|
| 78 |
+
|
| 79 |
+
#preview-img {
|
| 80 |
+
width: 100%; height: 100%; object-fit: cover; display: none; border-radius: 25px;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
/* Scanning Animation */
|
| 84 |
+
.scan-line {
|
| 85 |
+
position: absolute; top: 0; width: 100%; height: 4px;
|
| 86 |
+
background: #00f2fe; box-shadow: 0 0 30px #00f2fe, 0 0 10px #00f2fe;
|
| 87 |
+
display: none; z-index: 5;
|
| 88 |
+
}
|
| 89 |
+
@keyframes scanning { 0% { top: 0; opacity: 0; } 50% { opacity: 1; } 100% { top: 100%; opacity: 0; } }
|
| 90 |
+
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
|
| 91 |
+
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
|
| 92 |
+
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
.analyze-btn {
|
| 96 |
+
width: 100%;
|
| 97 |
+
padding: 20px;
|
| 98 |
+
background: linear-gradient(90deg, #00f2fe, #4facfe);
|
| 99 |
+
color: #0f172a;
|
| 100 |
+
border: none;
|
| 101 |
+
border-radius: 15px;
|
| 102 |
+
font-size: 18px;
|
| 103 |
+
font-weight: 800;
|
| 104 |
+
letter-spacing: 1px;
|
| 105 |
+
cursor: pointer;
|
| 106 |
+
box-shadow: 0 10px 30px -10px rgba(0, 242, 254, 0.5);
|
| 107 |
+
transition: 0.3s;
|
| 108 |
+
display: flex; justify-content: center; align-items: center; gap: 10px;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
.analyze-btn:hover { transform: translateY(-3px); box-shadow: 0 15px 35px -10px rgba(0, 242, 254, 0.6); }
|
| 112 |
+
.analyze-btn:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
|
| 113 |
+
|
| 114 |
+
/* Loading Progress */
|
| 115 |
+
.loading-container { display: none; margin-top: 30px; }
|
| 116 |
+
.progress-bar { background: #1e293b; height: 8px; border-radius: 10px; margin-top: 15px; overflow: hidden; position: relative; }
|
| 117 |
+
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #00f2fe, #4facfe); transition: width 0.2s ease-in-out; border-radius: 10px; }
|
| 118 |
+
.status-text-container { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; }
|
| 119 |
+
</style>
|
| 120 |
+
</head>
|
| 121 |
+
<body>
|
| 122 |
+
|
| 123 |
+
<div class="header">
|
| 124 |
+
<div class="logo">RetiCheck <span>AI</span></div>
|
| 125 |
+
<p class="subtitle">Advanced Retinal Disease Screening Portal</p>
|
| 126 |
+
</div>
|
| 127 |
+
|
| 128 |
+
<div class="glass-card">
|
| 129 |
+
|
| 130 |
+
<div class="upload-zone" id="dropZone" onclick="document.getElementById('fileInput').click()">
|
| 131 |
+
<div id="scan-line" class="scan-line"></div>
|
| 132 |
+
|
| 133 |
+
<div class="upload-placeholder" id="placeholderContent">
|
| 134 |
+
<i class="fa-solid fa-cloud-arrow-up upload-icon"></i>
|
| 135 |
+
<p class="upload-text">Click to Upload Retinal Scan</p>
|
| 136 |
+
<p class="upload-subtext">Supports JPG, PNG (Max 10MB)</p>
|
| 137 |
+
</div>
|
| 138 |
+
|
| 139 |
+
<img id="preview-img">
|
| 140 |
+
</div>
|
| 141 |
+
|
| 142 |
+
<input type="file" id="fileInput" hidden accept="image/*" onchange="previewFile()">
|
| 143 |
+
|
| 144 |
+
<button class="analyze-btn" id="analyzeBtn" onclick="runFullAnalysis()">
|
| 145 |
+
<i class="fa-solid fa-microchip"></i> START AI DIAGNOSIS
|
| 146 |
+
</button>
|
| 147 |
+
|
| 148 |
+
<div class="loading-container" id="loadingArea">
|
| 149 |
+
<div class="status-text-container">
|
| 150 |
+
<span style="color: #00f2fe;">Processing Image...</span>
|
| 151 |
+
<span id="progressPercent" style="color: #94a3b8;">0%</span>
|
| 152 |
+
</div>
|
| 153 |
+
<div class="progress-bar">
|
| 154 |
+
<div class="progress-fill" id="pFill"></div>
|
| 155 |
+
</div>
|
| 156 |
+
</div>
|
| 157 |
+
</div>
|
| 158 |
+
|
| 159 |
+
<script>
|
| 160 |
+
const previewImg = document.getElementById('preview-img');
|
| 161 |
+
const placeholderContent = document.getElementById('placeholderContent');
|
| 162 |
+
const dropZone = document.getElementById('dropZone');
|
| 163 |
+
const scanLine = document.getElementById('scan-line');
|
| 164 |
+
const pFill = document.getElementById('pFill');
|
| 165 |
+
const progressPercent = document.getElementById('progressPercent');
|
| 166 |
+
const loadingArea = document.getElementById('loadingArea');
|
| 167 |
+
const analyzeBtn = document.getElementById('analyzeBtn');
|
| 168 |
+
const fileInput = document.getElementById('fileInput');
|
| 169 |
+
|
| 170 |
+
// 1. File Preview Logic (Clean & Simple)
|
| 171 |
+
function previewFile() {
|
| 172 |
+
const file = fileInput.files[0];
|
| 173 |
+
if (!file) return;
|
| 174 |
+
|
| 175 |
+
const reader = new FileReader();
|
| 176 |
+
reader.onloadend = () => {
|
| 177 |
+
placeholderContent.style.display = 'none'; // Hide icon
|
| 178 |
+
previewImg.style.display = 'block'; // Show image
|
| 179 |
+
previewImg.src = reader.result;
|
| 180 |
+
// Add a cool border glow when image is loaded
|
| 181 |
+
dropZone.style.borderColor = '#00f2fe';
|
| 182 |
+
dropZone.style.boxShadow = '0 0 20px rgba(0, 242, 254, 0.2)';
|
| 183 |
+
}
|
| 184 |
+
reader.readAsDataURL(file);
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
// 2. The Analysis Logic (Removed Camera parts)
|
| 188 |
+
async function runFullAnalysis() {
|
| 189 |
+
if (!fileInput.files.length) {
|
| 190 |
+
alert("⚠️ Please upload a retinal scan image first.");
|
| 191 |
+
// Shake animation for feedback
|
| 192 |
+
dropZone.style.animation = 'shake 0.5s';
|
| 193 |
+
setTimeout(() => dropZone.style.animation = '', 500);
|
| 194 |
+
return;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
// Start UI Animations
|
| 198 |
+
loadingArea.style.display = 'block';
|
| 199 |
+
scanLine.style.display = 'block';
|
| 200 |
+
scanLine.style.animation = 'scanning 1.5s infinite ease-in-out';
|
| 201 |
+
analyzeBtn.innerHTML = '<i class="fa-solid fa-circle-notch fa-spin"></i> Analyzing...';
|
| 202 |
+
analyzeBtn.disabled = true;
|
| 203 |
+
dropZone.style.pointerEvents = 'none'; // Prevent double upload during process
|
| 204 |
+
|
| 205 |
+
// Fake Progress Animation
|
| 206 |
+
let progress = 0;
|
| 207 |
+
let progressInterval = setInterval(() => {
|
| 208 |
+
if(progress < 95) {
|
| 209 |
+
progress += Math.floor(Math.random() * 5) + 1;
|
| 210 |
+
if(progress > 95) progress = 95;
|
| 211 |
+
pFill.style.width = progress + "%";
|
| 212 |
+
progressPercent.innerText = progress + "%";
|
| 213 |
+
}
|
| 214 |
+
}, 150);
|
| 215 |
+
|
| 216 |
+
// Prepare Data
|
| 217 |
+
const formData = new FormData();
|
| 218 |
+
formData.append('image', fileInput.files[0]);
|
| 219 |
+
|
| 220 |
+
try {
|
| 221 |
+
// Send to Python Backend
|
| 222 |
+
let response = await fetch('/predict', { method: 'POST', body: formData });
|
| 223 |
+
let data = await response.json();
|
| 224 |
+
|
| 225 |
+
// Save result to memory
|
| 226 |
+
localStorage.setItem('aiResult', JSON.stringify(data));
|
| 227 |
+
|
| 228 |
+
// Complete Animation
|
| 229 |
+
clearInterval(progressInterval);
|
| 230 |
+
pFill.style.width = "100%";
|
| 231 |
+
progressPercent.innerText = "100% - Complete";
|
| 232 |
+
|
| 233 |
+
setTimeout(() => { window.location.href = "/result"; }, 800);
|
| 234 |
+
|
| 235 |
+
} catch (error) {
|
| 236 |
+
clearInterval(progressInterval);
|
| 237 |
+
alert("❌ Error connecting to AI Server! Is Flask running?");
|
| 238 |
+
// Reset UI
|
| 239 |
+
analyzeBtn.innerHTML = '<i class="fa-solid fa-microchip"></i> START AI DIAGNOSIS';
|
| 240 |
+
analyzeBtn.disabled = false;
|
| 241 |
+
loadingArea.style.display = 'none';
|
| 242 |
+
scanLine.style.display = 'none';
|
| 243 |
+
dropZone.style.pointerEvents = 'auto';
|
| 244 |
+
}
|
| 245 |
+
}
|
| 246 |
+
</script>
|
| 247 |
+
<style>
|
| 248 |
+
@keyframes shake { 0% { transform: translateX(0); } 25% { transform: translateX(-10px); } 50% { transform: translateX(10px); } 75% { transform: translateX(-10px); } 100% { transform: translateX(0); } }
|
| 249 |
+
</style>
|
| 250 |
+
</body>
|
| 251 |
</html>
|