Spaces:
Runtime error
Runtime error
| # import gradio as gr | |
| # def greet(name): | |
| # return "Hello " + name + "!!" | |
| # demo = gr.Interface(fn=greet, inputs="text", outputs="text") | |
| # demo.launch() | |
| # AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb. | |
| # %% auto 0 | |
| __all__ = ["learn", "categories", "image", "label", "examples", "intf", "classify_bike"] | |
| # %% app.ipynb 5 | |
| from fastai.vision.all import * | |
| import gradio as gr | |
| # %% app.ipynb 9 | |
| learn = load_learner("model.pkl") | |
| # %% app.ipynb 11 | |
| categories = ["giant", "specialized", "trek"] | |
| def classify_bike(image): | |
| pred, idx, probs = learn.predict(image) | |
| return dict(zip(categories, map(float, probs))) | |
| # %% app.ipynb 13 | |
| image = gr.Image(height=192, width=192, label="Bike Image") | |
| label = gr.Label(label="Predicted Bike Type") | |
| examples = ["trek.jpg", "specialized.jpg"] | |
| intf = gr.Interface(fn=classify_bike, inputs=image, outputs=label, examples=examples) | |
| intf.launch(inline=False) | |