Spaces:
Runtime error
Runtime error
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb. | |
# %% auto 0 | |
__all__ = ['learn', 'cloud_types', 'image', 'label', 'examples', 'intf', 'classify_image'] | |
# %% app.ipynb 2 | |
from fastai.vision.all import * | |
import gradio as gr | |
# %% app.ipynb 3 | |
learn = load_learner('models/architecture_style_classifyier_levit_384_model.pkl') | |
# %% app.ipynb 4 | |
architecture_styles = [ | |
'Achaemenid architecture', | |
'American craftsman style', | |
'American Foursquare architecture', | |
'Ancient Egyptian architecture', | |
'Art Deco architecture', | |
'Art Nouveau architecture', | |
'Baroque architecture', | |
'Bauhaus architecture', | |
'Beaux-Arts architecture', | |
'Byzantine architecture', | |
'Chicago school architecture', | |
'Colonial architecture', | |
'Deconstructivism', | |
'Edwardian architecture', | |
'Georgian architecture', | |
'Gothic architecture', | |
'Greek Revival architecture', | |
'International style', | |
'Novelty architecture', | |
'Palladian architecture', | |
'Postmodern architecture', | |
'Queen Anne architecture', | |
'Romanesque architecture', | |
'Russian Revival architecture', | |
'Tudor Revival architecture' | |
] | |
def classify_image(img): | |
pred,idx,probs = learn.predict(img) | |
return dict(zip(architecture_styles, map(float, probs))) | |
# %% app.ipynb 6 | |
image = gr.inputs.Image(shape=(192,192)) | |
label = gr.outputs.Label() | |
examples = ['Chicago school architecture.jpeg', 'Deconstructivism.jpeg', 'Gothic architecture.jpeg'] | |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
intf.launch(inline=False) | |