starpreeda commited on
Commit
4643a51
·
verified ·
1 Parent(s): 61b1ddc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +12 -4
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
- # Reconstruct Model Architecture
 
 
 
 
 
 
 
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
- # Load Weights
132
- model.load_weights("efficientnetb0_finetuned_brain_mri.keras")
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