import gradio as gr from PIL import Image import numpy as np import tensorflow as tf class_names = ['Covid19','Normal','Viral Pneumonia'] def process_image(image): image = image.resize((224,224)) image = np.array(image) / 255.0 image = np.expand_dims(image, axis=0) # (224,224,3) return image model = tf.keras.models.load_model('Covid19_Model.h5') def predict_image(image): processed_image = process_image(image) prediction = model.predict(processed_image) predicted_class_index = np.argmax(prediction) # ---> [0.23,0.58,0.86] predicted_class_name = class_names[predicted_class_index] return f"Prediction: {predicted_class_name}" examples = ['Samples/064.jpeg', 'Samples/072.jpeg', 'Samples/076.jpeg'] # Samples\076.jpeg interface = gr.Interface(fn= predict_image, inputs= gr.Image(type="pil"), outputs='text', title= "Covid19, Viral pneumonia or Normal", description="import an image to get predictions", examples=examples) interface.launch()