Spaces:
Sleeping
Sleeping
kswanjitsu
commited on
Commit
•
788c023
1
Parent(s):
8f5cd9f
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../colo_app.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['learn', 'image', 'label', 'examples', 'intf', 'classify_img']
|
5 |
+
|
6 |
+
# %% ../colo_app.ipynb 1
|
7 |
+
from fastai.vision.all import *
|
8 |
+
import gradio as gr
|
9 |
+
|
10 |
+
# %% ../colo_app.ipynb 4
|
11 |
+
learn = load_learner('export.pkl')
|
12 |
+
|
13 |
+
# %% ../colo_app.ipynb 7
|
14 |
+
def classify_img(img):
|
15 |
+
pred, cl, probs = learn.predict(img)
|
16 |
+
|
17 |
+
prob0 = float(probs[0])
|
18 |
+
prob1 = float(probs[1])
|
19 |
+
|
20 |
+
d = {
|
21 |
+
"This is a colonoscopy photo --- probability:":prob0,
|
22 |
+
"This is not a colonoscopy photo --- probability:":prob1
|
23 |
+
}
|
24 |
+
return d
|
25 |
+
|
26 |
+
# %% ../colo_app.ipynb 9
|
27 |
+
image = gr.inputs.Image(shape=(192,192))
|
28 |
+
label = gr.outputs.Label()
|
29 |
+
examples = ['colonoscopy.jpg','colonoscopy2.jpg','colonoscopy3.jpg','colonoscopy4.jpg', 'white_square.jpg','dog.jpeg','pinkroundball.jpeg','earthworm.jpg']
|
30 |
+
|
31 |
+
intf=gr.Interface(fn=classify_img, inputs=image, outputs=label, examples=examples)
|
32 |
+
intf.launch(inline=False)
|
33 |
+
|