Downloads · 30 days
0
adelelsayed1991/chexpert-mae-densenet-fpn
chexpert-mae-densenet-fpn is a image classification model from adelelsayed1991. Use it when you need a label for an image. It is set up for pytorch. The card lists the license as mit.
A deep learning framework for multi-label chest X-ray classification using a hybrid architecture combining Masked Autoencoders (MAE), DenseNet with CBAM attention, and Feature Pyramid Networks (FPN) with bidirectional…
Downloads · 30 days
0
Access
Public
Updated Dec 8, 2025
Repo size
4.2 GB
Likes
0
Public
Click a slice to open those files.
.pth4.2 GB · 100%
From the Hugging Face model README
A deep learning framework for multi-label chest X-ray classification using a hybrid architecture combining Masked Autoencoders (MAE), DenseNet with CBAM attention, and Feature Pyramid Networks (FPN) with bidirectional cross-attention fusion.
This project implements a novel multi-modal fusion architecture for medical image classification:
Input Image (384×384)
│
├─────────────────────────────┐
│ │
▼ ▼
MAE Encoder DenseNet-169
(ViT-based) (with CBAM)
│ │
│ ┌───────────────────┤
│ │ │
│ FPN Pyramid Dense Features
│ (P1-P4) (Multi-scale)
│ │ │
└─────────┴───────────────────┘
│
Bidirectional Cross-Attention
│
┌─────────┴──────────┐
│ │
MAE Head Dense Head + 4 FPN Heads
│ │
└────────┬───────────┘
│
Learned Ensemble (7 heads)
│
▼
14-class Predictions
git clone https://github.com/adelelsayed/chexpert-mae-densenet-fpn.git
cd chexpert-mae-densenet-fpn
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
Download CheXpert Dataset
Prepare the dataset
# Extract the dataset
unzip CheXpert-v1.0-small.zip
# Optionally, create a ZIP archive for faster loading
cd CheXpert-v1.0-small
zip -r chexpert.zip train/ valid/
configs/configs.pyroot variable to point to your dataset locationEdit configs/configs.py to customize:
# Example: Update paths
root = "/path/to/your/data"
mae_config = {
"lr": 1e-4,
"num_epochs": 200,
"batch_size": 96,
# ... other parameters
}
config = {
"lr": 1e-4,
"num_epochs": 200,
"batch_size": 36,
# ... other parameters
}
python trainer/trainer.py
# When prompted, type: mae
The MAE pre-training learns robust feature representations through masked image reconstruction.
python trainer/trainer.py
# When prompted, type: classifier
This loads the pre-trained MAE encoder and trains the full classification pipeline.
MAE Training:
Classifier Training:
from trainer.utils import Trainer
from configs.configs import config
# Initialize trainer
trainer = Trainer(config)
# Run evaluation on test set
macro_auc, micro_auc, per_class = trainer.test(
model_path="path/to/checkpoint.pth"
)
print(f"Macro AUC: {macro_auc:.4f}")
print(f"Micro AUC: {micro_auc:.4f}")
chexpert-mae-densenet-fpn/
├── configs/
│ ├── __init__.py
│ └── configs.py # Configuration parameters
├── data/
│ ├── __init__.py
│ ├── dataset.py # CheXpert dataset with ZIP caching
│ └── splitter.py # Data splitting utilities
├── loss/
│ ├── __init__.py
│ └── assymetric.py # Asymmetric loss for imbalanced data
├── models/
│ ├── __init__.py
│ ├── mae.py # Masked Autoencoder implementation
│ ├── densenet.py # DenseNet-169 with CBAM
│ └── classifier.py # Full classification architecture
├── trainer/
│ ├── __init__.py
│ ├── trainer.py # Main training script
│ ├── utils.py # Training utilities and loops
│ └── test.py # Testing utilities
├── notebooks/
│ ├── chexpert_mae.ipynb # MAE experiments
│ └── chexpert_mae_mask_classifier.ipynb # Full pipeline experiments
├── requirements.txt
└── README.md
The model predicts 14 pathologies:
Training augmentations (conservative for medical images):
The training automatically saves:
Training logs are saved to:
training_log.txt: Training progress with live metricsval_log.txt: Validation resultstest_log.txt: Test evaluation resultshistory.json: All metrics across epochsmetrics.png: Visualization plotsMemory Optimization:
Speed Optimization:
Training Stability:
Q: Out of memory errors?
Q: Slow training?
Q: Poor convergence?
If you use this code in your research, please cite:
@misc{chexpert-mae-densenet-fpn,
author = {adel elsayed},
title = {CheXpert Classification with MAE-DenseNet-FPN},
year = {2025},
publisher = {GitHub},
url = {https://github.com/adelelsayed/chexpert-mae-densenet-fpn}
}
This project is licensed under the MIT License.
https://www.linkedin.com/in/adel-elsayed-a5260246/
Note: This is a research project. For clinical use, please ensure proper validation and regulatory approval.