Skip to content

CXR-ACGAN: Auxiliary Classifier GAN (AC-GAN) for Chest X-Ray (CXR) Images Generation (Pneumonia, COVID-19 and healthy patients) for the purpose of data augmentation. Implemented in TensorFlow, trained on COVIDx CXR-3 dataset.

License

Notifications You must be signed in to change notification settings

giocoal/CXR-ACGAN-chest-xray-generator-covid19-pneumonia

Repository files navigation

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.

Contributors Forks Stargazers Issues MIT License LinkedIn

Table of contents

Abstract

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.

GenetationExample

Requirements

  • 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

COVIDx CXR-3: Dataset and Image Pre-processing

Step 1. Download and extract the dataset

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
    ├─── ...

Step 2. Perform class splitting of the dataset

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
    ├─── ...

Step 3. (Opt) Perform images resizing to 112 x 122

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.

AC-GAN Training and Generation

  1. Run the code and follow the detailed instructions in AC-cGAN-training.ipynb to perform AC-GAN training.
  2. Generates images in large quantities using AC-cGAN-generator.ipynb.

AC-GAN Evaluation: FID, Intra FID, Inception Score (IS), t-SNE

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

Chest X-Ray Classification: Pneumonia and COVID-19 detection with GAN Augmentation

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.

Status

Project is: ##c5f015 Done

Contact

Giorgio Carbone - feel free to contact me!

License

  • You can check out the full license here

This project is licensed under the terms of the MIT license.

Contributing

  1. Fork it (https://github.com/giocoal/CXR-ACGAN-chest-xray-generator-covid19-pneumonia.git)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Contributors

Releases

No releases published

Packages

No packages published

Languages