File size: 1,185 Bytes
afd66c1
 
 
 
 
 
45e82fb
afd66c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
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)