CoolFace
Apppublic

vsanchezn/minima

sourceHugging Faceapache-2.0updated 2y 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# demo = gr.Interface(fn=greet, inputs="text", outputs="text")7# demo.launch()8__all__ = ['label_func', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']9 10# Cell11from fastai.vision.all import *12import gradio as gr13 14def label_func(x):15    return "dog" if x[0].islower() else "cat"16# Cell17learn = load_learner('model.pkl')18 19# Cell20categories = ('Cat', 'Dog')21 22def classify_image(img):23    pred, idx, probs = learn.predict(img)24    return dict(zip(categories, map(float, probs)))25 26# Cell27# image = gr.inputs.Image(shape=(192, 192))28image = gr.Image(height=192, width=192)29label = gr.Label()30# label = gr.outputs.Label()31examples = ['dog1.jpeg', 'dog2.jpeg', 'dog3.jpeg','cat.jpg']32 33intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)34intf.launch(inline=False)