Spaces:
Sleeping
Sleeping
File size: 20,018 Bytes
a1af663 90f9a3f a1af663 90f9a3f a1af663 90f9a3f a1af663 90f9a3f a1af663 90f9a3f a1af663 90f9a3f a1af663 |
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 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Breast Cancer Classification - AI Diagnostic Tool</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 900px;
margin: 0 auto;
background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
text-align: center;
}
.header h1 {
font-size: 2.5em;
margin-bottom: 10px;
}
.header p {
font-size: 1.1em;
opacity: 0.9;
}
.content {
padding: 40px;
}
.info-box {
background: #f8f9fa;
border-left: 4px solid #667eea;
padding: 20px;
margin-bottom: 30px;
border-radius: 8px;
}
.info-box h3 {
color: #667eea;
margin-bottom: 10px;
}
.info-box ul {
margin-left: 20px;
line-height: 1.8;
}
.github-link {
display: inline-flex;
align-items: center;
gap: 8px;
color: #667eea;
text-decoration: none;
font-weight: 600;
font-size: 1.1em;
padding: 10px 20px;
background: white;
border: 2px solid #667eea;
border-radius: 8px;
transition: all 0.3s;
margin: 20px 0;
}
.github-link:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
background: #667eea;
color: white;
}
.test-button {
background: #6c757d;
color: white;
padding: 12px 30px;
border: none;
border-radius: 25px;
font-size: 1.1em;
cursor: pointer;
transition: transform 0.2s;
margin-left: 10px;
}
.test-button:hover {
background: #5a6268;
transform: scale(1.05);
}
.result-image-container {
position: relative;
margin-bottom: 20px;
}
.result-image {
max-width: 100%;
max-height: 300px;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}
.result-overlay {
position: absolute;
top: 10px;
left: 50%;
transform: translateX(-50%);
background: rgba(0, 0, 0, 0.8);
color: white;
padding: 10px 20px;
border-radius: 8px;
font-size: 1.2em;
font-weight: bold;
}
.upload-section {
text-align: center;
padding: 40px;
border: 3px dashed #667eea;
border-radius: 15px;
margin-bottom: 30px;
transition: all 0.3s;
cursor: pointer;
}
.upload-section:hover {
border-color: #764ba2;
background: #f8f9fa;
}
.upload-section.drag-over {
background: #e3f2fd;
border-color: #2196F3;
}
.upload-icon {
font-size: 4em;
color: #667eea;
margin-bottom: 20px;
}
.upload-text {
font-size: 1.2em;
color: #666;
margin-bottom: 15px;
}
.file-input {
display: none;
}
.upload-button {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 12px 30px;
border: none;
border-radius: 25px;
font-size: 1.1em;
cursor: pointer;
transition: transform 0.2s;
}
.upload-button:hover {
transform: scale(1.05);
}
.preview-section {
display: none;
margin-bottom: 30px;
}
.preview-image {
max-width: 100%;
max-height: 400px;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
display: block;
margin: 0 auto;
}
.result-section {
display: none;
padding: 30px;
border-radius: 15px;
text-align: center;
}
.result-benign {
background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
color: white;
}
.result-malignant {
background: linear-gradient(135deg, #ee0979 0%, #ff6a00 100%);
color: white;
}
.result-title {
font-size: 2em;
margin-bottom: 20px;
}
.confidence-bar {
background: rgba(255,255,255,0.3);
border-radius: 10px;
height: 30px;
margin: 20px 0;
position: relative;
overflow: hidden;
}
.confidence-fill {
height: 100%;
background: white;
border-radius: 10px;
transition: width 1s ease;
display: flex;
align-items: center;
justify-content: center;
color: #667eea;
font-weight: bold;
}
.probabilities {
display: flex;
justify-content: space-around;
margin-top: 20px;
}
.prob-item {
flex: 1;
padding: 15px;
background: rgba(255,255,255,0.2);
border-radius: 10px;
margin: 0 10px;
}
.prob-label {
font-size: 0.9em;
margin-bottom: 5px;
}
.prob-value {
font-size: 1.8em;
font-weight: bold;
}
.loading {
display: none;
text-align: center;
padding: 30px;
}
.spinner {
border: 4px solid #f3f3f3;
border-top: 4px solid #667eea;
border-radius: 50%;
width: 50px;
height: 50px;
animation: spin 1s linear infinite;
margin: 0 auto 20px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.error {
display: none;
background: #ff5252;
color: white;
padding: 15px;
border-radius: 10px;
margin-bottom: 20px;
}
.try-again-button {
background: white;
color: #667eea;
padding: 12px 30px;
border: none;
border-radius: 25px;
font-size: 1.1em;
cursor: pointer;
margin-top: 20px;
transition: transform 0.2s;
}
.try-again-button:hover {
transform: scale(1.05);
}
.note {
background: #fff3cd;
border-left: 4px solid #ffc107;
padding: 15px;
margin-top: 30px;
border-radius: 8px;
font-size: 0.9em;
}
.footer {
background: #f8f9fa;
padding: 20px;
text-align: center;
color: #666;
font-size: 0.9em;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🔬 Breast Cancer Classification</h1>
<p>AI-Powered Mammogram Analysis</p>
</div>
<div class="content">
<div class="info-box">
<h3>📋 How to Use This Tool</h3>
<ul>
<li><strong>Upload Image:</strong> Click the upload area or drag & drop a mammogram image</li>
<li><strong>Supported Formats:</strong> JPG, JPEG, PNG</li>
<li><strong>Image Requirements:</strong> Clear mammogram image, preferably full breast view</li>
<li><strong>Classification:</strong> The AI will classify the image as Benign (non-cancerous) or Malignant (cancerous)</li>
<li><strong>Confidence Score:</strong> Shows the model's confidence in its prediction</li>
</ul>
</div>
<div class="info-box">
<h3>🤖 About the Model</h3>
<p>This tool uses an integrated ensemble of VGG16 and ResNet50V2 deep learning models trained on the CBIS-DDSM dataset. The model combines transfer learning with custom classification layers to analyze mammogram images and predict breast cancer classification.</p>
<div style="margin-top: 15px;">
<a href="https://github.com/koesan/Breast_Cancer_Classification" target="_blank" class="github-link">
<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
<path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/>
</svg>
View on GitHub
</a>
</div>
</div>
<div class="error" id="errorMessage"></div>
<div class="upload-section" id="uploadSection">
<div class="upload-icon">📤</div>
<div class="upload-text">Drag & Drop your mammogram image here</div>
<div style="margin: 20px 0;">or</div>
<input type="file" id="fileInput" class="file-input" accept="image/*">
<button class="upload-button" onclick="document.getElementById('fileInput').click()">
Choose File
</button>
<button class="test-button" onclick="testExample()">
🧪 Test Example
</button>
</div>
<div class="preview-section" id="previewSection">
<h3 style="margin-bottom: 15px;">Uploaded Image:</h3>
<img id="previewImage" class="preview-image" alt="Preview">
<div style="text-align: center; margin-top: 20px;">
<button class="upload-button" onclick="analyzeImage()">
🔍 Analyze Image
</button>
</div>
</div>
<div class="loading" id="loading">
<div class="spinner"></div>
<p>Analyzing mammogram image...</p>
</div>
<div class="result-section" id="resultSection">
<div class="result-image-container" id="resultImageContainer" style="display: none;">
<img id="resultImage" class="result-image" alt="Result">
<div class="result-overlay" id="resultOverlay"></div>
</div>
<div class="result-title" id="resultTitle"></div>
<div class="confidence-bar">
<div class="confidence-fill" id="confidenceFill"></div>
</div>
<div class="probabilities">
<div class="prob-item">
<div class="prob-label">Benign Probability</div>
<div class="prob-value" id="benignProb">-</div>
</div>
<div class="prob-item">
<div class="prob-label">Malignant Probability</div>
<div class="prob-value" id="malignantProb">-</div>
</div>
</div>
<button class="try-again-button" onclick="resetAnalysis()">
🔄 Analyze Another Image
</button>
</div>
<div class="note">
<strong>⚠️ Important Notice:</strong> This is an AI diagnostic assistance tool for educational and research purposes. It should NOT be used as a substitute for professional medical diagnosis. Always consult with qualified healthcare professionals for medical advice and diagnosis.
</div>
</div>
<div class="footer">
<p>Powered by VGG16 + ResNet50V2 Ensemble Model | CBIS-DDSM Dataset</p>
<p>© 2025 Breast Cancer Classification Project</p>
</div>
</div>
<script>
let selectedFile = null;
// File input change handler
document.getElementById('fileInput').addEventListener('change', function(e) {
handleFile(e.target.files[0]);
});
// Drag and drop handlers
const uploadSection = document.getElementById('uploadSection');
uploadSection.addEventListener('dragover', function(e) {
e.preventDefault();
uploadSection.classList.add('drag-over');
});
uploadSection.addEventListener('dragleave', function(e) {
e.preventDefault();
uploadSection.classList.remove('drag-over');
});
uploadSection.addEventListener('drop', function(e) {
e.preventDefault();
uploadSection.classList.remove('drag-over');
handleFile(e.dataTransfer.files[0]);
});
function handleFile(file) {
if (!file) return;
// Check if file is an image
if (!file.type.startsWith('image/')) {
showError('Please upload a valid image file (JPG, JPEG, PNG)');
return;
}
selectedFile = file;
// Show preview
const reader = new FileReader();
reader.onload = function(e) {
document.getElementById('previewImage').src = e.target.result;
document.getElementById('uploadSection').style.display = 'none';
document.getElementById('previewSection').style.display = 'block';
document.getElementById('errorMessage').style.display = 'none';
};
reader.readAsDataURL(file);
}
async function analyzeImage() {
if (!selectedFile) return;
// Show loading
document.getElementById('previewSection').style.display = 'none';
document.getElementById('loading').style.display = 'block';
// Create FormData
const formData = new FormData();
formData.append('file', selectedFile);
try {
const response = await fetch('/predict', {
method: 'POST',
body: formData
});
const data = await response.json();
if (response.ok) {
showResult(data);
} else {
showError(data.error || 'An error occurred during analysis');
}
} catch (error) {
showError('Failed to connect to the server. Please try again.');
} finally {
document.getElementById('loading').style.display = 'none';
}
}
function testExample() {
// Show loading
document.getElementById('loading').style.display = 'block';
document.getElementById('uploadSection').style.display = 'none';
document.getElementById('previewSection').style.display = 'none';
document.getElementById('resultSection').style.display = 'none';
document.getElementById('errorMessage').style.display = 'none';
fetch('/test-example', {
method: 'POST'
})
.then(response => response.json())
.then(data => {
document.getElementById('loading').style.display = 'none';
if (data.error) {
showError(data.error);
} else {
showResult(data, true);
}
})
.catch(error => {
document.getElementById('loading').style.display = 'none';
showError('Failed to analyze example: ' + error.message);
});
}
function showResult(data, showImage = false) {
const resultSection = document.getElementById('resultSection');
const resultTitle = document.getElementById('resultTitle');
const confidenceFill = document.getElementById('confidenceFill');
const benignProb = document.getElementById('benignProb');
const malignantProb = document.getElementById('malignantProb');
const resultImageContainer = document.getElementById('resultImageContainer');
const resultImage = document.getElementById('resultImage');
const resultOverlay = document.getElementById('resultOverlay');
// Show image if available
if (showImage && data.image) {
resultImage.src = data.image;
resultOverlay.textContent = data.class;
resultImageContainer.style.display = 'block';
} else {
resultImageContainer.style.display = 'none';
}
// Update content
resultTitle.textContent = `Classification: ${data.class}`;
confidenceFill.style.width = data.confidence.toFixed(2) + '%';
confidenceFill.textContent = data.confidence.toFixed(2) + '%';
benignProb.textContent = data.benign_prob.toFixed(2) + '%';
malignantProb.textContent = data.malignant_prob.toFixed(2) + '%';
// Update styling based on classification
if (data.class === 'Benign') {
resultSection.className = 'result-section result-benign';
} else {
resultSection.className = 'result-section result-malignant';
}
resultSection.style.display = 'block';
}
function showError(message) {
const errorElement = document.getElementById('errorMessage');
errorElement.textContent = '❌ Error: ' + message;
errorElement.style.display = 'block';
document.getElementById('uploadSection').style.display = 'block';
document.getElementById('loading').style.display = 'none';
}
function resetAnalysis() {
selectedFile = null;
document.getElementById('fileInput').value = '';
document.getElementById('uploadSection').style.display = 'block';
document.getElementById('previewSection').style.display = 'none';
document.getElementById('resultSection').style.display = 'none';
document.getElementById('errorMessage').style.display = 'none';
}
</script>
</body>
</html>
|