Spaces:
Sleeping
Sleeping
File size: 967 Bytes
ba7b1f7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 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()
|