Giter Site home page Giter Site logo

giocoal / cxr-acgan-chest-xray-generator-covid19-pneumonia Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 2.0 656.18 MB

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: MIT License

Python 100.00%
ac-gan auxiliary-classifier-gan chest-xray-images chest-xrays chestxray14 covid-19 covidx-dataset cxr-lungs frechet-inception-distance generative-adversarial-network generative-models inception-score keras pneumonia t-sne tensorflow computer-vision deep-learning python data-augmentation

cxr-acgan-chest-xray-generator-covid19-pneumonia's Introduction

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

cxr-acgan-chest-xray-generator-covid19-pneumonia's People

Contributors

giocoal avatar rmarconzini avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.