This project leverages Machine Learning and Computer Vision techniques to detect tumors in MRI scans and analyze patient testimonials through unsupervised clustering.
- Tumor Detection (Supervised Learning): Classifies MRI scans into categories such as Healthy, Glioma, Meningioma, Pituitary, or general Tumor using an SVM model.
- Testimonial Analysis (Unsupervised Learning): Clusters patient testimonials using NLP (TF-IDF + K-Means) to identify common themes and concerns.
- Web Interface: A FastAPI-based web application for easy interaction with the models.
- Advanced Preprocessing: Uses adaptive histogram equalization and TV Chambolle denoising to enhance MRI image quality.
- Feature Extraction: Implements GLCM (Gray-Level Co-occurrence Matrix) for texture analysis and HOG (Histogram of Oriented Gradients).
scripts/: Contains the core application logic and training scripts.api.py: FastAPI web server.supervised_training.py: Script to train the SVM model for tumor detection.unsupervised_learning.py/train_model_unsupervised_learning.py: Scripts for testimonial clustering.
dataset_exploration.ipynb: Notebook for initial data analysis.supervised_learning.ipynb: Detailed workflow for tumor detection training.unsupervised_learning.ipynb: Workflow for testimonial clustering.test_*.ipynb: Experimental notebooks for various CV techniques (blob detection, corner detection, etc.).templates/: HTML templates for the web interface.
The MRI dataset consists of 5,000 images:
- 3,000 images showing tumors.
- 2,000 healthy images.
The data is categorized into:
- Healthy
- Glioma
- Meningioma
- Pituitary
- Tumor
##️ Setup & Installation
- Python 3.8+
- Recommended: A virtual environment (venv or conda)
-
Clone the repository:
git clone <repository-url> cd <repository-folder>
-
Install dependencies:
pip install -r requirements.txt
- To train the supervised tumor detection model:
python scripts/supervised_training.py
- To train the unsupervised testimonial clustering model:
python scripts/train_model_unsupervised_learning.py
Start the FastAPI server:
python scripts/api.pyOr using uvicorn:
uvicorn scripts.api:app --reloadThe app will be available at http://127.0.0.1:8000.
- Preprocessing: Grayscale conversion, resizing to 256x256, and denoising.
- Feature Engineering: Texture features extracted via GLCM and shape features via HOG.
- Classification: A Support Vector Machine (SVM) classifier trained on the extracted features.
- Text Cleaning: Normalization and removal of non-alphabetic characters.
- Vectorization: TF-IDF (Term Frequency-Inverse Document Frequency).
- Clustering: K-Means clustering to group similar testimonials.