Spaces:
Build error
Build error
| import gradio as gr | |
| from fastai.vision.all import * | |
| import skimage | |
| learn = load_learner('characters.pkl') | |
| labels = learn.dls.vocab | |
| def predict(img): | |
| pred, pred_idx, probs = learn.predict(img) | |
| return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
| title = "Video Game Character Classifier" | |
| examples = ['ellie.jpg', 'arthur.jpg', 'kratos.jpg', 'ellielou.jpg'] | |
| # Updated Gradio Interface with new syntax | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# " + title) | |
| image_input = gr.Image(shape=(128, 128)) | |
| label_output = gr.Label() | |
| # Create submit button | |
| submit_btn = gr.Button("Classify") | |
| submit_btn.click(fn=predict, inputs=image_input, outputs=label_output) | |
| # Adding examples | |
| gr.Examples(examples, inputs=image_input, outputs=label_output, fn=predict) | |
| demo.launch() |