File size: 699 Bytes
c605cb7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20ee3aa
ec495a2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import gradio as gr
from fastai.vision.all import *
import skimage

learn = load_learner('export.pkl')

def predict(img):
    labels = learn.dls.vocab
    im = PILImage.create(img)
    pred,pred_idx,probs = learn.predict(im)
    return {label: float(prob) for (label,prob) in zip(labels,probs)}

gr.Interface(fn=predict,
             inputs=gr.inputs.Image(shape=((400,400))),
             outputs=gr.outputs.Label(num_top_classes=4),
             title = "Art Mood",
             examples =  [f'_Image{i}.jpg' for i in range(1,12)],
             description= "Does this Art make you think of Spring, Summer, Winter or Fall? Do you agree with the Prediction?").launch(share=True, enable_queue=True)