CoolFace
Apppublic

DataBadger/VeraClassifier

sourceHugging Faceapache-2.0updated 4y agoView on Hugging Face
0likes
app.py25 linesDownload Raw Back to root
1import gradio as gr2from fastai.vision.all import *3import pathlib4 5plt = platform.system()6if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath7 8def get_x(r): return r['fname']9def get_y(r): return r['color']10 11learn = load_learner("pattern_classifier_model.pkl")12 13categories = tuple(learn.dls.vocab)14 15def classify_image(img):16    pred, idx, probs = learn.predict(img)17    return dict(zip(categories, map(float, probs)))18 19 20image = gr.inputs.Image(shape = (192, 192))21label = gr.outputs.Label()22examples = ['Lavender Sky Test.jpg', 'Park Stripe Test.jpg', 'Fan Flowers Test.jpg']23 24intf = gr.Interface(fn = classify_image, inputs = image, outputs = label, examples = examples)25intf.launch(inline = False)