File size: 912 Bytes
7152f4e
e6e53fd
 
7152f4e
9bcb70a
7152f4e
9bcb70a
e6e53fd
 
3a120bc
 
e6e53fd
30e53f9
3de827b
fe9cec4
0759b01
fa5f59e
4bb1fe5
30e53f9
9eb2af9
e6e53fd
 
9eb2af9
4bb1fe5
e6e53fd
9087e34
6bde5ca
897be32
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.vision.all import *
import skimage

neural_net = load_learner('trained-NN.pkl')

labels = neural_net.dls.vocab

def predict(img):
    category, idx, probs = neural_net.predict(img)
    return dict(zip(labels, map(float, probs)))
    
title = 'Natural Landscape Photo Classifier'
description = 'Click an example photo or upload an image of your own!'
examples = ['farm.jpg', 'lake.jpg', 'solar.jpg', 'neighborhood.jpg']
inputs=gr.Image(type='pil',
               label='Photo')
outputs = gr.Label(value={labels[i]: 0 for i in range(len(labels))},
                  label='The photo is a...',
                  show_label=True)

iface = gr.Interface(fn=predict, 
                     inputs=inputs, 
                     outputs=outputs,
                     title=title,
                     description=description,
                     examples=examples)
iface.launch(share=True)