Spaces:
Sleeping
Sleeping
Commit ·
e917a92
1
Parent(s): 1461efa
App changes
Browse files- app.py +13 -4
- credit_card.png +0 -0
- model.pkl +3 -0
- visiting_card.jpg +0 -0
app.py
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
learner = load_learner('model.pkl')
|
| 5 |
+
categories = ('Credit Card', 'Other Card')
|
| 6 |
|
| 7 |
+
def classify_image(img):
|
| 8 |
+
pred, idx, probs = learner.predict(img)
|
| 9 |
+
return dict(zip(categories, map(float, probs)))
|
| 10 |
+
|
| 11 |
+
image = gr.Image(shape=(192, 192))
|
| 12 |
+
label = gr.Label()
|
| 13 |
+
examples = ['credit_card.png', 'visiting_card.jpg']
|
| 14 |
+
|
| 15 |
+
demo = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 16 |
+
demo.launch(inline=False)
|
credit_card.png
ADDED
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8f525fa00334a574e83f4d44e57008fec72689f50fcc63b67c98cbf5c8c99a20
|
| 3 |
+
size 46956102
|
visiting_card.jpg
ADDED
|