Project Overview
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.
Diagnostic Examples
Representative visualizations highlighting the contrast between healthy lungs and pneumonia-affected regions.
Pipeline Architecture
Key Code Snippets
Image Preprocessing
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485], std=[0.229])
])
Data Augmentation
train_transform = transforms.Compose([
transforms.RandomHorizontalFlip(),
transforms.RandomRotation(10),
transforms.Resize((224, 224)),
transforms.ToTensor()
])
Model Definition
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)
Training Loop
for images, labels in train_loader:
outputs = model(images)
loss = criterion(outputs, labels)
loss.backward()
optimizer.step()
Prediction
with torch.no_grad():
probs = torch.softmax(model(x), dim=1)
pred = torch.argmax(probs, dim=1)
Model Performance
Evaluation Metrics
- Accuracy: Classification accuracy across 20 thoracic conditions
- Precision: Positive prediction reliability
- Recall: Pneumonia detection sensitivity
- F1 Score: Precision-recall balance
- ROC-AUC: Threshold-independent performance
Dataset Summary
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.
Technologies Used
Real Images from the Notebook
These are actual figures extracted directly from the Jupyter notebook, including dataset samples, plots, and model visualizations.