Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from PIL import Image
|
2 |
+
import cv2
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
import tensorflow as tf
|
6 |
+
from keras.models import load_model
|
7 |
+
|
8 |
+
import gradio as gr
|
9 |
+
|
10 |
+
model =load_model('BrainTumor10Epochs.h5')
|
11 |
+
|
12 |
+
def getResult(inp):
|
13 |
+
|
14 |
+
inp=np.array(inp)
|
15 |
+
input_img = np.expand_dims(inp, axis=0)
|
16 |
+
result=np.max(model.predict(input_img))
|
17 |
+
|
18 |
+
if result==0:
|
19 |
+
return "No Brain Tumor"
|
20 |
+
elif result==1:
|
21 |
+
|
22 |
+
return "Yes Brain Tumor"
|
23 |
+
|
24 |
+
|
25 |
+
iface=gr.Interface(fn=getResult,
|
26 |
+
inputs=gr.Image(shape=(64, 64)),
|
27 |
+
outputs=gr.Label(num_top_classes=2),
|
28 |
+
)
|
29 |
+
if __name__ == "__main__":
|
30 |
+
iface.launch()
|