CoolFace
Apppublic

Dkeruan/multi-labeling

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
1likes
app.py22 linesDownload Raw Back to root
1import gradio as gr2from fastai.vision.all import *3import skimage4 5learn = load_learner('export.pkl')6 7labels = learn.dls.vocab8 9def predict(img):10    img = PILImage.create(img)11    pred, pred_idx, probs = learn.predict(img)12    return {labels[i]:float(probs[i]) for i in range(len(labels))}13 14 15title = 'Multi-label Image Classifier'16description = 'An image classifier trained on the Pascal Dataset via transfer learning. Created as a demo for my ML self-study'17examples = ['teddy.jpg', 'bus.jpg', 'vacation.jpg']18 19 20gr.Interface(fn=predict, inputs=gr.Image(height=512, width=512), 21             outputs=gr.Label(num_top_classes=3), title=title, 22             description=description, examples=examples).launch(share=True)