File size: 1,276 Bytes
265d612
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: apache-2.0
---
# 🧠 Brain MRI Classification with TensorFlow and Streamlit

## 🇬🇧 English

This project is a deep learning-based solution for classifying Brain MRI images into four categories: **Glioma**, **Meningioma**, **Pituitary**, and **Normal**. The classification model is trained using TensorFlow/Keras and can be used either programmatically or with a Streamlit web interface.

### 🧪 Model Information

- Input shape: `(224, 224, 3)`
- Model format: `.keras` (SavedModel)
- Output classes:
  - 0: Glioma
  - 1: Meningioma
  - 2: Normal
  - 3: Pituitary

---

### 🧠 Example Usage (Python Script)

```python
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing import image
import numpy as np

# Load the trained model
model = load_model('brainmri.keras')

# Load and preprocess the image
img = image.load_img('example.jpeg', target_size=(224, 224))
img_array = image.img_to_array(img) / 255.0
img_array = np.expand_dims(img_array, axis=0)

# Define class labels
classes = {
    0: "Glioma",
    1: "Meningioma",
    2: "Normal",
    3: "Pituitary"
}

# Make prediction
result = model.predict(img_array)
predicted_class = np.argmax(result)

# Print result
print("Predicted Class:", classes.get(predicted_class))