Spaces:
Build error
Build error
File size: 851 Bytes
781a1c6 94135ec 358176d 781a1c6 8eb8a19 d235a46 358176d 94135ec d235a46 781a1c6 4afb8bb 781a1c6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import gradio as gr
from fastai.vision.all import *
from huggingface_hub import from_pretrained_fastai
import pathlib
# loading the model
windows_backup = pathlib.WindowsPath
pathlib.WindowsPath = pathlib.PosixPath
learn = from_pretrained_fastai("pka007/flowerclassifier_model")
pathlib.WindowsPath = windows_backup
labels = ['Jasmine', 'Marigold', 'Rose', 'sunflower', 'tulip']
def predict(img):
img = PILImage.create(img)
pred,pred_idx,probs = learn.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
title = "Flower Classifier"
description = "A flower classifier trained on the images downloaded from the internet."
examples = ['sunflower.jpg','marigold.jpg']
intf = gr.Interface(fn=predict,inputs=gr.Image(type="pil"),outputs=gr.Label(),title=title,description=description,examples=examples)
intf.launch()
|