File size: 665 Bytes
65ad9c0
070776c
2f720de
 
ed22e1b
070776c
65ad9c0
070776c
65ad9c0
 
 
 
 
 
 
 
2f720de
65ad9c0
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from fastai.vision.all import *
import gradio as gr
import os



learner = load_learner('RM_classifier.pkl')


def classify_image(image):
    predicted, idx, probabilities = learner.predict(image)
    return dict(zip(learner.dls.vocab, map(float, probabilities)))


image = gr.inputs.Image(shape=(224,224))
label = gr.outputs.Label()
examples = [os.path.join("./images", img_path) for img_path in os.listdir( './images')]

interface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title='Rick and Morty Character Classifier', description='Upload an image of a Rick and Morty character')
interface.launch()