mahisourav36/brain-tumour-detection-using-DL

GitHub: mahisourav36/brain-tumour-detection-using-DL

基于 VGG16 迁移学习和 Flask 的脑肿瘤 MRI 图像检测系统,提供从模型训练到 Web 预测的完整流程。

Stars: 0 | Forks: 0

# 🧠 使用 AI 与机器学习进行脑肿瘤检测 ### 毕业设计 — CNN + Flask Web 应用程序 ## 📁 项目结构 ``` brain_tumour_detection/ ├── train_model.py ← CNN model training (VGG16 Transfer Learning) ├── app.py ← Flask web application ├── evaluate.py ← Detailed evaluation & clinical metrics ├── download_dataset.py ← Kaggle dataset auto-downloader ├── requirements.txt ← Python dependencies ├── templates/ │ └── index.html ← Web UI (dark medical theme) ├── models/ │ └── brain_tumour_cnn.h5 ← Saved model (generated after training) ├── dataset/ │ ├── yes/ ← Place tumour MRI images here │ └── no/ ← Place normal MRI images here ├── results/ │ ├── training_results.png │ ├── evaluation_charts.png │ └── metrics.json └── static/uploads/ ← User-uploaded images (auto-created) ``` ## ⚙️ 设置与运行 ### 1. 安装依赖项 ``` pip install -r requirements.txt ``` ### 2. 下载数据集 **选项 A — 自动(Kaggle API):** ``` # 将 kaggle.json 放置在 ~/.kaggle/ 中(从 kaggle.com → Settings → API 获取) python download_dataset.py ``` **选项 B — 手动:** 1. 从以下地址下载:https://www.kaggle.com/datasets/navoneel/brain-mri-images-for-brain-tumor-detection 2. 解压并将图像放置在 `dataset/yes/` 和 `dataset/no/` 中 ### 3. 训练模型 ``` python train_model.py ``` 这将: - 通过迁移学习训练 VGG16 CNN - 将最佳模型保存至 `models/brain_tumour_cnn.h5` - 在 `results/` 中生成性能图表 ### 4.(可选)运行评估 ``` python evaluate.py ``` ### 5. 启动 Web 应用程序 ``` python app.py ``` 打开:**http://localhost:5000** ## 🧪 模型工作原理 ``` MRI Image Input ↓ Image Preprocessing (resize 224x224, normalize) ↓ VGG16 Feature Extractor (ImageNet pretrained) ↓ Custom Classification Head (Dense → Dropout → Sigmoid) ↓ Binary Prediction: Tumour / No Tumour ↓ Grad-CAM Heatmap (explainability overlay) ``` ## 📊 预期结果 | 指标 | 预期数值 | |-------------|---------------| | Accuracy | ≥ 92% | | Sensitivity | ≥ 93% | | Specificity | ≥ 90% | | ROC-AUC | ≥ 0.96 | | F1 Score | ≥ 0.92 | ## 🌐 Web 应用程序功能 - 上传 MRI 扫描图像(PNG/JPG) - 实时 CNN 预测 - 置信度得分 + 风险等级 - **Grad-CAM 热力图** — 展示模型关注的区域 - UI 中嵌入的训练性能图表 - 推理时间显示 ## 📚 数据集 **Kaggle:用于脑肿瘤检测的大脑 MRI 图像** 链接:https://www.kaggle.com/datasets/navoneel/brain-mri-images-for-brain-tumor-detection 253 张图像 | 155 张肿瘤 | 98 张正常 ## ⚠️ 免责声明 本系统仅供**教育和研究目的使用**。 它不是经过认证的医疗设备,在没有专业医疗监督的情况下不得用于临床诊断。 ## 🛠️ 技术栈 `Python` · `TensorFlow/Keras` · `VGG16` · `OpenCV` · `Flask` · `Scikit-learn` · `Matplotlib` · `Seaborn`
标签:Flask, VGG16, 人工智能, 医疗辅助诊断, 图像分类, 深度学习, 用户模式Hook绕过, 自定义脚本, 逆向工具