File size: 985 Bytes
fadbcdd 6fbcada 3837337 6fbcada fadbcdd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
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_1.jpg"],
["example_images/Yes_2.jpg"],
["example_images/Yes_3.jpg"]
]
iface = gr.Interface(
fn=getResult,
inputs=gr.Image(shape=(64, 64)),
outputs=gr.Label(num_top_classes=2),
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
)
if __name__ == "__main__":
iface.launch() |