from PIL import Image import cv2 import numpy as np import tensorflow as tf from keras.models import load_model import gradio as gr model =load_model('BrainTumor10Epochs.h5') def getResult(inp): inp=np.array(inp) input_img = np.expand_dims(inp, axis=0) result=np.max(model.predict(input_img)) if result==0: return "No Brain Tumor" elif result==1: return "Yes Brain Tumor" examples = [ ["example_images/No_1.jpg"], ["example_images/No_2.jpg"], ["example_images/No_3.jpg"], ["example_images/Yes_2.jpg"], ["example_images/Yes_3.jpg"] ] iface = gr.Interface( fn=getResult, inputs=gr.Image(shape=(64, 64),label="MRI Image"), outputs=gr.Label(num_top_classes=2,label="Output"), title="Brain Tumor Classification", description="Upload the MRI Image of the Brain and it will tell whether it has a Brain Tumor or not", examples=examples, theme=gr.themes.Default(primary_hue="teal", secondary_hue="cyan"), allow_flagging=False ) if __name__ == "__main__": iface.launch()