File size: 585 Bytes
e5a756f
b32ee1e
e5a756f
b32ee1e
 
 
e5a756f
b32ee1e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
27
import gradio as gr
from fastai.vision.all import *

title = "Interstellar Classifier"
description = "Built for fast.ai 'Practical Deep Learning'"
examples = "examples"

model = load_learner("model/model.pkl")


def predict(img):
    labels = model.dls.vocab
    img = PILImage.create(img)
    pred, pred_idx, probs = model.predict(img)
    return dict(map(labels, map(float, probs)))


demo = gr.Interface(
    fn=predict,
    inputs="image",
    outputs="image",
    examples=examples,
    title=title,
    description=description,
).queue(default_concurrency_limit=5)
demo.launch()