File size: 824 Bytes
f5aa10c 51e9bde f5aa10c 51e9bde f5aa10c 51e9bde f5aa10c 51e9bde f5aa10c |
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# -*- coding: utf-8 -*-
"""planets-predictions.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1B7jPgW69uJ1nLSAZ2eKfhGx1TSEiYOZh
"""
from fastai.vision.all import *
import gradio as gr
learn = load_learner("planets-v1.pkl")
labels = learn.dls.vocab
def predict(img):
img = PILImage.create(img)
pred, pred_idx, probs = learn.predict(img)
return dict(zip(labels, probs.tolist()))
image_input = gr.Image(shape=(224, 224))
label_output = gr.Label()
examples = [
"Mercury.jpg",
"Venus.png",
"Earth.jpg",
"Mars.jpg",
"Jupiter.jpg",
"Saturn.jpg",
"Uranus.jpg",
"Neptune.jpg",
]
iface = gr.Interface(
fn=predict, inputs=image_input, outputs=label_output, examples=examples
)
iface.launch(inline=False)
|