Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import fastai
|
2 |
+
from fastai.vision.all import*
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
def is_cat(x):returnx[0].isupper()
|
6 |
+
|
7 |
+
learn=load_learner('model(1).pkl')
|
8 |
+
|
9 |
+
categories=('normal','pneumonia')
|
10 |
+
|
11 |
+
def classify_img(img):
|
12 |
+
pred,idx,probs=learn.predict(img)
|
13 |
+
return dict(zip(categories,map(float,probs)))
|
14 |
+
|
15 |
+
image =gr.inputs.Image(shape=(192,192))
|
16 |
+
label =gr.outputs.Label()
|
17 |
+
example=['Normal.jpg','pneumonia.jpg']
|
18 |
+
intf=gr.Interface(fn=classify_img,inputs=image,outputs=label,examples=example)
|
19 |
+
intf.launch(inline=False)
|