Spaces:
Build error
Build error
| # AUTOGENERATED! DO NOT EDIT! File to edit: ../ap.ipynb. | |
| # %% auto 0 | |
| __all__ = ['learner', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image'] | |
| # %% ../ap.ipynb 1 | |
| from fastai.vision.all import * | |
| from huggingface_hub import push_to_hub_fastai, from_pretrained_fastai | |
| import gradio as gr | |
| # %% ../ap.ipynb 3 | |
| learner = load_learner('export.pkl') | |
| # %% ../ap.ipynb 5 | |
| categories = ('In-phase', 'Invert-Phase', 'Noise') | |
| def classify_image(img): | |
| pred, idx, probs = learner.predict(img) | |
| return dict(zip(categories, map(float, probs))) | |
| # %% ../ap.ipynb 7 | |
| image = gr.inputs.Image(shape=(192,192)) | |
| label = gr.outputs.Label() | |
| examples = ['IVP1.jpg','IVP2.jpg', 'IP1.jpg', 'IP2.jpg','Noise1.jpg', 'Noise2.jpg'] | |
| intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
| intf.launch(inline=False) | |