| | |
| |
|
| | |
| | __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'inf', 'classify_img'] |
| |
|
| | |
| | from fastai.vision.all import * |
| | import gradio as gr |
| |
|
| | |
| | learn = load_learner('model.pkl') |
| |
|
| | |
| | categories = ('Art Deco', 'Baroque', 'Classical', 'Craftsman', 'Gothic', 'Renaissance', 'Tudor', 'Victorian') |
| |
|
| | def classify_img(img): |
| | pred,idx,probs = learn.predict(img) |
| | |
| | return dict(zip(categories, map(float, probs))) |
| |
|
| | |
| | |
| | image = gr.Image(image_mode="RGB", type="pil") |
| | label = gr.Label() |
| | examples = ['classical.jpg', 'artdec.jpg', 'victorian.jpeg'] |
| |
|
| | inf = gr.Interface(fn=classify_img, inputs=image, outputs=label, examples=examples) |
| |
|
| | |
| | inf.launch(inline=False) |
| |
|