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
|
@@ -50,7 +50,6 @@ from tensorflow.keras.layers import Dense, GlobalAveragePooling2D, Dropout, Batc
|
|
| 50 |
from tensorflow.keras.models import Model
|
| 51 |
from huggingface_hub import hf_hub_download
|
| 52 |
|
| 53 |
-
# 1. นิยามโครงสร้างโมเดล (Model Architecture)
|
| 54 |
base_model = EfficientNetB0(weights=None, include_top=False, input_shape=(224, 224, 3))
|
| 55 |
x = base_model.output
|
| 56 |
x = GlobalAveragePooling2D()(x)
|
|
@@ -61,14 +60,11 @@ outputs = Dense(4, activation='softmax')(x)
|
|
| 61 |
|
| 62 |
model = Model(inputs=base_model.input, outputs=outputs)
|
| 63 |
|
| 64 |
-
# 2. ดาวน์โหลดและโหลดน้ำหนักโมเดลจาก Hugging Face
|
| 65 |
model_path = hf_hub_download(repo_id="starpreeda/BrainTumorTest", filename="efficientnetb0_finetuned_brain_mri.keras")
|
| 66 |
model.load_weights(model_path)
|
| 67 |
|
| 68 |
-
# 3. กำหนดรายชื่อคลาส
|
| 69 |
class_names = ['Glioma', 'Meningioma', 'No Tumor', 'Pituitary']
|
| 70 |
|
| 71 |
-
# 4. ฟังก์ชันสำหรับเตรียมรูปภาพและพยากรณ์ผล
|
| 72 |
def predict_mri(image_path):
|
| 73 |
img = Image.open(image_path).convert('RGB')
|
| 74 |
img = img.resize((224, 224))
|
|
@@ -81,11 +77,10 @@ def predict_mri(image_path):
|
|
| 81 |
|
| 82 |
return predicted_class, confidence
|
| 83 |
|
| 84 |
-
# ตัวอย่างการเรียกใช้งาน:
|
| 85 |
# class_label, conf = predict_mri("path/to/your/mri_scan.jpg")
|
| 86 |
# print(f"ผลการทำนาย: {class_label} ({conf:.2f}%)")
|
| 87 |
-
|
| 88 |
-
|
| 89 |
## ⚙️ Training Details & Hyperparameters
|
| 90 |
|
| 91 |
- **Optimizer:** Adam (Learning Rate = `1e-4`)
|
|
|
|
| 50 |
from tensorflow.keras.models import Model
|
| 51 |
from huggingface_hub import hf_hub_download
|
| 52 |
|
|
|
|
| 53 |
base_model = EfficientNetB0(weights=None, include_top=False, input_shape=(224, 224, 3))
|
| 54 |
x = base_model.output
|
| 55 |
x = GlobalAveragePooling2D()(x)
|
|
|
|
| 60 |
|
| 61 |
model = Model(inputs=base_model.input, outputs=outputs)
|
| 62 |
|
|
|
|
| 63 |
model_path = hf_hub_download(repo_id="starpreeda/BrainTumorTest", filename="efficientnetb0_finetuned_brain_mri.keras")
|
| 64 |
model.load_weights(model_path)
|
| 65 |
|
|
|
|
| 66 |
class_names = ['Glioma', 'Meningioma', 'No Tumor', 'Pituitary']
|
| 67 |
|
|
|
|
| 68 |
def predict_mri(image_path):
|
| 69 |
img = Image.open(image_path).convert('RGB')
|
| 70 |
img = img.resize((224, 224))
|
|
|
|
| 77 |
|
| 78 |
return predicted_class, confidence
|
| 79 |
|
|
|
|
| 80 |
# class_label, conf = predict_mri("path/to/your/mri_scan.jpg")
|
| 81 |
# print(f"ผลการทำนาย: {class_label} ({conf:.2f}%)")
|
| 82 |
+
```
|
| 83 |
+
```
|
| 84 |
## ⚙️ Training Details & Hyperparameters
|
| 85 |
|
| 86 |
- **Optimizer:** Adam (Learning Rate = `1e-4`)
|