Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from image_classifier.service import ImageClassifierService | |
| service = ImageClassifierService() | |
| def classify_image(image): | |
| return service.classify(image) | |
| with gr.Blocks( | |
| title="Image Classifier CPU", | |
| theme=gr.themes.Soft(primary_hue="indigo", secondary_hue="blue"), | |
| ) as demo: | |
| gr.Markdown( | |
| """ | |
| # Image Classifier CPU | |
| Upload an image and get top predicted labels on free CPU. | |
| """ | |
| ) | |
| image_input = gr.Image(type="pil", label="Input Image") | |
| run_button = gr.Button("Classify", variant="primary") | |
| top_label_output = gr.Textbox(label="Top Label", lines=1) | |
| top_results_output = gr.Textbox(label="Top Results", lines=6) | |
| status_output = gr.Textbox(label="Status", lines=2) | |
| run_button.click( | |
| fn=classify_image, | |
| inputs=[image_input], | |
| outputs=[top_label_output, top_results_output, status_output], | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |