Spaces:
Sleeping
Sleeping
| # AUTOGENERATED! DO NOT EDIT! File to edit: load.ipynb. | |
| # %% auto 0 | |
| __all__ = ['learn', 'intf', 'classify_image'] | |
| # %% load.ipynb 1 | |
| import pickle # or import joblib | |
| from fastai.vision.all import * | |
| import gradio as gr | |
| # %% load.ipynb 3 | |
| learn = load_learner('models/archclassifier_v2.pkl') | |
| # %% load.ipynb 6 | |
| def classify_image(img): | |
| img = PILImage.create(img) | |
| pred_class, pred_idx, probs = learn.predict(img) | |
| # Corrected: Create dict mapping class names to float probabilities | |
| return dict(zip(learn.dls.vocab, map(float, probs))) | |
| # %% load.ipynb 8 | |
| examples = ['examples/1.jpg','examples/2.jpg','examples/3.jpg','examples/4.jpg'] | |
| intf = gr.Interface( | |
| fn=classify_image, | |
| inputs=gr.Image(), | |
| outputs=gr.Label(num_top_classes=3), # show top 3 predictions visually | |
| examples=examples, | |
| title="Arch Style Classifier π’", | |
| description="Upload or choose an image to classify the Arch Style." | |
| ) | |
| intf.launch() |