# -*- 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)