Spaces:
Runtime error
Runtime error
File size: 682 Bytes
340a90b aa9e4f1 f6a2655 aa9e4f1 d14064e aa9e4f1 d14064e f6a2655 d14064e e7138ce aa9e4f1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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()
e = ['elliptical.jpg', 'irregular.jpg', 'spiral.jpg']
examples = []
for img in examples:
img = Image.open(img)
img = img.resize((224,224), Image.NEAREST)
examples.append(img)
iface = gr.Interface(fn = classify_img, inputs = image, outputs = label, title = 'Galaxy Classifier', examples = examples)
iface.launch() |