vishal2023 commited on
Commit
3a69ee4
·
1 Parent(s): e68064d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from keras.models import load_model
2
+ from tensorflow.keras.utils import load_img, img_to_array
3
+ import numpy as np
4
+ import cv2
5
+
6
+ model = load_model('/little_imporved_model.h5')
7
+
8
+ def predict_from_img(img):
9
+ img = cv2.cvtColor(img,cv2.COLOR_RGB2GRAY)
10
+ img = img/255.0
11
+ img = np.expand_dims(img,axis = 0)
12
+ output = model.predict(img)[0][0]
13
+ return {'NORMAL':float(output),'PNEUMONIA':float(1-output)}
14
+
15
+ import gradio as gr
16
+ image = gr.inputs.Image(shape=(150,150))
17
+ label = gr.outputs.Label(num_top_classes=2)
18
+ gr.Interface(fn=predict_from_img, inputs=image, outputs=label).launch(share=True)