File size: 2,466 Bytes
546a860
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
title: NeuroScope AI
sdk: docker
app_port: 7860
---

# Brain MRI Analysis System

A Flask-based web application that analyzes brain MRI images for tumor classification and segmentation.

## Features

- **MRI Image Upload**: Upload brain MRI images for analysis
- **Tumor Classification**: Identifies the type of tumor (glioma, meningioma, pituitary) or confirms no tumor
- **Tumor Segmentation**: Visualizes the tumor area with an overlay if present
- **Medical Summary**: Provides a brief summary of the findings
- **Analysis History**: Stores all analyses for future reference

## Technical Stack

- **Backend**: Flask (Python)
- **Frontend**: HTML, Tailwind CSS
- **Database**: SQLite
- **Machine Learning**: TensorFlow/Keras
- **Models**: 
  - Brain MRI classification model (brain_mri.h5)
  - U-Net segmentation model (Unet_model.h5)

## Setup Instructions

1. **Clone the repository**

2. **Install dependencies**
   ```
   pip install -r requirements.txt
   ```

3. **Download the pre-trained models**
   - Place the models in the root directory:
     - `brain_mri.h5` (classification model)
     - `Unet_model.h5` (segmentation model)

4. **Initialize the database**
   - The database will be automatically created when you run the application for the first time

5. **Run the application**
   ```
   export OPENROUTER_API_KEY=your_openrouter_api_key
   python app.py
   ```

6. **Access the application**
   - Open a web browser and go to `http://127.0.0.1:5000/`

## Project Structure

```
β”œβ”€β”€ app.py                  # Main Flask application file
β”œβ”€β”€ brain_mri.db            # SQLite database (created automatically)
β”œβ”€β”€ brain_mri.h5            # Classification model
β”œβ”€β”€ Unet_model.h5           # Segmentation model
β”œβ”€β”€ requirements.txt        # Dependencies
β”œβ”€β”€ static/                 # Static files
β”‚   β”œβ”€β”€ uploads/            # Uploaded MRI images
β”‚   └── results/            # Generated results
└── templates/              # HTML templates
    β”œβ”€β”€ base.html           # Base template
    β”œβ”€β”€ index.html          # Homepage
    β”œβ”€β”€ result.html         # Results page
    └── history.html        # Analysis history page
```

## Notes

- This application is for educational purposes only and should not be used for actual medical diagnosis.
- The result summary uses OpenRouter through the OpenAI-compatible Python client and expects `OPENROUTER_API_KEY` to be set.