Sambhavnoobcoder
commited on
Commit
·
83a0520
1
Parent(s):
b29832f
create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from tensorflow.keras.models import load_model
|
2 |
+
import numpy as np
|
3 |
+
import cv2
|
4 |
+
|
5 |
+
model = load_model('model-3.h5')
|
6 |
+
|
7 |
+
def predict_from_img(img):
|
8 |
+
img = cv2.cvtColor(img,cv2.COLOR_RGB2GRAY)
|
9 |
+
img = img/255.0
|
10 |
+
img = np.expand_dims(img,axis = 0)
|
11 |
+
output = model.predict(img)[0][0]
|
12 |
+
return {'NORMAL':float(output),'PNEUMONIA':float(1-output)}
|
13 |
+
|
14 |
+
import gradio as gr
|
15 |
+
image = gr.inputs.Image(shape=(150,150))
|
16 |
+
label = gr.outputs.Label(num_top_classes=2)
|
17 |
+
gr.Interface(fn=predict_from_img, inputs=image, outputs=label,title = 'PNEUMONIA-DETECTION').launch()
|