ct-i-rad / app.py
chidojawbreaker's picture
Update app.py
fb2c01a
raw
history blame contribute delete
No virus
1.19 kB
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(Image):
test_image = tf.image.resize(Image,[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
title = "CT-iRAD"
description = "Welcome to CT-iRAD -- a web based decision support system for radiologists when screening lung diseases -- COVID-19, LUNG CANCER and PNEUMONIA -- in CT images. Please Upload the CT scan image for screening below."
examples = [
["covid.jpg"],
["healthy.jpg"],
["lung cancer.jpg"],
["pneumonia.jpg"]
]
iRAD = gr.Interface(predict,"image","text",
title=title,description=description,examples=examples,theme="peach")
iRAD.launch()