File size: 749 Bytes
2f7db80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import gradio as gr
from fastai.vision.all import *

# Loading the model we trained
learn = load_learner('one_piece.pkl')

# Prediction function
def predict_character(img):
    pred_class, pred_idx, probs = learn.predict(img)

    return {learn.dls.vocab[i]: float(probs[i])
            for i in range(len(learn.dls.vocab))}

# Gradio app interface
demo = gr.Interface(
    fn = predict_character,
    inputs = gr.Image(type = 'pil', label = 'Upload Character Image'),
    outputs = gr.Label(num_top_classes = 10, label = 'Predictions'),
    title = 'One Piece Straw Hat Recognition',
    description = 'Upload any straw hats members image except franky and jinbe',
    examples = None,
    theme = gr.themes.Soft()
)

# Launch our app
demo.launch()