File size: 766 Bytes
437e081
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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}