CoolFace
Apppublic

instantnoodle/Fruits-classifier

sourceHugging Faceapache-2.0updated 4y agoView on Hugging Face
1likes
app.py19 linesDownload Raw Back to root
1from fastai.vision.all import *2import gradio as gr3 4learn = load_learner('fruits.pkl')5labels = learn.dls.vocab6 7def predict(img):8    img = PILImage.create(img)9    pred, pred_idx, probs = learn.predict(img)10    return {labels[i]: float(probs[i]) for i in range(len(labels))}11 12title = 'Fruits Classifier'13description = 'This model can classify the image into four categories of fruits: Apple, Banana, Mango, and Blueberries'14image = gr.inputs.Image(shape=(512,512))15label = gr.outputs.Label()16examples = ['Mango.jpg', 'Apple.jpg', 'Banana.webp', 'Blueberries.jpg']17 18gr.Interface(fn=predict, inputs=image, outputs=label, examples=examples, title=title, description=description).launch()19