Skip to content

This repository contains code for pneumonia detection using X-ray images of the lungs.

License

Notifications You must be signed in to change notification settings

tirth-hihoriya/Pneumonia_Detection

 
 

Repository files navigation

Pneumonia Detection

This repository contains code for pneumonia detection using X-ray images of the lungs.

Link for the dataset

Link to the trained models

Instructions

  • Install required packages from requirements.txt
  • You can download, extract and move the data according to the label using data.py
    • pip install kaggle
    • Download Kaggle API key from your Kaggle Account. Go to www.kaggle.com -> My Account -> Create New API token
    • Place the file in on your home directory $(HOME)/.kaggle/kaggle.json.
    • Kaggle module will look for this token at ~/.kaggle/kaggle.json on Linux, OSX, and other UNIX-based operating systems, and at C:\Users\<windows-username>\.kaggle\kaggle.json on Windows.
    • execute python data.py
  • Run main.py to train from the dataset. For example, python main.py --base_model {base_model} --optimizer {optimizer} --learning_rate {learning_rate} --batch_size {batch_size} --epoch {epoch} --colab
    • To change pretrained base model, give input while initializing the model object. Use values from
      • ResNet18
      • ResNet34
      • ResNet50
      • ResNet101
      • ResNet152
      • Alexnet
      • VGG11
      • VGG13
      • VGG16
      • VGG19
      • GoogleNet
      • Inception
    • If using colab for training, mount the drive and use --colab to save the files in the drive
    • To change optimizers, use one of the following
      • Adam
      • SGD
      • RMSprop
      • Adagrad
      • Adadelta
  • To test new dataset, run test.py with directory path and base model with option given above. Make sure that model is trained on those models first.
    • Example, python3 test.py "./data/Corona_Classification_data/test/" Inception
  • To generate a Class Activation Map from a trained model, after training it, use CAM.py like python3 CAM.py {Model_Name} {Path_to_Image}
    • Example, python3 CAM.py Inception "./data/abc.jpg"
    • This will save the output as CAM_{Model_Name}.jpg in the current directory

About

This repository contains code for pneumonia detection using X-ray images of the lungs.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 77.8%
  • Jupyter Notebook 12.1%
  • Shell 10.1%