initial version
Browse files- app.py +27 -0
- corn_01.jpg +0 -0
- corn_02.jpg +0 -0
- corn_03.jpg +0 -0
- export.pkl +3 -0
- no_corn_01.jpg +0 -0
- no_corn_02.jpg +0 -0
- requirements.txt +1 -0
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
|
4 |
+
learn = load_learner("export.pkl")
|
5 |
+
|
6 |
+
labels = learn.dls.vocab
|
7 |
+
|
8 |
+
|
9 |
+
def predict(img):
|
10 |
+
img = PILImage.create(img)
|
11 |
+
_, _, probs = learn.predict(img)
|
12 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
13 |
+
|
14 |
+
gr.Interface(
|
15 |
+
fn=predict,
|
16 |
+
inputs=gr.components.Image(shape=(400, 400)),
|
17 |
+
outputs=gr.components.Label(num_top_classes=2),
|
18 |
+
title="Does my sighthound have a corn?",
|
19 |
+
description="given a picture of a paw. does it have a corn?",
|
20 |
+
examples=[
|
21 |
+
"corn_01.jpg",
|
22 |
+
"corn_02.jpg",
|
23 |
+
"corn_03.jpg",
|
24 |
+
"no_corn_01.jpg",
|
25 |
+
"no_corn_02.jpg",
|
26 |
+
],
|
27 |
+
).launch(enable_queue=True)
|
corn_01.jpg
ADDED
![]() |
corn_02.jpg
ADDED
![]() |
corn_03.jpg
ADDED
![]() |
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:212dd162547e13599c42f1625c1b2b31627278cc2b8d205a403e531bd16a73a4
|
3 |
+
size 791507375
|
no_corn_01.jpg
ADDED
![]() |
no_corn_02.jpg
ADDED
![]() |
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fastai==2.7.9
|