Spaces:
Build error
Build error
File size: 20,591 Bytes
9874885 8e03aff 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 8e03aff 9874885 90dd6a4 9874885 90dd6a4 9874885 8e03aff 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 8e03aff 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 8e03aff 90dd6a4 9874885 90dd6a4 9874885 8e03aff 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 8e03aff 9874885 90dd6a4 9874885 8e03aff 90dd6a4 8e03aff 9874885 90dd6a4 9874885 8e03aff 9874885 90dd6a4 9874885 8e03aff 9874885 90dd6a4 9874885 8e03aff 9874885 90dd6a4 9874885 90dd6a4 8e03aff 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 90dd6a4 9874885 | 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 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rust AutoScore Engine - Smart Dashboard</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap" rel="stylesheet">
<style>
:root {
--primary: #00ff88;
--secondary: #00d4ff;
--accent: #ff4d4d;
--bg: #0a0e14;
--card-bg: rgba(255, 255, 255, 0.03);
--glass-border: rgba(255, 255, 255, 0.08);
--panel-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Outfit', sans-serif;
}
body {
background: var(--bg);
color: #fff;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
overflow-x: hidden;
background-image:
radial-gradient(circle at 20% 20%, rgba(0, 255, 136, 0.05) 0%, transparent 40%),
radial-gradient(circle at 80% 80%, rgba(0, 212, 255, 0.05) 0%, transparent 40%);
}
.bg-grid {
position: fixed;
top: 0; left: 0; width: 100%; height: 100%;
background-image: linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
background-size: 50px 50px;
z-index: -1;
pointer-events: none;
}
header {
padding: 3rem 2rem;
text-align: center;
width: 100%;
background: linear-gradient(to bottom, rgba(10, 14, 20, 0.8), transparent);
backdrop-filter: blur(10px);
border-bottom: 1px solid var(--glass-border);
margin-bottom: 2rem;
}
h1 {
font-size: 3.5rem;
font-weight: 800;
background: linear-gradient(135deg, var(--primary), var(--secondary));
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
margin-bottom: 0.5rem;
letter-spacing: -2px;
filter: drop-shadow(0 0 20px rgba(0, 255, 136, 0.3));
}
p.subtitle {
color: #8892b0;
font-size: 0.9rem;
letter-spacing: 4px;
text-transform: uppercase;
font-weight: 400;
opacity: 0.8;
}
main {
width: 95%;
max-width: 1400px;
display: grid;
grid-template-columns: 1fr 400px;
gap: 2.5rem;
padding: 0 0 4rem 0;
animation: fadeIn 0.8s ease-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
.visual-area {
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.upload-container {
background: var(--card-bg);
backdrop-filter: blur(30px);
border: 1px solid var(--glass-border);
border-radius: 32px;
padding: 1.5rem;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
min-height: 700px;
position: relative;
overflow: hidden;
box-shadow: var(--panel-shadow);
}
.upload-container:hover {
border-color: var(--primary);
box-shadow: 0 0 60px rgba(0, 255, 136, 0.15);
background: rgba(255, 255, 255, 0.05);
transform: scale(1.005);
}
.upload-container.drag-over {
border-color: var(--secondary);
background: rgba(0, 212, 255, 0.08);
transform: scale(1.01);
}
.preview-wrapper {
position: relative;
width: 100%;
height: 100%;
display: none;
justify-content: center;
align-items: center;
border-radius: 20px;
overflow: hidden;
}
#preview-img {
max-width: 100%;
max-height: 650px;
border-radius: 24px;
display: block;
object-fit: contain;
transition: 0.3s;
}
#overlay-svg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 10;
}
.scanline {
position: absolute;
top: -100%;
left: 0;
width: 100%;
height: 80px;
background: linear-gradient(to bottom, transparent, rgba(0, 255, 136, 0.2), transparent);
opacity: 0.8;
display: none;
z-index: 20;
pointer-events: none;
}
@keyframes scan {
0% { top: -10%; }
100% { top: 110%; }
}
.upload-icon { font-size: 5rem; margin-bottom: 1.5rem; filter: drop-shadow(0 0 15px rgba(255,255,255,0.2)); }
.upload-text { font-size: 1.8rem; font-weight: 600; color: #fff; letter-spacing: -0.5px; }
.upload-subtext { color: #8892b0; margin-top: 1rem; font-size: 1rem; }
.stats-panel {
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.stat-card {
background: var(--card-bg);
backdrop-filter: blur(20px);
border: 1px solid var(--glass-border);
border-radius: 28px;
padding: 1.8rem;
position: relative;
overflow: hidden;
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.stat-card:hover {
border-color: rgba(255,255,255,0.2);
background: rgba(255, 255, 255, 0.06);
transform: translateY(-5px);
}
.stat-label { color: #8892b0; font-size: 0.75rem; font-weight: 700; margin-bottom: 0.8rem; text-transform: uppercase; letter-spacing: 2px; }
.stat-value { font-size: 2.2rem; font-weight: 800; margin-bottom: 0.5rem; }
.conf-bar { height: 8px; background: rgba(255,255,255,0.05); border-radius: 4px; margin-top: 1.2rem; overflow: hidden; }
.conf-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--primary), var(--secondary)); transition: 1.5s cubic-bezier(0.19, 1, 0.22, 1); }
.loading-spinner {
width: 70px; height: 70px;
border: 5px solid rgba(0, 255, 136, 0.05);
border-top: 5px solid var(--primary);
border-radius: 50%;
animation: spin 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
display: none;
position: absolute;
z-index: 30;
filter: drop-shadow(0 0 15px var(--primary));
}
@keyframes spin { 100% { transform: rotate(360deg); } }
.keypoint-marker {
fill: var(--primary);
stroke: #fff;
stroke-width: 2.5px;
filter: drop-shadow(0 0 10px var(--primary));
animation: pulse-marker 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}
@keyframes pulse-marker {
0%, 100% { r: 8; opacity: 1; }
50% { r: 8; opacity: 0.8; }
}
.result-item {
padding: 14px 0;
border-bottom: 1px solid rgba(255,255,255,0.04);
display: flex;
align-items: center;
justify-content: space-between;
animation: slideIn 0.4s ease-out forwards;
}
@keyframes slideIn {
from { opacity: 0; transform: translateX(20px); }
to { opacity: 1; transform: translateX(0); }
}
.badge {
padding: 5px 12px;
border-radius: 20px;
font-size: 0.75rem;
font-weight: 800;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.badge-dart { background: linear-gradient(135deg, #ff4d4d, #c00); color: white; box-shadow: 0 4px 15px rgba(255, 77, 77, 0.4); }
.badge-cal { background: linear-gradient(135deg, #00ff88, #00d4ff); color: #0a0e14; box-shadow: 0 4px 15px rgba(0, 255, 136, 0.2); }
</style>
</head>
<body>
<div class="bg-grid"></div>
<header>
<h1>RUST AUTO SCORE <span style="font-weight: 200; opacity: 0.4;">ENGINE</span></h1>
<p class="subtitle">Neural Scoring & Board Analytics</p>
</header>
<main>
<section class="visual-area">
<div class="upload-container" id="drop-zone">
<div class="scanline" id="scanline"></div>
<div id="initial-state">
<div class="upload-icon">💠</div>
<div class="upload-text">Initialize Vision System</div>
<div class="upload-subtext">Drop board imagery for real-time neural mapping</div>
</div>
<div class="preview-wrapper" id="preview-wrapper">
<img id="preview-img">
<svg id="overlay-svg"></svg>
</div>
<div class="loading-spinner" id="spinner"></div>
</div>
<input type="file" id="file-input" style="display: none;" accept="image/*">
</section>
<aside class="stats-panel">
<div class="stat-card">
<div class="stat-label">Model Status</div>
<div class="stat-value" id="status-text" style="font-size: 1.4rem; color: var(--primary);">System Ready</div>
</div>
<div class="stat-card" id="cal-card">
<div class="stat-label">Calibration Sync</div>
<div class="stat-value" id="cal-status" style="font-size: 1.2rem; color: #8892b0;">Pending...</div>
</div>
<div class="stat-card">
<div class="stat-label">AI Confidence</div>
<div class="stat-value" id="conf-val">0.0%</div>
<div class="conf-bar"><div class="conf-fill" id="conf-fill"></div></div>
</div>
<div class="stat-card">
<div class="stat-label">Detection Result</div>
<div class="stat-value" id="result-text" style="font-size: 1.1rem; opacity: 0.8;">No Frame Captured</div>
</div>
</aside>
</main>
<script>
const dropZone = document.getElementById('drop-zone');
const fileInput = document.getElementById('file-input');
const previewImg = document.getElementById('preview-img');
const previewWrapper = document.getElementById('preview-wrapper');
const initialState = document.getElementById('initial-state');
const svgOverlay = document.getElementById('overlay-svg');
const spinner = document.getElementById('spinner');
const scanline = document.getElementById('scanline');
dropZone.onclick = () => fileInput.click();
fileInput.onchange = (e) => handleFile(e.target.files[0]);
dropZone.ondragover = (e) => { e.preventDefault(); dropZone.classList.add('drag-over'); };
dropZone.ondragleave = () => dropZone.classList.remove('drag-over');
dropZone.ondrop = (e) => { e.preventDefault(); dropZone.classList.remove('drag-over'); handleFile(e.dataTransfer.files[0]); };
async function handleFile(file) {
if (!file || !file.type.startsWith('image/')) return;
const reader = new FileReader();
reader.onload = (e) => {
previewImg.src = e.target.result;
previewWrapper.style.display = 'flex';
initialState.style.display = 'none';
clearKeypoints();
};
reader.readAsDataURL(file);
spinner.style.display = 'block';
scanline.style.display = 'block';
scanline.style.animation = 'scan 2s linear infinite';
document.getElementById('status-text').innerText = 'Neural Processing...';
document.getElementById('status-text').style.color = 'var(--secondary)';
const formData = new FormData();
formData.append('image', file);
try {
const response = await fetch('/api/predict', { method: 'POST', body: formData });
const data = await response.json();
spinner.style.display = 'none';
scanline.style.display = 'none';
if (data.status === 'success') {
document.getElementById('status-text').innerText = 'Analysis Complete';
document.getElementById('status-text').style.color = 'var(--primary)';
updateUI(data);
drawKeypoints(data.keypoints, data.confidences);
} else {
document.getElementById('status-text').innerText = 'Analysis Failed';
document.getElementById('status-text').style.color = 'var(--accent)';
}
} catch (err) {
spinner.style.display = 'none';
scanline.style.display = 'none';
document.getElementById('status-text').innerText = 'System Error';
document.getElementById('status-text').style.color = 'var(--accent)';
}
}
function updateUI(data) {
const conf = (data.confidence * 100).toFixed(1);
document.getElementById('conf-val').innerText = `${conf}%`;
document.getElementById('conf-fill').style.width = `${conf}%`;
const calStatus = document.getElementById('cal-status');
if (data.is_calibrated) {
calStatus.innerText = "VERIFIED ✅";
calStatus.style.color = "var(--primary)";
} else {
calStatus.innerText = "FAILED ❌";
calStatus.style.color = "var(--accent)";
}
let resultHtml = `<div style="margin: 1.5rem 0 1rem 0; font-size: 0.95rem; line-height: 1.6; color: rgba(255,255,255,0.9);">${data.message}</div>`;
if (data.keypoints && data.keypoints.length >= 8) {
const names = ["Cal 1", "Cal 2", "Cal 3", "Cal 4", "Dart"];
resultHtml += `<div style="font-size: 0.75rem; color: #8892b0; margin: 1.5rem 0 0.8rem 0; letter-spacing: 2px; text-transform: uppercase;">MAPPED DATA</div>`;
for (let i = 0; i < data.keypoints.length; i += 2) {
const classIdx = i / 2;
const isCal = classIdx < 4;
const name = names[classIdx] || `Dart ${Math.floor(classIdx - 3)}`;
const x = data.keypoints[i].toFixed(3);
const y = data.keypoints[i+1].toFixed(3);
const ptConf = ((data.confidences[classIdx] || 0) * 100).toFixed(0);
const isReliable = ptConf > 10;
let scoreHtml = "";
if (classIdx >= 4 && data.scores && data.scores[classIdx - 4]) {
scoreHtml = `<div style="display: flex; flex-direction: column; align-items: flex-end; gap: 4px;">
<span class="badge badge-dart">${data.scores[classIdx - 4]}</span>
<span style="font-size: 0.65rem; color: #8892b0; font-weight: 600;">CONF: ${ptConf}%</span>
</div>`;
} else if (isCal) {
scoreHtml = `<span class="badge" style="background: ${isReliable ? 'rgba(0,255,136,0.1)' : 'rgba(255,77,77,0.1)'}; color: ${isReliable ? 'var(--primary)' : 'var(--accent)'}; font-size: 0.6rem; border: 1px solid">${isReliable ? ptConf+'% OK' : ptConf+'% ERR'}</span>`;
}
resultHtml += `
<div class="result-item" style="animation-delay: ${classIdx * 0.1}s">
<div style="display: flex; flex-direction: column;">
<span style="font-weight: 600; font-size: 0.95rem; color: ${isCal ? 'var(--primary)' : 'var(--accent)'}">${name}</span>
<span style="font-size: 0.7rem; color: #8892b0; font-family: monospace; letter-spacing: 0.5px;">X:${x} Y:${y}</span>
</div>
${scoreHtml}
</div>`;
}
}
document.getElementById('result-text').innerHTML = resultHtml;
}
function clearKeypoints() {
while (svgOverlay.firstChild) svgOverlay.removeChild(svgOverlay.firstChild);
}
function drawKeypoints(pts, confs) {
clearKeypoints();
if (!pts || pts.length === 0) return;
setTimeout(() => {
const rect = previewImg.getBoundingClientRect();
const wrapperRect = previewWrapper.getBoundingClientRect();
const offsetX = rect.left - wrapperRect.left;
const offsetY = rect.top - wrapperRect.top;
const width = rect.width;
const height = rect.height;
for (let i = 0; i < pts.length; i += 2) {
const classIdx = i / 2;
const isCal = classIdx < 4;
const x = pts[i] * width + offsetX;
const y = pts[i+1] * height + offsetY;
const ptConf = ((confs[classIdx] || 0) * 100).toFixed(0);
const name = isCal ? `CAL ${classIdx+1} (${ptConf}%)` : `DART (${ptConf}%)`;
const group = document.createElementNS("http://www.w3.org/2000/svg", "g");
const circle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
circle.setAttribute("cx", x);
circle.setAttribute("cy", y);
circle.setAttribute("r", 8);
circle.setAttribute("class", "keypoint-marker");
if (!isCal) {
circle.style.fill = "#ff4d4d";
circle.style.filter = "drop-shadow(0 0 15px rgba(255, 77, 77, 0.6))";
}
const labelBg = document.createElementNS("http://www.w3.org/2000/svg", "rect");
labelBg.setAttribute("x", x + 15);
labelBg.setAttribute("y", y - 25);
labelBg.setAttribute("width", name.length * 7 + 15);
labelBg.setAttribute("height", "22");
labelBg.setAttribute("rx", "11");
labelBg.setAttribute("fill", "rgba(0,0,0,0.7)");
labelBg.setAttribute("style", "backdrop-filter: blur(8px); stroke: rgba(255,255,255,0.1); stroke-width: 1;");
const label = document.createElementNS("http://www.w3.org/2000/svg", "text");
label.setAttribute("x", x + 21);
label.setAttribute("y", y - 9);
label.setAttribute("fill", isCal ? "#00ff88" : "#ff4d4d");
label.setAttribute("font-size", "10px");
label.setAttribute("font-weight", "900");
label.setAttribute("style", "text-transform: uppercase; letter-spacing: 1.5px;");
label.textContent = name;
group.appendChild(circle);
group.appendChild(labelBg);
group.appendChild(label);
svgOverlay.appendChild(group);
}
}, 100);
}
</script>
</body>
</html>
|