Spaces:
Sleeping
Sleeping
import tensorflow as tf | |
import tf_keras | |
model_mri = tf_keras.models.load_model('model') | |
def load_image_with_path(path): | |
img = tf.io.read_file(path) | |
img = tf.image.decode_image(img, channels=3) | |
img = tf.image.resize(img, size=[256, 256]) | |
img = img / 255. | |
return img | |
def makepredictions(path): | |
print(path) | |
img = load_image_with_path(path) | |
predictions = model_mri.predict(tf.expand_dims(img, axis=0)) | |
a = int(tf.argmax(tf.squeeze(predictions))) | |
if a == 0: | |
a = "Result : Glioma Tumor" | |
elif a == 1: | |
a = "Result : Meningioma Tumor" | |
elif a == 2: | |
a = "Result : No Tumor" | |
else: | |
a = "Result : Pituitary Tumor" | |
return a | |
# {'glioma': 0, 'meningioma': 1, 'notumor': 2, 'pituitary': 3} | |