Sambhavnoobcoder's picture
changed grade import to the top.
4c317e4 verified
raw
history blame contribute delete
No virus
546 Bytes
from tensorflow.keras.models import load_model
import numpy as np
import cv2
import gradio as gr
model = load_model('model-3.h5')
def predict_from_img(img):
img = cv2.cvtColor(img,cv2.COLOR_RGB2GRAY)
img = img/255.0
img = np.expand_dims(img,axis = 0)
output = model.predict(img)[0][0]
return {'NORMAL':float(output),'PNEUMONIA':float(1-output)}
image = gr.inputs.Image(shape=(150,150))
label = gr.outputs.Label(num_top_classes=2)
gr.Interface(fn=predict_from_img, inputs=image, outputs=label,title = 'PNEUMONIA-DETECTION').launch()