kellyshreeve's picture
Update app.py
30e53f9 verified
raw
history blame contribute delete
912 Bytes
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)