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." iRAD = gr.Interface(fn=predict, inputs="image", outputs="text", theme="darkhuggingface", title=title,description=description) iRAD.launch()