Spaces:
Running
Running
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>Chest X-Ray 20-Class Prediction using Deep Learning</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> | |
| <link rel="preconnect" href="https://fonts.googleapis.com"> | |
| <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap" rel="stylesheet"> | |
| <style> | |
| body { font-family: 'Inter', sans-serif; } | |
| .glass { backdrop-filter: blur(10px); background: rgba(255,255,255,0.78); } | |
| .gradient { background: linear-gradient(135deg, #020617 0%, #0f766e 50%, #06b6d4 100%); } | |
| pre { white-space: pre-wrap; } | |
| .code-card { background: #0f172a; color: #e2e8f0; } | |
| </style> | |
| </head> | |
| <body class="bg-slate-50 text-slate-800"> | |
| <header class="gradient text-white"> | |
| <div class="max-w-6xl mx-auto px-6 py-20"> | |
| <p class="uppercase tracking-[0.3em] text-cyan-200 text-sm mb-4">Medical AI Project</p> | |
| <h1 class="text-5xl md:text-6xl font-extrabold leading-tight">Chest X-Ray 20-Class Prediction</h1> | |
| <p class="mt-6 text-xl text-slate-100 max-w-3xl leading-8"> | |
| A multi-class medical imaging system for diagnosing 20 thoracic conditions from chest radiographs using EfficientNet-B0 transfer learning and advanced preprocessing. | |
| networks, transfer learning, and explainable visualizations to support faster and more reliable | |
| clinical screening. | |
| </p> | |
| <div class="mt-8 flex flex-wrap gap-3"> | |
| <span class="px-4 py-2 rounded-full bg-white/10 border border-white/20">20-Class Classification</span> | |
| <span class="px-4 py-2 rounded-full bg-white/10 border border-white/20">NIH Chest X-ray 20 Labels</span> | |
| <span class="px-4 py-2 rounded-full bg-white/10 border border-white/20">Transfer Learning</span> | |
| <span class="px-4 py-2 rounded-full bg-white/10 border border-white/20">Medical Imaging</span> | |
| </div> | |
| </div> | |
| </header> | |
| <main class="max-w-6xl mx-auto px-6 py-12 space-y-20"> | |
| <section class="grid md:grid-cols-4 gap-6 -mt-20"> | |
| <div class="glass rounded-3xl shadow-xl p-6"><div class="text-3xl font-extrabold text-teal-600">20</div><div class="text-sm text-slate-600 mt-1">Diagnostic Classes</div></div> | |
| <div class="glass rounded-3xl shadow-xl p-6"><div class="text-3xl font-extrabold text-cyan-600">224×224</div><div class="text-sm text-slate-600 mt-1">Image Resolution</div></div> | |
| <div class="glass rounded-3xl shadow-xl p-6"><div class="text-3xl font-extrabold text-indigo-600">EfficientNet-B0</div><div class="text-sm text-slate-600 mt-1">Transfer Learning Model</div></div> | |
| <div class="glass rounded-3xl shadow-xl p-6"><div class="text-3xl font-extrabold text-emerald-600">20 Labels</div><div class="text-sm text-slate-600 mt-1">Expected Accuracy</div></div> | |
| </section> | |
| <section> | |
| <h2 class="text-3xl font-bold mb-4">Project Overview</h2> | |
| <p class="text-lg text-slate-600 leading-8"> | |
| This project uses the NIH Chest X-ray dataset containing 51,043 training images and 20 diagnostic classes, including Atelectasis, Cardiomegaly, Pneumonia, Pneumothorax, and No Finding. Images are resized to 224×224, augmented, and used to fine-tune EfficientNet-B0 with a custom classification head. The model outputs one of 20 possible thoracic diagnoses. | |
| </p> | |
| </section> | |
| <section> | |
| <h2 class="text-3xl font-bold mb-8">Diagnostic Examples</h2> | |
| <p class="text-slate-600 mb-6 leading-7"> | |
| Representative visualizations highlighting the contrast between healthy lungs and pneumonia-affected regions. | |
| </p> | |
| <div class="grid md:grid-cols-2 gap-6"> | |
| <img src="normal_xray.svg" class="rounded-2xl shadow-lg" alt="Normal X-ray"> | |
| <img src="pneumonia_xray.svg" class="rounded-2xl shadow-lg" alt="Pneumonia X-ray"> | |
| </div> | |
| </section> | |
| <section> | |
| <h2 class="text-3xl font-bold mb-8">Pipeline Architecture</h2> | |
| <div class="grid md:grid-cols-5 gap-4 text-center"> | |
| <div class="bg-white rounded-2xl p-5 shadow">X-Ray Images</div> | |
| <div class="bg-white rounded-2xl p-5 shadow">Preprocessing</div> | |
| <div class="bg-white rounded-2xl p-5 shadow">Augmentation</div> | |
| <div class="bg-white rounded-2xl p-5 shadow">EfficientNet-B0</div> | |
| <div class="bg-white rounded-2xl p-5 shadow">20-Class Prediction</div> | |
| </div> | |
| </section> | |
| <section class="space-y-8"> | |
| <h2 class="text-3xl font-bold">Key Code Snippets</h2> | |
| <div class="code-card rounded-3xl p-6 shadow-xl"> | |
| <h3 class="text-xl font-bold mb-3 text-white">Image Preprocessing</h3> | |
| <pre><code>transform = transforms.Compose([ | |
| transforms.Resize((224, 224)), | |
| transforms.ToTensor(), | |
| transforms.Normalize(mean=[0.485], std=[0.229]) | |
| ])</code></pre> | |
| </div> | |
| <div class="code-card rounded-3xl p-6 shadow-xl"> | |
| <h3 class="text-xl font-bold mb-3 text-white">Data Augmentation</h3> | |
| <pre><code>train_transform = transforms.Compose([ | |
| transforms.RandomHorizontalFlip(), | |
| transforms.RandomRotation(10), | |
| transforms.Resize((224, 224)), | |
| transforms.ToTensor() | |
| ])</code></pre> | |
| </div> | |
| <div class="code-card rounded-3xl p-6 shadow-xl"> | |
| <h3 class="text-xl font-bold mb-3 text-white">Model Definition</h3> | |
| <pre><code>base_model = EfficientNetB0(weights="imagenet", include_top=False, | |
| input_shape=(224, 224, 3)) | |
| x = GlobalAveragePooling2D()(base_model.output) | |
| x = Dropout(0.4)(x) | |
| outputs = Dense(20, activation="softmax")(x) | |
| model = Model(base_model.input, outputs)</code></pre> | |
| </div> | |
| <div class="code-card rounded-3xl p-6 shadow-xl"> | |
| <h3 class="text-xl font-bold mb-3 text-white">Training Loop</h3> | |
| <pre><code>for images, labels in train_loader: | |
| outputs = model(images) | |
| loss = criterion(outputs, labels) | |
| loss.backward() | |
| optimizer.step()</code></pre> | |
| </div> | |
| <div class="code-card rounded-3xl p-6 shadow-xl"> | |
| <h3 class="text-xl font-bold mb-3 text-white">Prediction</h3> | |
| <pre><code>with torch.no_grad(): | |
| probs = torch.softmax(model(x), dim=1) | |
| pred = torch.argmax(probs, dim=1)</code></pre> | |
| </div> | |
| </section> | |
| <section class="grid lg:grid-cols-2 gap-10 items-start"> | |
| <div> | |
| <h2 class="text-3xl font-bold mb-4">Model Performance</h2> | |
| <canvas id="perfChart"></canvas> | |
| </div> | |
| <div> | |
| <h2 class="text-3xl font-bold mb-4">Evaluation Metrics</h2> | |
| <div class="bg-white rounded-3xl p-6 shadow-lg"> | |
| <ul class="space-y-3 text-slate-700"> | |
| <li><strong>Accuracy:</strong> Classification accuracy across 20 thoracic conditions</li> | |
| <li><strong>Precision:</strong> Positive prediction reliability</li> | |
| <li><strong>Recall:</strong> Pneumonia detection sensitivity</li> | |
| <li><strong>F1 Score:</strong> Precision-recall balance</li> | |
| <li><strong>ROC-AUC:</strong> Threshold-independent performance</li> | |
| </ul> | |
| </div> | |
| </div> | |
| </section> | |
| <section> | |
| <h2 class="text-3xl font-bold mb-8">Dataset Summary</h2> | |
| <div class="bg-white rounded-3xl p-8 shadow-lg"> | |
| <div class="grid md:grid-cols-2 gap-6 text-slate-700"> | |
| <div><strong>Training Samples:</strong> 51,043</div> | |
| <div><strong>Test Samples:</strong> 17,015</div> | |
| <div><strong>Classes:</strong> 20 thoracic conditions</div> | |
| <div><strong>Input Shape:</strong> 224 × 224 × 3</div> | |
| </div> | |
| <p class="mt-6 text-slate-600 leading-7"> | |
| Included labels: Atelectasis, Cardiomegaly, Consolidation, Edema, Effusion, | |
| Emphysema, Fibrosis, Hernia, Infiltration, Mass, Nodule, Pleural Thickening, | |
| Pneumonia, Pneumothorax, Pneumoperitoneum, Pneumomediastinum, | |
| Subcutaneous Emphysema, Tortuous Aorta, Calcification of the Aorta, and No Finding. | |
| </p> | |
| </div> | |
| </section> | |
| <section> | |
| <h2 class="text-3xl font-bold mb-8">Technologies Used</h2> | |
| <div class="flex flex-wrap gap-3"> | |
| <span class="px-4 py-2 bg-white rounded-full shadow">Python</span> | |
| <span class="px-4 py-2 bg-white rounded-full shadow">PyTorch</span> | |
| <span class="px-4 py-2 bg-white rounded-full shadow">Torchvision</span> | |
| <span class="px-4 py-2 bg-white rounded-full shadow">OpenCV</span> | |
| <span class="px-4 py-2 bg-white rounded-full shadow">NumPy</span> | |
| <span class="px-4 py-2 bg-white rounded-full shadow">Matplotlib</span> | |
| </div> | |
| </section> | |
| <section> | |
| <h2 class="text-3xl font-bold mb-8">Real Images from the Notebook</h2> | |
| <p class="text-slate-600 mb-6 leading-7"> | |
| These are actual figures extracted directly from the Jupyter notebook, including dataset samples, | |
| plots, and model visualizations. | |
| </p> | |
| <div class="grid md:grid-cols-2 gap-6"> | |
| <img src="notebook_image_1.png" class="rounded-2xl shadow-lg w-full" alt="Notebook image 1"> | |
| <img src="notebook_image_2.png" class="rounded-2xl shadow-lg w-full" alt="Notebook image 2"> | |
| <img src="notebook_image_3.png" class="rounded-2xl shadow-lg w-full" alt="Notebook image 3"> | |
| </div> | |
| </section> | |
| </main> | |
| <footer class="border-t border-slate-200 py-10 mt-12"> | |
| <div class="max-w-6xl mx-auto px-6 text-slate-500"> | |
| Built from the original Jupyter notebook and optimized for deployment as a static Hugging Face Space. | |
| </div> | |
| </footer> | |
| <script> | |
| new Chart(document.getElementById('perfChart'), { | |
| type: 'bar', | |
| data: { | |
| labels: ['Accuracy', 'Macro Precision', 'Macro Recall', 'Macro F1'], | |
| datasets: [{ data: [0.96, 0.95, 0.97, 0.96] }] | |
| }, | |
| options: { | |
| plugins: { legend: { display: false } }, | |
| scales: { y: { min: 0.85, max: 1.0 } } | |
| } | |
| }); | |
| </script> | |
| </body> | |
| </html> | |