Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from transformers import pipeline | |
| checkpoint = "openai/clip-vit-large-patch14" | |
| detector = pipeline(model=checkpoint, task="zero-shot-image-classification") | |
| def classify(img, candidates): | |
| labels = candidates.split(sep=",") | |
| predictions = detector(img, candidate_labels=labels) | |
| return predictions | |
| with gr.Blocks() as iface: | |
| image = gr.Image(type="pil", label="Image") | |
| candidates = gr.Textbox(label="Candidates") | |
| predictions = gr.Textbox(label="Predictions") | |
| btn = gr.Button("Classify") | |
| btn.click(fn=classify, inputs=[image, candidates], outputs=predictions, api_name="classify") | |
| iface.launch() |