GithubHelp home page GithubHelp logo

alinstein / x_ray Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 4.0 73.65 MB

Weakly supervised Classification and Localization of Chest X-ray images

License: MIT License

Python 53.33% Shell 0.62% Jupyter Notebook 46.05%
disease-location chest-xray-images heatmap cnn gradcam class-activation-maps densenet gradcam-plus-plus nih-chest-x-ray chestxray14

x_ray's Introduction

Weakly supervised Classification and Localization of Chest X-ray images.

Results

This project contains two task :

  • Detect common thoracic diseases from chest X-ray images.
  • Localize the plausible disease location in X-ray image using CNN model trained on images labels only.

This implementation can used with two chest X-ray image datasets.

Following are implemented in this repository:

  • Module to train, evaluate the DCNN model on NIH Chest X-ray dataset.
  • Can use following CNN : ResNet, DenseNet, Efficient, PCAM with DenseNet as backbone.
  • Weakly supervised localization methods: Class Activation Map, GradCAM, GradCAM++ to generate a heatmap of plausible disease location and bounding boxes are marked around the disease location.

Getting Started

  1. Install packages

    pip install -r requirements.txt

  2. Download the datasets from the link provided above.

  3. For NIH dataset extract the dataset and move all images into directory dataset/images and train, val and test CSV files to dataset. And for NIH dataset before training, it's recommended to reduce the size of image from 1024x1024 to 512x512 or 256x256 depending upon the training image size. This will significantly speed up the training speed.

    For ChesXpert dataset, download the dataset and extract all the dataset to dataset/CheXpert.

  4. Change the resolution, CNN architecture, batch size, epochs, pooling layer, attention network etc in config.py.

  5. To train and evaluate the multi-label classification model on NIH dataset with eight diseases, run :

     python main.py --num_classes=8 --batch_size=32 --multi_label=True --img_size=224 --epochs=20 --dataset=NIH
    

    To train and evaluate the multi-label classification model on NIH dataset with eight diseases, run :

     python main.py --num_classes=5 --batch_size=32 --multi_label=True --img_size=224 --epochs=20 --dataset=ChesXpert
    

    To train and evaluate the binary classification (abnormality) model, run :

     python main.py --num_classes=1 --batch_size=32 --multi_label=False --img_size=224 --epochs=20
    
  6. To generate a heatmap of the disease, give CNN model's location in main function in heatMap_.py and check the configuration in config.py. Run the following :

      python heatMap_.py
    

Reference

[1] Xiaosong Wang, Yifan Peng, Le Lu, Zhiyong Lu, Mohammadhadi Bagheri, Ronald M. Summers. ChestX-ray8: Hospital-scale Chest X-ray Database and Benchmarks on Weakly- Supervised Classification and Localization of Common Thorax Diseases, IEEE CVPR, pp. 3462-3471,2017

[2] J. Irvin, P Rajpurkar, M Ko, Yifan Yu, S Ciurea-Ilcus, C Chute, H Marklund, B Haghgoo, R Ball, K Shpanskaya, J Seekins, David A. Mong, S S. Halabi, Jesse K. S, Ricky J, David B. L, Curtis P. L, Bhavik N. P, Matthew P. L, and Andrew Y. Ng. “CheXpert: A Large Chest Radiograph Dataset With Uncertainty Labels and Expert Comparison”. Proceedings of the AAAI Conference on Artificial Intelligence 33 (01):590-97,2019. Link

[3] B. Zhou, A. Khosla, A. Lapedriza, A. Oliva and A. Torralba, "Learning Deep Features for Discriminative Localization," 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Las Vegas, NV, 2016, pp. 2921-2929, doi: 10.1109/CVPR.2016.319. Link

[4] R. R. Selvaraju, M. Cogswell, A. Das, R. Vedantam, D. Parikh and D. Batra, "Grad-CAM: Visual explanations from deep networks via gradient-based localization," 2017 IEEE International Conference on Computer Vision (ICCV), Venice, 2017, pp. 618-626, doi: 10.1109/ICCV.2017.74. Link

[5] A. Chattopadhay, A. Sarkar, P. Howlader and V. N. Balasubramanian, "Grad-CAM++: Generalized gradient-based visual explanations for deep convolutional networks," 2018 IEEE Winter Conference on Applications of Computer Vision (WACV), Lake Tahoe, NV, 2018, pp. 839-847, doi: 10.1 109/WACV.2018.00097. 1710.11063v3.pdf (arxiv.org) Link

x_ray's People

Contributors

alinstein avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

x_ray's Issues

Pretrained Model

Hi,

This is a very interesting work! May I request for a pretrain for your classification models?

Thank you!

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.