Instructions to use starpreeda/BrainTumorTest with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use starpreeda/BrainTumorTest with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://starpreeda/BrainTumorTest") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -113,12 +113,21 @@ Input (224, 224, 3)
|
|
| 113 |
---
|
| 114 |
🚀 How to Load and Use
|
| 115 |
|
|
|
|
|
|
|
| 116 |
import tensorflow as tf
|
| 117 |
from tensorflow.keras.applications import EfficientNetB0
|
| 118 |
from tensorflow.keras.layers import Dense, GlobalAveragePooling2D, Dropout, BatchNormalization
|
| 119 |
from tensorflow.keras.models import Model
|
| 120 |
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
base_model = EfficientNetB0(weights=None, include_top=False, input_shape=(224, 224, 3))
|
| 123 |
x = base_model.output
|
| 124 |
x = GlobalAveragePooling2D()(x)
|
|
@@ -126,10 +135,9 @@ x = BatchNormalization()(x)
|
|
| 126 |
x = Dense(256, activation='relu')(x)
|
| 127 |
x = Dropout(0.4)(x)
|
| 128 |
outputs = Dense(4, activation='softmax')(x)
|
| 129 |
-
|
| 130 |
model = Model(inputs=base_model.input, outputs=outputs)
|
| 131 |
-
|
| 132 |
-
|
| 133 |
```
|
| 134 |
📊 Dataset & Training Data
|
| 135 |
|
|
|
|
| 113 |
---
|
| 114 |
🚀 How to Load and Use
|
| 115 |
|
| 116 |
+
import os
|
| 117 |
+
import urllib.request
|
| 118 |
import tensorflow as tf
|
| 119 |
from tensorflow.keras.applications import EfficientNetB0
|
| 120 |
from tensorflow.keras.layers import Dense, GlobalAveragePooling2D, Dropout, BatchNormalization
|
| 121 |
from tensorflow.keras.models import Model
|
| 122 |
|
| 123 |
+
weights_path = "efficientnetb0_finetuned_brain_mri.keras"
|
| 124 |
+
model_url = "https://huggingface.co/starpreeda/BrainTumorTest/resolve/main/efficientnetb0_finetuned_brain_mri.keras"
|
| 125 |
+
|
| 126 |
+
if not os.path.exists(weights_path):
|
| 127 |
+
print("Downloading model weights...")
|
| 128 |
+
urllib.request.urlretrieve(model_url, weights_path)
|
| 129 |
+
print("Download completed!")
|
| 130 |
+
|
| 131 |
base_model = EfficientNetB0(weights=None, include_top=False, input_shape=(224, 224, 3))
|
| 132 |
x = base_model.output
|
| 133 |
x = GlobalAveragePooling2D()(x)
|
|
|
|
| 135 |
x = Dense(256, activation='relu')(x)
|
| 136 |
x = Dropout(0.4)(x)
|
| 137 |
outputs = Dense(4, activation='softmax')(x)
|
|
|
|
| 138 |
model = Model(inputs=base_model.input, outputs=outputs)
|
| 139 |
+
model.load_weights(weights_path)
|
| 140 |
+
print("Model is ready for use!")
|
| 141 |
```
|
| 142 |
📊 Dataset & Training Data
|
| 143 |
|