Spaces:
Sleeping
Sleeping
# AUTOGENERATED! DO NOT EDIT! File to edit: ../broken_windows.ipynb. | |
# %% auto 0 | |
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'is_broken', 'classify_image'] | |
# %% ../broken_windows.ipynb 19 | |
from fastai.vision.all import * | |
import gradio as gr | |
def is_broken(x): return x[0].isupper() | |
# %% ../broken_windows.ipynb 20 | |
learn = load_learner('model.pkl') | |
# %% ../broken_windows.ipynb 21 | |
categories = ('Broken window', 'Not broken window') | |
def classify_image(img): | |
pred, idx, probs = learn.predict(img) | |
return dict(zip(categories, map(float, probs))) | |
# %% ../broken_windows.ipynb 22 | |
image = gr.Image() | |
label = gr.Label() | |
examples = ['window.jpg', 'broken_window.jpg'] | |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
intf.launch(inline=False) | |