Spaces:
Runtime error
Runtime error
__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) |