Views
No views yet
categorical_crossentropyAdam| Metric | Value |
|---|---|
| Training Accuracy | ~96% |
| Validation Accuracy | ~85–90% |
| AUC (training) | ~0.90 |
pip install tensorflow huggingface_hub1from tensorflow.keras.models import load_model
2from huggingface_hub import hf_hub_download
3import numpy as np
4from tensorflow.keras.preprocessing import image
5
6# Download model file from Hugging Face Hub
7model_path = hf_hub_download(
8 repo_id="larrikin-coder/brain-tumor-cnn", # replace with your repo
9 filename="cnn_model.h5"
10)
11
12# Load model
13model = load_model(model_path)
14
15# Preprocess an image
16img = image.load_img("test_mri.jpg", target_size=(224, 224))
17img_array = image.img_to_array(img) / 255.0
18img_array = np.expand_dims(img_array, axis=0)
19
20# Predict
21pred = model.predict(img_array)
22class_names = ["glioma", "meningioma", "pituitary", "no_tumor"]
23print("Prediction:", class_names[np.argmax(pred)])