Spaces:
Runtime error
Runtime error
import fastai | |
from fastai.vision.all import * | |
import gradio as gr | |
from PIL import Image | |
learn = load_learner('model.pkl') | |
categories = 'elliptical', 'irregular', 'spiral' | |
def classify_img(img): | |
pred, idx, probs = learn.predict(img) | |
return dict(zip(categories, map(float,probs))) | |
image = gr.inputs.Image(shape=(224,224)) | |
label = gr.outputs.Label() | |
examples = ['elliptical.jpg', 'irregular.jpg', 'spiral.jpg'] | |
for img in examples: | |
img = Image.open(img) | |
img = img.resize((224,224), Image.NEAREST) | |
iface = gr.Interface(fn = classify_img, inputs = image, outputs = label, title = 'Galaxy Classifier', examples = examples) | |
iface.launch() |