Spaces:
Runtime error
Runtime error
Update templates/upload.html
Browse files- templates/upload.html +4 -88
templates/upload.html
CHANGED
|
@@ -145,6 +145,9 @@
|
|
| 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>
|
|
@@ -161,91 +164,4 @@
|
|
| 161 |
const placeholderContent = document.getElementById('placeholderContent');
|
| 162 |
const dropZone = document.getElementById('dropZone');
|
| 163 |
const scanLine = document.getElementById('scan-line');
|
| 164 |
-
const pFill = document.getElementById('
|
| 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>
|
|
|
|
| 145 |
<i class="fa-solid fa-microchip"></i> START AI DIAGNOSIS
|
| 146 |
</button>
|
| 147 |
|
| 148 |
+
<button class="analyze-btn" style="background: #1e293b; color: #00f2fe; margin-top: 15px;" onclick="window.location.href='/database'">
|
| 149 |
+
<i class="fa-solid fa-database"></i> VIEW PATIENT DATABASE
|
| 150 |
+
</button>
|
| 151 |
<div class="loading-container" id="loadingArea">
|
| 152 |
<div class="status-text-container">
|
| 153 |
<span style="color: #00f2fe;">Processing Image...</span>
|
|
|
|
| 164 |
const placeholderContent = document.getElementById('placeholderContent');
|
| 165 |
const dropZone = document.getElementById('dropZone');
|
| 166 |
const scanLine = document.getElementById('scan-line');
|
| 167 |
+
const pFill = document.getElementById('p
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|