# π§ Brain Tumor Detection with Deep Learning
Welcome to the **Brain Tumor Detection** project! This repository contains a deep learning model that classifies brain images as either having a tumor or not. Dive into the power of convolutional neural networks (CNNs) and see how they can be used in medical imaging! π
## π Project Structure
```plaintext
brain-tumor-detection/
β
βββ brain_tumor_dataset/
β βββ no/ # Images without tumors
β βββ yes/ # Images with tumors
β
βββ Brain-tumor-detector.py # Model training and evaluation
βββ Brain-tumor-probability.py # Tumor probability prediction for a specific image
This project uses a CNN model to classify brain images into two categories:
- No tumor (stored in
brain_tumor_dataset/no
) - Tumor (stored in
brain_tumor_dataset/yes
)
-
Clone the repository:
git clone https://github.com/Armanx200/Brain-tumor-detector.git cd Brain-tumor-detector
-
Install dependencies:
pip install tensorflow opencv-python scikit-learn
-
Download the dataset:
- Ensure you have the brain tumor dataset in the correct structure as shown above.
Run the Brain-tumor-detector.py
script to train the model:
python Brain-tumor-detector.py
This script:
- Loads and preprocesses the dataset.
- Splits the data into training and testing sets.
- Builds and trains a CNN model.
- Evaluates the model and displays the test accuracy.
To predict the probability of a specific image having a tumor, use the Brain-tumor-probability.py
script:
-
Ensure the model is trained and saved as
brain_tumor_model.h5
. -
Run the prediction script:
python Brain-tumor-probability.py
This script will:
- Load the trained model.
- Preprocess the specified image.
- Output the probability of the image being a tumor.
The model achieves impressive accuracy on the test set. See the script output for detailed performance metrics.
- TensorFlow/Keras: For building and training the neural network.
- OpenCV: For image processing.
- Scikit-learn: For data splitting and preprocessing.
Below is an example of how the model predicts the probability of an image being a tumor:
Probability of the image being a tumor: 95.44%
Contributions are welcome! Please create a pull request or open an issue for any improvements or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for details.
Developed with β€οΈ by Armanx200