Spaces:
Runtime error
Runtime error
laylabitar
commited on
Commit
•
d363e89
1
Parent(s):
fe968ae
adding the working model interface
Browse files- app.py +35 -0
- bradycardia-ECG.jpg +0 -0
- model2.pkl +3 -0
- tachycardia.jpg +0 -0
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../app2.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['temp', 'learn', 'categories', 'image', 'label', 'examples', 'iface', 'ECG', 'classify_image']
|
5 |
+
|
6 |
+
# %% ../app2.ipynb 2
|
7 |
+
from fastai.vision.all import*
|
8 |
+
import gradio as gr
|
9 |
+
|
10 |
+
def ECG(x):
|
11 |
+
return x[0].isupper()
|
12 |
+
|
13 |
+
# %% ../app2.ipynb 4
|
14 |
+
import pathlib
|
15 |
+
temp = pathlib.PosixPath
|
16 |
+
pathlib.PosixPath = pathlib.WindowsPath
|
17 |
+
from pathlib import Path
|
18 |
+
|
19 |
+
learn = load_learner(str(Path('model2.pkl')))
|
20 |
+
|
21 |
+
|
22 |
+
# %% ../app2.ipynb 6
|
23 |
+
categories = ('bradycardia','tachycardia')
|
24 |
+
|
25 |
+
def classify_image(img):
|
26 |
+
pred,idx,probs = learn.predict(img)
|
27 |
+
return dict(zip(categories, map(float,probs)))
|
28 |
+
|
29 |
+
# %% ../app2.ipynb 8
|
30 |
+
image = gr.inputs.Image(shape=(192,192))
|
31 |
+
label = gr.outputs.Label()
|
32 |
+
examples = ['bradycardia-ECG.jpg', 'tachycardia.jpg']
|
33 |
+
|
34 |
+
iface = gr.Interface(fn = classify_image, inputs = image, outputs = label, examples = examples)
|
35 |
+
iface.launch()
|
bradycardia-ECG.jpg
ADDED
model2.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:102dba94e9492f40f372fd86b8bf460a129d37821f29367d0cbbeba4ae9ee6f2
|
3 |
+
size 46960341
|
tachycardia.jpg
ADDED