Spaces:
Sleeping
Sleeping
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb. | |
# %% auto 0 | |
__all__ = ['learn_inf', 'categories', 'image', 'label', 'examples', 'intf', 'classify_images'] | |
# %% app.ipynb 23 | |
from fastai.vision.all import * | |
import gradio as gr | |
# %% app.ipynb 25 | |
learn_inf = load_learner('model.pkl') | |
# %% app.ipynb 28 | |
categories = ('edvard_munch', 'vincent_van_gogh') | |
def classify_images(img): | |
pred, idx,probs = learn_inf.predict(img) | |
return dict(zip(categories, map(float,probs))) | |
# %% app.ipynb 30 | |
title = "Vincent or Edvard paintings Classifier" | |
description = "Gradio Demo for a image classifier trained with fastai. To use it, simply upload your image, or click one of the examples to load them." | |
article = "<p style='text-align: center; font-weight: bold;'><a href='https://github.com/verdugo-danieML/vincent_or_edvard' target='_blank'>Github Repo π</a></p></p>" | |
image = gr.inputs.Image(shape=(256,256)) | |
label = gr.outputs.Label() | |
examples = ['vincent_van_gogh.jpg', 'edvard_munch.jpg'] | |
intf = gr.Interface(fn= classify_images, inputs=image, outputs=label, examples=examples,title=title,description=description,article=article) | |
intf.launch(inline=False) | |