Spaces:
Runtime error
Runtime error
File size: 1,168 Bytes
8ee9448 bfab212 557cdf9 bfab212 557cdf9 8ee9448 bfab212 8ee9448 2082fc6 8ee9448 ea3434b 8ee9448 0149bca |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
from fastai.vision.all import *
import gradio as gr
import glob
examples = glob.glob("examples/*")
learn = load_learner("model.pkl")
labels = learn.dls.vocab
def classify_image(img):
pred, idx, probs = learn.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
title = "Pasta Recognition"
description = """
Pasta is delicious, but there are too many pasta types to remember. This app will help you
recall the name of the pasta whose image you'll upload.
Under the hood it's a pasta classifier, built using Fast.ai by fine-tuning the
`convnext_small_in22k` model. It supports only the followig pasta types:
* Campanelle
* Ditalini
* Fettuccine
* Fusilli
* Linguine
* Macaroni
* Pappardelle
The model's accuracy is ~87.3%.
The notebook used to train the model can be seen [in Google Colab](https://colab.research.google.com/drive/1NM6BvRkV7xDlnncFqVRGxxg0GFtqpVgT?usp=sharing).
"""
iface = gr.Interface(fn=classify_image, inputs=image, outputs=gr.outputs.Label(), examples=examples, title=title, description=description)
iface.launch(inline=False, share=False)
|