updated version
Browse files
README.md
CHANGED
@@ -78,3 +78,38 @@ The model predicts one of the following four categories:
|
|
78 |
### Installation
|
79 |
```bash
|
80 |
pip install tensorflow huggingface_hub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
### Installation
|
79 |
```bash
|
80 |
pip install tensorflow huggingface_hub
|
81 |
+
```
|
82 |
+
|
83 |
+
|
84 |
+
```python
|
85 |
+
from tensorflow.keras.models import load_model
|
86 |
+
from huggingface_hub import hf_hub_download
|
87 |
+
import numpy as np
|
88 |
+
from tensorflow.keras.preprocessing import image
|
89 |
+
|
90 |
+
# Download model file from Hugging Face Hub
|
91 |
+
model_path = hf_hub_download(
|
92 |
+
repo_id="larrikin-coder/brain-tumor-cnn", # replace with your repo
|
93 |
+
filename="cnn_model.h5"
|
94 |
+
)
|
95 |
+
|
96 |
+
# Load model
|
97 |
+
model = load_model(model_path)
|
98 |
+
|
99 |
+
# Preprocess an image
|
100 |
+
img = image.load_img("test_mri.jpg", target_size=(224, 224))
|
101 |
+
img_array = image.img_to_array(img) / 255.0
|
102 |
+
img_array = np.expand_dims(img_array, axis=0)
|
103 |
+
|
104 |
+
# Predict
|
105 |
+
pred = model.predict(img_array)
|
106 |
+
class_names = ["glioma", "meningioma", "pituitary", "no_tumor"]
|
107 |
+
print("Prediction:", class_names[np.argmax(pred)])
|
108 |
+
```
|
109 |
+
|
110 |
+
@misc{larrikin-coder2025,
|
111 |
+
title={CNN Brain Tumor Classifier},
|
112 |
+
author={Larrikin Coder},
|
113 |
+
year={2025},
|
114 |
+
howpublished={\url{https://huggingface.co/larrikin-coder/brain-tumor-cnn}}
|
115 |
+
}
|