https://github.com/nima-kam/tuberculosis_detection_cxr_pytorch
This repository contains tuberculosis classification on Chest X-ray using transfer learning in pytorch
https://github.com/nima-kam/tuberculosis_detection_cxr_pytorch
alexnet jupyter-notebook pytorch transfer-learning tuberculosis-classification
Last synced: 4 months ago
JSON representation
This repository contains tuberculosis classification on Chest X-ray using transfer learning in pytorch
- Host: GitHub
- URL: https://github.com/nima-kam/tuberculosis_detection_cxr_pytorch
- Owner: nima-kam
- Created: 2022-09-05T17:23:39.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-09-05T20:25:12.000Z (about 3 years ago)
- Last Synced: 2025-04-19T21:15:37.131Z (6 months ago)
- Topics: alexnet, jupyter-notebook, pytorch, transfer-learning, tuberculosis-classification
- Language: Jupyter Notebook
- Homepage:
- Size: 349 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tuberculosis detection using Chest X-RAY images in PyTorch
**AlexNet** CNN as the base model is used to classify CXR images as _**Normal / Tuberculosis_infected**_ through **Transfer learning**.## Dataset
**Data Source:** _https://www.kaggle.com/datasets/tawsifurrahman/tuberculosis-tb-chest-xray-dataset_
- **Total File Size:** 700MB
- **Number of records:** 3500 Normal, 700 Tuberculosis (Separated into 2 _(3600 train and 600 validation)_ parts)
- Images are size of **(512 * 512 * 3)** and in **_.jpg_** format.
![]()
![]()
## Network Architecture
```
===============================================================
Layer (type) Output Shape Param
===============================================================
Conv2d-1 [18, 64, 127, 127] 23,296
ReLU-2 [18, 64, 127, 127] 0
MaxPool2d-3 [18, 64, 63, 63] 0
Conv2d-4 [18, 192, 63, 63] 307,392
ReLU-5 [18, 192, 63, 63] 0
MaxPool2d-6 [18, 192, 31, 31] 0
Conv2d-7 [18, 384, 31, 31] 663,936
ReLU-8 [18, 384, 31, 31] 0
Conv2d-9 [18, 256, 31, 31] 884,992
ReLU-10 [18, 256, 31, 31] 0
Conv2d-11 [18, 256, 31, 31] 590,080
ReLU-12 [18, 256, 31, 31] 0
MaxPool2d-13 [18, 256, 15, 15] 0
AdaptiveAvgPool2d-14 [18, 256, 15, 15] 0
Dropout-15 [18, 57600] 0
Linear-16 [18, 510] 29,376,510
ReLU-17 [18, 510] 0
Linear-18 [18, 1] 511
================================================================
Total params: 31,846,717
Trainable params: 29,377,021
Non-trainable params: 2,469,696
```
- network uses pretrained weights and during the training, _CNN weights_ are freezed and training only affects the _Linear layers_.## Training
- For solving the problem of imbalance dataset, **weighted classes** used alongside with **cross entropy loss**## Accuracy
```
Validation loss: 0.019457, Validation acc: 99.333333,
for class Normal:
validation precision: 0.994024, validation recall: 0.998000 , validation F1: 0.996008
for class Tuberculosis:
validation precision: 0.989796, validation recall: 0.970000 , validation F1: 0.979798
```
Confusion matrix:
![]()
![]()
![]()