Download classify.py from Rahuletto/carbrands: direct link, hf CLI and curl.
- Browser
- Download file 790 Bytes
-
https://huggingface.co/spaces/Rahuletto/carbrands/resolve/main/classify.py
- Command line
-
hf download hf://spaces/Rahuletto/carbrands/classify.py
-
curl -L -o classify.py https://huggingface.co/spaces/Rahuletto/carbrands/resolve/main/classify.py
790 Bytes
| # AUTOGENERATED! DO NOT EDIT! File to edit: classify.ipynb. | |
| # %% auto 0 | |
| __all__ = ['learn', 'image', 'label', 'examples', 'intf', 'classify_car'] | |
| # %% classify.ipynb 1 | |
| from fastbook import * | |
| import gradio as gr | |
| # %% classify.ipynb 3 | |
| learn=load_learner('models/car_classifier.pkl') | |
| # %% classify.ipynb 5 | |
| def classify_car(img): | |
| img = PILImage.create(img) | |
| pred, pred_idx, probs = learn.predict(img) | |
| return {learn.dls.vocab[i]: probs[i].item() for i in range(len(learn.dls.vocab))} | |
| # %% classify.ipynb 6 | |
| image=gr.components.Image() | |
| label=gr.components.Label() | |
| examples=[['examples/example_0.png'], ['examples/example_1.png'], ['examples/example_2.png']] | |
| intf=gr.Interface(fn=classify_car, inputs=image, outputs=label, examples=examples).launch() | |
| intf.launch(inline=False) | |