This project is a Brain Tumor Detection system that uses MRI scans to detect and visualize tumors. The application is built using Python with a graphical user interface (GUI) created using Tkinter. The system allows users to upload MRI images, detect the presence of tumors, and visualize the tumor region in the image using pre-trained machine learning models and image processing techniques.
- Image Upload: Upload MRI images using a file browser.
- Tumor Detection: Automatically detect the presence of brain tumors using a pre-trained model.
- Tumor Visualization: View the region of the detected tumor in the MRI image.
- User-Friendly GUI: A simple interface to interact with the system and display results.
- Real-time Results: Instant feedback on the detection results and visualization of tumor regions.
To run the Brain Tumor Detection system locally, follow the steps below:
-
Clone the Repository:
git clone https://github.com/yourusername/brain-tumor-detection.git cd brain-tumor-detection -
Install Required Libraries: Install the necessary Python packages using
pip:pip install -r requirements.txt
-
Run the Application: After installing the dependencies, run the
gui.pyfile to start the GUI:python gui.py
- Browse Image: Click the
Browsebutton to upload an MRI image file (formats supported:.jpg,.png,.jpeg). - Select an Option:
- Choose the Detect Tumor option to detect whether a tumor is present in the MRI scan.
- Choose the View Tumor Region option to visualize the tumor region on the MRI image.
- View Results:
- If a tumor is detected, a message will be displayed: "Tumor Detected" (in red) or "No Tumor" (in green).
- The detected tumor region will be highlighted and displayed on the MRI image.
The project directory is structured as follows:
brain-tumor-detection/
│
├── frames.py # Handles the GUI frames and image display logic
├── displayTumor.py # Contains methods for tumor visualization
├── predictTumor.py # Performs brain tumor prediction
├── gui.py # Main file that runs the GUI application
├── README.md # This README file
├── requirements.txt # List of required dependencies
└── assets/ # Contains example MRI images (if any)
gui.py: The main entry point of the project. Initializes the GUI and manages user interactions.frames.py: Defines theFramesclass, which manages the GUI frames, image handling, and event bindings.predictTumor.py: Defines thepredictTumor()function that processes the MRI image and detects the presence of a tumor using a pre-trained machine learning model.displayTumor.py: Implements methods to visualize and highlight tumor regions in MRI images.
- The user uploads an MRI image by clicking the Browse button, which opens a file dialog to select an image. The selected image is loaded and displayed in the GUI.
- The user can select the Detect Tumor option to check if the MRI image contains a tumor.
- The
predictTumor()function (defined inpredictTumor.py) is called, which uses a machine learning model (e.g., a convolutional neural network) to classify the MRI image as having a tumor or not. - Based on the prediction, a message "Tumor Detected" (in red) or "No Tumor" (in green) is displayed on the GUI.
- If the user selects the View Tumor Region option, the system will visualize the tumor region on the MRI image.
- The
DisplayTumorclass (defined indisplayTumor.py) processes the MRI image by removing noise and highlighting the tumor region. - The processed image is then displayed on the GUI, allowing the user to see where the tumor is located.
- The application uses the
Framesclass (fromframes.py) to manage different frames (sections of the GUI) and handle image loading, button interactions, and switching between different functionalities (e.g., detection vs. visualization). - The
NextWindow()method is used to transition between frames when the user clicks the View button to see the next step of processing.
The following dependencies are required to run this project:
- Python 3.9
- Tkinter (for GUI)
- OpenCV (
cv2for image processing) - Pillow (
PILfor image handling) - Numpy (for handling arrays)
- Pre-trained machine learning model for brain tumor detection (e.g., VGG16, Xception)
To install all required dependencies, run:
pip install -r requirements.txt