Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -3,81 +3,48 @@ title: Brain Tumor Detection
|
|
| 3 |
emoji: 🐢
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: green
|
| 6 |
-
sdk:
|
| 7 |
-
sdk_version: 5.42.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
|
| 12 |
-
|
| 13 |
-
🧠 Brain Tumor Detection (Multi-Modal)
|
| 14 |
-
This is a Gradio-based web app for detecting brain tumors using a multi-modal deep learning model. The app supports two modes:
|
| 15 |
|
| 16 |
-
|
| 17 |
-
Multi-Modal Mode: Combines MRI images (processed via CNN) and tabular patient data (processed via MLP) for enhanced predictions.
|
| 18 |
|
| 19 |
-
Features
|
| 20 |
|
| 21 |
-
Upload
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
Multi-modal model if both image and tabular data are provided.
|
| 26 |
|
|
|
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
-
Enter Patient Data (Optional): Input numerical values for the 17 features extracted from the image or patient records. Leave blank for image-only prediction.
|
| 34 |
-
Submit: Click the submit button to get the prediction.
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
MLP branch: 2 dense layers (64, 32 units) for tabular data.
|
| 42 |
-
Combined features fed to a final dense layer with sigmoid activation.
|
| 43 |
|
|
|
|
| 44 |
|
| 45 |
-
|
|
|
|
| 46 |
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
CNN-Only Model:
|
| 49 |
-
Architecture: 3 convolutional layers (32, 64, 128 filters) with ReLU, max-pooling, dropout, and a final dense layer with sigmoid activation.
|
| 50 |
-
Inputs: MRI image (128x128, grayscale).
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
Training Data: Brain Tumor dataset (images) + tabular features from bt_dataset_t3.csv.
|
| 54 |
-
Preprocessing:
|
| 55 |
-
Images: Grayscale, resized to 128x128, normalized to [0,1].
|
| 56 |
-
Tabular: Standardized using StandardScaler.
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
Metrics: Binary classification (Tumor vs. No Tumor).
|
| 60 |
-
|
| 61 |
-
Installation (For Local Development)
|
| 62 |
-
|
| 63 |
-
Clone this repository.
|
| 64 |
-
Install dependencies: pip install -r requirements.txt
|
| 65 |
-
Run the app: python app.py
|
| 66 |
-
|
| 67 |
-
Deployment
|
| 68 |
-
|
| 69 |
-
Deploy on Hugging Face Spaces.
|
| 70 |
-
Ensure multi_modal_brain_tumor_model.h5, cnn_only_brain_tumor_model.h5, and scaler.pkl are included in the repository.
|
| 71 |
-
|
| 72 |
-
Notes
|
| 73 |
-
|
| 74 |
-
Ensure the MRI image is in JPG format and matches the training data format (grayscale, 128x128).
|
| 75 |
-
Tabular inputs are optional. If provided, they must be numeric and correspond to the 17 features used during training.
|
| 76 |
-
The app automatically switches to the CNN-only model if tabular data is not provided.
|
| 77 |
-
Model files (multi_modal_brain_tumor_model.h5, cnn_only_brain_tumor_model.h5) and scaler (scaler.pkl) must be present in the same directory.
|
| 78 |
-
|
| 79 |
-
Acknowledgments
|
| 80 |
-
|
| 81 |
-
Built with Gradio and TensorFlow.
|
| 82 |
-
Dataset inspired from Kaggle Brain Tumor features and images.
|
| 83 |
|
|
|
|
| 3 |
emoji: 🐢
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: green
|
| 6 |
+
sdk: streamlit
|
|
|
|
| 7 |
app_file: app.py
|
| 8 |
pinned: false
|
| 9 |
---
|
| 10 |
|
| 11 |
+
# 🧠 Brain Tumor Detection (CNN Only)
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
This is a **Streamlit-based web app** for detecting brain tumors using a **CNN model** trained on MRI images. The app only uses **image input** for prediction — tabular data is not required.
|
|
|
|
| 14 |
|
| 15 |
+
## Features
|
| 16 |
|
| 17 |
+
- Upload a brain MRI image (`.jpg`, `.jpeg`, `.png`).
|
| 18 |
+
- Predicts **Benign** or **Malignant** tumors.
|
| 19 |
+
- Uses a CNN trained on grayscale MRI images resized to 128x128 pixels.
|
| 20 |
+
- Lightweight and fast — suitable for deployment on Hugging Face Spaces.
|
|
|
|
| 21 |
|
| 22 |
+
## How to Use
|
| 23 |
|
| 24 |
+
1. **Upload MRI Image:** Select a brain MRI image (JPG, JPEG, or PNG format).
|
| 25 |
+
2. **View Prediction:** The app will display the uploaded image and predict:
|
| 26 |
+
- **Benign**
|
| 27 |
+
- **Malignant**
|
| 28 |
|
| 29 |
+
The prediction is displayed directly in the app.
|
| 30 |
|
| 31 |
+
## Model Details
|
|
|
|
|
|
|
| 32 |
|
| 33 |
+
- **CNN Architecture:**
|
| 34 |
+
- 3 convolutional layers (32, 64, 128 filters) with ReLU activation
|
| 35 |
+
- Max-pooling and dropout layers for regularization
|
| 36 |
+
- Final dense layer with sigmoid activation
|
| 37 |
|
| 38 |
+
- **Input:** Grayscale MRI image, resized to 128x128, normalized to `[0,1]`
|
| 39 |
+
- **Training Dataset:** Brain Tumor images only
|
| 40 |
+
- **Metrics:** Binary classification (Tumor vs. No Tumor)
|
|
|
|
|
|
|
| 41 |
|
| 42 |
+
## Installation (For Local Development)
|
| 43 |
|
| 44 |
+
1. Clone the repository.
|
| 45 |
+
2. Install dependencies:
|
| 46 |
|
| 47 |
+
```bash
|
| 48 |
+
pip install -r requirements.txt
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|