Spaces:
Runtime error
Runtime error
| from fastai.vision.all import * | |
| import gradio as gr | |
| learn = load_learner('model.pth') | |
| def classify_image(img): | |
| celebrity_name,_,probs = learn.predict(img) | |
| results = dict(zip(list(learn.dls.vocab),probs)) | |
| best_results = sorted(results, key=results.get, reverse=True)[:5] | |
| probabilities = {key: float(results[key]) for key in best_results} | |
| return probabilities | |
| image = gr.inputs.Image(shape=(224,224)) | |
| label = gr.outputs.Label() | |
| examples = ['emma_watson.jpg', "tom_hanks.jpeg"] | |
| iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
| iface.launch(inline=False) |