Spaces:
Sleeping
Sleeping
laylabitar
commited on
Commit
•
101c0cc
1
Parent(s):
b86152b
Added the interface for the model
Browse files- app.py +24 -4
- model1.pkl +3 -0
app.py
CHANGED
@@ -1,7 +1,27 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def
|
4 |
-
return
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
!pip install fastai
|
2 |
+
from fastai.vision.all import*
|
3 |
import gradio as gr
|
4 |
|
5 |
+
def ECG(x):
|
6 |
+
return x[0].isupper()
|
7 |
|
8 |
+
|
9 |
+
import pathlib
|
10 |
+
temp = pathlib.PosixPath
|
11 |
+
pathlib.PosixPath = pathlib.WindowsPath
|
12 |
+
from pathlib import Path
|
13 |
+
|
14 |
+
learn = load_learner(str(Path('model1.pkl')))
|
15 |
+
|
16 |
+
categories = ('bradycardia','tachycardia')
|
17 |
+
|
18 |
+
def classify_image(img):
|
19 |
+
pred,idx,probs = learn.predict(img)
|
20 |
+
return dict(zip(categories, map(float,probs)))
|
21 |
+
|
22 |
+
image = gr.inputs.Image(shape=(192,192))
|
23 |
+
label = gr.outputs.Label()
|
24 |
+
examples = ['bradycardia-ECG.jpg']
|
25 |
+
|
26 |
+
iface = gr.Interface(fn = classify_image, inputs = image, outputs = label, examples = examples)
|
27 |
+
iface.launch()
|
model1.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b3bd4a2299278f52c1d698db7f57e6502cf8ac8580603874a4e0cdd9fafcabbf
|
3 |
+
size 46961807
|