File size: 508 Bytes
fb36623
 
4d7e61d
 
2a52bf6
4bf3886
 
fb36623
 
 
 
 
 
 
 
 
 
 
 
f84be12
fb36623
 
 
 
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
import pickle
# pip install -Uqq fastbook
# from fastbook import *
from fastai.vision.all import *
from fastai.learner import load_learner


# Load the trained model
learn = load_learner('model.pkl')
labels = learn.dls.vocab

def predict(img):
    pred, _, probs = learn.predict(img)
    return f"This is a {pred} with probability {probs[pred_idx]}"

# Create the Gradio interface
iface = gr.Interface(
    fn=predict,
    inputs=gr.Image(),
    outputs="text"
)

iface.launch(share=True)