Spaces:
Sleeping
Sleeping
import gradio as gr | |
from fastai.vision.all import * | |
import os | |
learn = load_learner('painters_model.pkl') | |
painters_categories = list(learn.dls.vocab) | |
def classify_image(img): | |
'''Image classifications''' | |
pred, idx, probs = learn.predict(img) | |
return dict(zip(painters_categories, map(float, probs))) | |
image = gr.components.Image(shape=(192, 192)) | |
label = gr.components.Label() | |
examples_dir = 'paintings_examples' | |
examples = [os.path.join(examples_dir, file) for file in os.listdir(examples_dir)] | |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
intf.launch(inline=False) | |