File size: 488 Bytes
7ba82f6
1461efa
 
e917a92
 
1461efa
e917a92
 
 
 
7ba82f6
e917a92
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from fastai.vision.all import *
import gradio as gr

learner = load_learner('model.pkl')
categories = ('Credit Card', 'Other Card')

def classify_image(img):
    pred, idx, probs = learner.predict(img)
    return dict(zip(categories, map(float, probs)))

image = gr.Image()  # Remove the shape argument
label = gr.Label()
examples = ['credit_card.png', 'visiting_card.jpg']

demo = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
demo.launch(inline=False)