CoolFace
Apppublic

flashfaster/pets

sourceHugging Faceapache-2.0updated 3y agoView on Hugging Face
0likes
app.py34 linesDownload Raw Back to root
1# import gradio as gr2 3# def greet(name):4#     return "Hello " + name + "!!"5 6# iface = gr.Interface(fn=greet, inputs="text", outputs="text")7# iface.launch()8 9 10 11from fastai import *12from fastai.vision.all import *13 14import gradio as gr 15 16def is_cat(x): return x[0].isupper()17 18 19learn = load_learner('model.pkl')20 21categories = ('Dog', 'Cat')22 23def classify_image(img):24    pred, idx, probs = learn.predict(img)25    return dict(zip(categories, map(float, probs)))26 27 28image = gr.Image()29label = gr.Label()30examples = ['dog.jpeg', 'cat.jpeg', 'wot.jpeg']31 32 33intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)34intf.launch(inline=False)