ct-i-rad / app.py
chidojawbreaker's picture
Update app.py
c9466f2
raw
history blame
No virus
813 Bytes
import gradio as gr
import numpy as np
import tensorflow as tf
from tensorflow.keras.preprocessing import image
model = tf.keras.models.load_model('model.hdf5')
def predict(img_path):
test_image = image.load_img(img_path, target_size=(224,224))
test_image = image.img_to_array(test_image)
test_image = test_image/255.0
test_image = np.expand_dims(test_image, axis = 0)
prediction = model.predict(test_image)
result = np.argmax(prediction, axis=1)
if result[0] == 0:
prediction = 'COVID DETECTED'
elif result[0] == 1:
prediction = 'HEALTHY'
elif result[0] == 2:
prediction = 'LUNG CANCER DETECTED'
else:
prediction = 'PNEUMONIA DETECTED'
return prediction
iface = gr.Interface(fn=predict, inputs="text", outputs="text")
iface.launch()