CXR-ACGAN: Auxiliary Classifier GAN (AC-GAN) for Conditional Generation of Chest X-Ray Images (Pneumonia, COVID-19 and Healthy patients) for the purpose of data augmentation.
- Abstract
- Report
- Requirements
- COVIDx CXR-3: Dataset and Image Pre-processing
- AC-GAN Training and Generation
- AC-GAN Evaluation: FID, Intra FID, Inception Score (IS), t-SNE
- Chest X-Ray Classification: Pneumonia and COVID-19 detection with GAN augmentation
- Status
- Contact
- License
- Contributing
Our project involved training a model for conditional image generation of chest X-rays using an AC-GAN architecture. The main objective was to train an Auxiliary Classifier GAN (AC-GAN) to obtain a model for the conditional synthesis of chest radiographs of healthy patients, patients with COVID-19 and patients with non-COVID-19 pneumonia. Additionally, we used the trained GAN to perform data augmentation on the unbalanced COVIDx dataset, generatively balancing minority classes, and possibly improving the performance of some classifiers. The resulting generative model will enable the synthesis of conditionally generated chest X-rays, with potential applications in medical research and diagnostics. The GAN is trained directly on COVIDx CXR-3 dataset with simple preprocessing and positional data augmentation.
- python==3.8
- ipython
- ipykernel
- matplotlib
- pandas
- seaborn
- tqdm==4.64.1
- scikit-learn==1.2.0
- glob2==0.7
- keras==2.10.0
- Keras-Preprocessing==1.1.2
- tensorflow==2.10.1
- numpy==1.24.2
- opencv_python==4.7.0.68
- pandas==1.5.3
- Pillow==9.4.0
- imageio==2.25.0
Download COVID-x CXR-3 from the official Kaggle Folder and extract train
and test
folders in ./Data/COVIDx/
, resulting in a folder tree like this:
project_folder
└───Data
├───COVIDx
| ├───test_COVIDx9A.txt
| ├───train_COVIDx9A.txt
| ├───train
| └───test
├───COVIDx-splitted-resized-112
├─── ...
Run the ./Data/train_test_class_split.sh
bash script which will subdivide the training and testing images within the COVIDx-splitted-resized-112 folder according to their class. So that we can then use flow_from_directory
. You get a directory tree like this:
project_folder
└───Data
├───COVIDx
├───COVIDx-splitted-resized-112
| ├───test_COVIDx9A.txt
| ├───train_COVIDx9A.txt
| ├───train
| | ├───COVID-19
| | ├───normal
| | └───pneumonia
| └───test
├─── ...
This step is intended to reduce the size of the dataset. It is not essential because resizing is also performed in the training phase. Run the ./Data/resize_all.py
script.
- Run the code and follow the detailed instructions in
AC-cGAN-training.ipynb
to perform AC-GAN training. - Generates images in large quantities using
AC-cGAN-generator.ipynb
.
Run the code and follow the detailed instructions in AC-cGAN-evaluate.ipynb
to:
- Displaying training metrics (Losses and Accuracies)
- Calculate Fréchet inception distance (FID)
- Calculate the Intra Fréchet inception distance (Intra FID)
- Calculate the Inception Score (IS)
- View t-SNE two-dimensional embeddings
Use the notebooks in CXR Classification
folder to train and evaluate classification models for the detection of COVID-19, Pneumonia and Absence of symptoms in Chest X-ray. Some forms of data augmentation are tested, including generation by trained AC-GAN.
Giorgio Carbone - feel free to contact me!
-
You can check out the full license here
This project is licensed under the terms of the MIT license.
- Fork it (https://github.com/giocoal/CXR-ACGAN-chest-xray-generator-covid19-pneumonia.git)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request