vizcodes's picture
changed path to model pickle file
45e82fb
import gradio as gr
from fastai.learner import load_learner
def image_classifier(inp):
art_classifier = load_learner('art_classifier.pkl')
class_lst = art_classifier.dls.vocab
pred,pred_idx,probs = art_classifier.predict(inp)
pred_dict = {x:y.numpy() for x, y in zip(class_lst,probs)}
return pred_dict
demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label",
title = 'Art Style Classifier 🎨',
description = '<center> The Restnet152 model was finetuned on different art images to classify different styles of the art.</center>',
examples = ['./static/abstract.jpg',
'./static/cons.jpg',
'./static/cubism.png',
'./static/graff.jpg',
'./static/impressionism.jfif',
'./static/pop.jpg',
'./static/sketch.jpg','./static/photorealism.jpg'],
article = 'Made with ❤️ by <a href = "https://github.com/vizcodes"> @vizcodes </a> using FastAI')
demo.launch(share = True)