https://github.com/aidinhamedi/pneumonia-detection-ai
This project uses a deep learning model built with the TensorFlow Library to detect pneumonia in X-ray images. The model architecture is based on the EfficientNetB7 model, which has achieved an accuracy of approximately 97.12% (97.11538%) on our test data. This high accuracy rate is one of the strengths of our AI model.
https://github.com/aidinhamedi/pneumonia-detection-ai
ai artificial-intelligence artificial-neural-networks cli data data-science database gui interface kaggle keras pneumonia pneumonia-classification pneumonia-detection pneumonia-detector pneumoniac-xray python tensorflow tensorflow2 training
Last synced: about 2 months ago
JSON representation
This project uses a deep learning model built with the TensorFlow Library to detect pneumonia in X-ray images. The model architecture is based on the EfficientNetB7 model, which has achieved an accuracy of approximately 97.12% (97.11538%) on our test data. This high accuracy rate is one of the strengths of our AI model.
- Host: GitHub
- URL: https://github.com/aidinhamedi/pneumonia-detection-ai
- Owner: AidinHamedi
- License: mit
- Created: 2023-12-20T18:39:13.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-31T11:00:09.000Z (5 months ago)
- Last Synced: 2024-12-31T12:17:03.069Z (5 months ago)
- Topics: ai, artificial-intelligence, artificial-neural-networks, cli, data, data-science, database, gui, interface, kaggle, keras, pneumonia, pneumonia-classification, pneumonia-detection, pneumonia-detector, pneumoniac-xray, python, tensorflow, tensorflow2, training
- Language: Jupyter Notebook
- Homepage:
- Size: 136 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: history/Archive/model_SGD-N-88-LongRun_y2024_m03_d21-h15_m03_s19_history.pkl.gz
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Citation: CITATION.cff
- Security: SECURITY.md
Awesome Lists containing this project
README
# Pneumonia Detection AI π€
![]()
![]()
![]()
![]()
[](https://opensource.org/licenses/MIT)
[](https://github.com/astral-sh/ruff)
[](https://github.com/Aydinhamedi/Pneumonia-Detection-Ai/actions/workflows/codeql.yml)
[](https://github.com/Aydinhamedi/Pneumonia-Detection-Ai/actions/workflows/dependency-review.yml)\
[](https://github.com/Aydinhamedi/Pneumonia-Detection-Ai/actions/workflows/ruff_L&F-Main.yml)
[](https://github.com/Aydinhamedi/Pneumonia-Detection-Ai/actions/workflows/ruff_L&F-Beta.yml)
[](https://github.com/Aydinhamedi/Pneumonia-Detection-Ai/actions/workflows/ruff_L&F-Alpha.yml)### This project uses a deep learning model built with the TensorFlow Library to detect pneumonia in X-ray images. The model architecture is based on the EfficientNetB7 model, which has achieved an accuracy of approximately 97.12% (97.11538%) on our test data. This high accuracy rate is one of the strengths of our AI model.
> [!IMPORTANT]
> The code that had achieved the highest acc is `backup/V6/Model_T&T.ipynb`.\
> And the codes with the light and super light models are `backup/V7/Model_T&T.ipynb`, `backup/V8/Model_T&T.ipynb`.## π Usage
> [!TIP]
> If you just want the model go to the Github Releases.> [!NOTE]
> This model was built using the [EfficientNet ](https://github.com/qubvel/efficientnet) library,
> which is a collection of state-of-the-art models for image classification. To use the model,
> you need to install the library and import it as follows:
> ```python
> import efficientnet.tfkeras
> ```
> Or clone the project and use `Utils.FixedDropout`:
> ```python
> from Utils.FixedDropout import FixedDropout
> from keras.models import load_model
>
> # Load the model
> model = load_model('PAI_model_T.h5', custom_objects={'FixedDropout': FixedDropout})
> ```The project includes a Command Line Interface (CLI) and a (GUI) Graphical User Interface for easy use of the model. The CLI, which is based on the [Python CLI template](https://github.com/Aydinhamedi/Python-CLI-template) from the same author, provides a user-friendly, colorful interface that allows you to interact with the model. you can fined the CLI in
> [!CAUTION]
> The last version of CLI is V0.8.9.3 and currently its has entered a minimal maintenance and not being updated ***and its going to be deprecated***.
```
Interface\CLI
```
Additionally, a Graphical User Interface (GUI) is available. you can fined the GUI in
```
Interface\GUI
```
### Example Image of the CLI (V0.8.9.3) ‡

### Example Image of the GUI (V0.8.9.6) ‡
## π¦ Release
> ### Newest release π
> #### [Go to newest release](https://github.com/Aydinhamedi/Pneumonia-Detection-Ai/releases/latest)## π Training System Specifications
- **Graphics Card (GPU)**: RTX 3090
- **Memory (RAM)**: 64GB
- **Operating System (OS)**: Windows 11 Pro
- **Processor (CPU)**: Intel Core i7-12700KF## π Model
The model is a Convolutional Neural Network (CNN) trained on a dataset of 23681 X-ray images. The dataset is a combination of the following:
- Chest X-ray Pneumonia dataset from Kaggle
- Covid19-Pneumonia-Normal Chest X-Ray Images from Mendeley
- RSNA datasetThis combined dataset provides a comprehensive set of images for training the model.\
### Model list:
| Model | Base Model | Params | acc | Status | Grad Cam |
|----------|-----------------|--------|--------|--------|----------|
| V6 | efficientnet-b7 | 65.4M | 97.12% | β | β |
| V7 light | efficientnet-b4 | 29.7M | 97.12% | β | β οΈ |
| V8 Super light | efficientnet-b0 | 4.8M | 96.47% | β | β |## π§ͺ Training Methods
### The AI model supports two distinct training approaches:- rev1: A straightforward method using Keras fit function for basic training.
- rev2: An enhanced training strategy incorporating data augmentation and subset training for improved accuracy and generalization.
### rev2 Training Simplified:
- Memory Optimization: Begins with clearing system memory to ensure efficient resource utilization.
- Hyperparameter Setup: Configures essential training parameters such as epoch count and batch size.
- Data Enrichment: Utilizes data augmentation techniques to introduce variability in the training dataset.
- Focused Training: Implements training on data subsets to reduce overfitting and streamline the learning process.
- Adaptive Learning Rate: Applies a dynamic learning rate schedule to fine-tune the training progression.
- Training Supervision: Uses callbacks for monitoring training, saving the best model, and enabling early stopping.
- Progressive Learning: Trains the model iteratively on subsets, evaluating and adjusting after each epoch.
- Data Standardization: Normalizes image inputs to facilitate model training.
- Robustness Enhancement: Introduces random noise to training images to strengthen model robustness against unseen data.
- While rev1 is suitable for quick and simple model training, rev2 is tailored for those seeking a more sophisticated and potentially more effective training regimen.## π Repository Structure
Please note that due to the large size of some files and folders, they are not available directly in the repository. However, they can be found in the [Releases](https://github.com/Aydinhamedi/Pneumonia-Detection-Ai/releases) page of the repository. This includes the model weights and the database, which are crucial for the functioning of the AI model.
## π€ Contribution
Any contributions to improve the project are welcome. You can submit a pull request or open an issue on GitHub. Please make sure to test your changes thoroughly before submitting. We appreciate your help in making this project better.
## β οΈ WARNING
> [!CAUTION]
The model provided in this project should not be used for medical diagnosis without further validation. While the model has shown high accuracy in detecting pneumonia from X-ray images, it is not a substitute for professional medical advice. Please consult with a healthcare professional for medical advice.## π Other
> [!NOTE]
> Please note that this code uses my:
> - Python-CLI-template
> - for more info go to https://github.com/Aydinhamedi/Python-CLI-template.
> - Python-color-print-V2
> - for more info go to https://github.com/Aydinhamedi/Python-color-print-V2.
> - Python-color-print
> - for more info go to https://github.com/Aydinhamedi/Python-color-print.## π Results
> [!WARNING]
> Results were achieved using Rev2 training method and Rev1.2 model and
> with `backup/V6/Model_T&T.ipynb` code.
### Acc:

### π· Grad cam:
| Model | Grad-cam Ex |
|----------|----------|
| V6 | |
| V7 light | π§Noneπ§|
| V8 super light | π§Noneπ§|
### π§ Other:

## π Citing
```bib
@software{Hamedi_Pneumonia-Detection-Ai,
author = {Aydin Hamedi},
license = {MIT},
title = {Pneumonia-Detection-Ai},
url = {https://github.com/Aydinhamedi/Pneumonia-Detection-Ai}
}
```## License
This project is open-source and is licensed under the MIT License. See the `LICENSE` file for details.