Spaces:
Sleeping
Sleeping
import tensorflow as tf | |
import tf_keras | |
model_mri = tf_keras.models.load_model('model') | |
model_xray = tf_keras.models.load_model('xray_resnet_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} | |
def xray_predict(path): | |
img = load_image_with_path(path) | |
predications = model_xray.predict(tf.expand_dims(img, axis=0)) | |
a = int(tf.argmax(tf.squeeze(predications))) | |
xray_classes = ['COVID19','NORMAL', 'PNEUMONIA',' TURBERCULOSIS'] | |
a = xray_classes[a] | |
return a | |
# {'COVID19': 0, 'NORMAL': 1, 'PNEUMONIA': 2, 'TURBERCULOSIS': 3} |