Instructions to use agcaabdurrahim/tumor_model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use agcaabdurrahim/tumor_model with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://agcaabdurrahim/tumor_model") - Notebooks
- Google Colab
- Kaggle
File size: 905 Bytes
647ebc1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
from tensorflow.keras.models import load_model
model = load_model('my_model.keras')
model.summary()
def predict(img_path):
class_dict = {'glioma': 0, 'meningioma': 1, 'notumor': 2, 'pituitary': 3}
label = list(class_dict.keys())
plt.figure(figsize=(12, 12))
img = Image.open(img_path)
resized_img = img.resize((299, 299))
img = np.asarray(resized_img)
img = np.expand_dims(img, axis=0)
img = img / 255
predictions = model.predict(img)
probs = list(predictions[0])
labels = label
plt.subplot(2, 1, 1)
plt.imshow(resized_img)
plt.subplot(2, 1, 2)
bars = plt.barh(labels, probs)
plt.xlabel('Olasılık', fontsize=15)
ax = plt.gca()
ax.bar_label(bars, fmt = '%.2f')
plt.show()
predict("Testing/notumor/Te-no_0010.jpg") |