Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/majidraimi/chest-xray-pneumonia-classifications
Building a image classification model using chest xray images with tensorflow ๐ช
https://github.com/majidraimi/chest-xray-pneumonia-classifications
Last synced: 4 days ago
JSON representation
Building a image classification model using chest xray images with tensorflow ๐ช
- Host: GitHub
- URL: https://github.com/majidraimi/chest-xray-pneumonia-classifications
- Owner: MajidRaimi
- License: mit
- Created: 2023-11-28T18:14:56.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-01T14:40:22.000Z (about 1 year ago)
- Last Synced: 2024-11-08T00:15:48.766Z (about 2 months ago)
- Language: Jupyter Notebook
- Size: 13.8 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Chest X-Ray Image Classification ๐๐
Welcome to the Chest X-Ray Image Classification project! This endeavor represents the culmination of our exploration into the realm of Deep Learning within the context of the **ARTI 502** course. As a final project for this course, our objective is to employ a Convolutional Neural Network (CNN) model to effectively classify chest X-ray images into two distinct categories: "Normal" and "Pneumonia." This undertaking not only showcases our understanding of deep learning principles but also demonstrates the practical application of these concepts in the domain of medical image analysis.
Join us on this journey as we leverage advanced techniques to enhance diagnostic capabilities, contributing to the intersection of artificial intelligence and healthcare. Together, let's unravel the potential of deep learning in accurately identifying health conditions through the analysis of chest X-ray images.
## Project Structure ๐```
- data/
- images/
- normal/
- pneumonia/
- env/
- .gitignore
- logs/
- models/
- main.ipynb
- README.md
- requirements.txt
```The `data` directory contains two subdirectories, `normal` and `pneumonia`, each containing a large number of chest X-ray images for training and testing the model.
## Report ๐
You can find the final report for this project [here](./report.md).## Model Architecture ๐ง
```python
model = Sequential()model.add(Conv2D(16, (3,3), 1, activation='relu', input_shape=(256, 256, 3)))
model.add(MaxPooling2D())
model.add(Conv2D(32, (3,3), 1, activation='relu'))
model.add(MaxPooling2D())
model.add(Conv2D(16, (3,3), 1, activation='relu'))
model.add(MaxPooling2D())
model.add(Flatten())
model.add(Dense(256, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
```This CNN architecture consists of three convolutional layers with max-pooling, followed by a flattening layer and two dense layers. The final layer uses the sigmoid activation function for binary classification.
## Dataset ๐ผ๏ธ
**Chest X-Ray Images (Pneumonia)**
[Dataset Link](https://www.kaggle.com/datasets/paultimothymooney/chest-xray-pneumonia/)The `normal` and `pneumonia` folders within the `data/images/` directory contain a substantial number of chest X-ray images for both normal and pneumonia cases.
## Installing Dependencies ๐ ๏ธ
To set up the required dependencies, run:
```bash
pip install -r requirements.txt
```## Usage ๐
1. Open `main.ipynb` to explore the data, preprocess it, and train the model.
2. The model is trained using TensorFlow. Ensure you have GPU support for faster training.## Training the Model ๐๏ธโโ๏ธ
Adjust the number of epochs and other parameters as needed:
```python
history = model.fit(train, epochs=24, validation_data=val, callbacks=[tensorboard_callback])
```## Model Evaluation ๐
After training, the model's precision, recall, and accuracy can be evaluated using the test dataset.
```python
print('Precision: ', pre.result().numpy())
print('Recall: ', rec.result().numpy())
print('Accuracy: ', acc.result().numpy())
```## Testing the Model ๐งช
Test the model by using the provided `predict` function:
```python
predict('data/images/normal/IM-0001-0001.jpeg') # Output: Normal
predict('data/images/pneumonia/person1_bacteria_1.jpeg') # Output: Pneumonia
```## Save and Load Model โฌ๏ธ
Save the trained model for future use:
```python
model.save('models/main_model.keras')
```Load the saved model:
```python
new_model = load_model('models/main_model.keras')
```## Contributors (Group 4) ๐ฅ
- **Majid Saleh Al-Raimi**
- **Rashid Sami Al-Binali**
- **Mashari Adel Al-Jiban**
- Alwaleed Ahmad Al-Qurashi
- Mahmoud Sahal Noor
- Abdulrahman Sami Al-Juhani## Hardware Specifications ๐ป
- **Processor:** Apple M2 chip
- **Memory:** 16 GB RAM
- **Storage:** 512 GB SSD
- **Operating System:** macOS Sonoma 14.1.1## License ๐
This project is licensed under the MIT License - see the [LICENSE.md](./LICENSE) file for details.
Feel free to customize and expand upon this project. Happy coding! ๐๐ค