File size: 546 Bytes
83a0520
 
 
4c317e4
 
83a0520
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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()