File size: 516 Bytes
8dfdf1f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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("fhenaog/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}")
    

gr.Interface(fn=classify_image,
             inputs=gr.Image(width=224, height=224),
             outputs="textbox").launch()