Spaces:
Runtime error
Runtime error
File size: 868 Bytes
53a8393 f753a4b 0b23ffb f753a4b 363bdc5 53a8393 f753a4b 53a8393 0b23ffb 53a8393 0b23ffb f753a4b |
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 |
__all__ = ['cloud_learn', 'classify_image', 'cloud_categories', 'cloud_examples', 'intf']
import gradio as gr
from fastai.vision.all import *
from pathlib import Path
model_path = Path('models')
image_path = Path('images')
cloud_categories = (
'Cirrus',
'Cirrostratus',
'Cirrocumulus',
'Altostratus',
'Altocumulus',
'Stratus',
'Stratocumulus',
'Nimbostratus',
'Cumulus',
'Cumulonimbus',
'Lenticular'
)
cloud_examples = [str(image_path / f"{c}.jpg") for c in cloud_categories]
cloud_learn = load_learner(model_path/'cloudmodel.pkl')
def classify_image(img):
pred, idx, probs = cloud_learn.predict(img)
return dict(zip(cloud_categories, map(float,probs)))
intf = gr.Interface(fn=classify_image,
inputs=gr.inputs.Image(shape=(192, 192)),
outputs=gr.outputs.Label(),
examples=cloud_examples)
intf.launch(inline=False) |