Spaces:
Runtime error
Runtime error
__all__ = ['learner', 'labels', 'interface', 'classify'] | |
from fastai.vision.all import * | |
import gradio as gr | |
learner = load_learner('ConvNext_RmsProps.pkl') | |
labels = learner.dls.vocab | |
def classify(img): | |
img = PILImage.create(img) | |
pred, pred_idx, probs = learner.predict(img) | |
return {labels[i]: float(probs[i]) for i in range (len(labels))} | |
interface = gr.Interface( | |
fn=classify, | |
inputs=gr.Image(), | |
outputs=gr.Label(), | |
examples=['Amanita.jpg'], | |
allow_flagging='never', | |
title='European Mushroom Common Genus Image Classifier', | |
description='Model trained to classify nine types of european mushroom common genus image classifier — Entoloma, Suillus, Hygrocybe, Agaricus, Amanita, Lactarius, Russula,Boletus,Cortinarius.' | |
) | |
interface.launch(share=False, inline=False) | |