test-zero-shot / app.py
isingh's picture
fix typo
59e9ce4
raw
history blame
No virus
626 Bytes
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):
predictions = detector(img, candidate_labels=["fox", "bear", "seagull", "owl"])
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()