File size: 582 Bytes
a47ad99
b7c222e
 
bb27838
b7c222e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from fastbook import *

learn = load_learner('BirdOrForest.pkl')

def predict_image(image):
    img = PILImage.create(image)
    pred, pred_idx, probs = learn.predict(img)
    return pred

# Create a Gradio interface with updated input/output methods
iface = gr.Interface(
    fn=predict_image,
    inputs=gr.Image(),  # Use gr.Image for input
    outputs=gr.Label(),   # Use gr.Label and gr.Number for output
    examples=[
        ["Examples/1.jpg"], 
        ["Examples/2.jpg"], 
        ["Examples/3.jpg"], 
        ["Examples/4.jpg"]
    ]
)

iface.launch()