jdmartinev's picture
Update app.py
cc82272 verified
raw
history blame
595 Bytes
import gradio as gr
from fastai.learner import load_learner
from fastai.vision.core import PILImage
from huggingface_hub import hf_hub_download
learner = load_learner(hf_hub_download("jdmartinev/isitabird","model.pkl"))
def classify_image(image):
img = PILImage.create(image)
pred_class, pred_idx, outputs = learner.predict(img)
return(f"Predicted class: {pred_class}")
demo = gr.Interface(classify_image, gr.Image(shape=(224, 224)), "text")
gr.Interface(fn=classify_image,
inputs=gr.Image(width=224, height=224),
outputs="textbox").launch()