File size: 665 Bytes
2914119 29fdf1d 4071bec 2ee716e 2914119 2ee716e 29fdf1d 7d0dabc 29fdf1d 4071bec 7d0dabc 29fdf1d 6a5f8ce 7d0dabc 29fdf1d 6a5f8ce 29fdf1d |
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 |
import gradio as gr
import pickle
from PIL import Image
from fastai.learner import load_learner
model = load_learner('./mushrooms.pkl')
categories = [
"Agaricus",
"Amanita",
"Boletus",
"Cortinarius",
"Entoloma",
"Hygrocybe",
"Lactarius",
"Russula",
"Suillus",
]
def classify_image(image):
prediction, _, probs = model.predict(image)
return dict(zip(categories, map(float, probs)))
iface = gr.Interface(
fn=classify_image,
inputs=gr.Image(type="pil"),
outputs=gr.Label(),
title="Image Classifier",
description="WHAT IS THE MUSHROOM?"
)
# Launch app
if __name__ == "__main__":
iface.launch()
|