# Necessary imports import warnings warnings.filterwarnings("ignore") import gradio as gr from src.siglip.classifier import ZeroShotImageClassification # Examples to display in the interface examples = [ [ "images/baklava.png", "dessert on a plate, a serving of baklava, a plate and spoon", ], [ "images/beignets.png", "a dog, a cat, a donut, a beignet", ], [ "images/cat.png", "two sleeping cats, two cats playing, three cats laying down", ], ] # Title and description and article for the interface title = "Zero Shot Image Classification" description = "Classify image using zero-shot classification with SigLIP 2 model! Provide an image input and a list of candidate labels separated by commas. Read more at the links below." article = "

SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features | Model Page

" # Launch the interface demo = gr.Interface( fn=ZeroShotImageClassification, inputs=[ gr.Image(type="pil", label="Input", placeholder="Enter image to classify"), gr.Textbox( label="Candidate Labels", placeholder="Enter candidate labels separated by commas", ), ], outputs=gr.Label(label="Classification", num_top_classes=3), title=title, description=description, article=article, examples=examples, cache_examples=True, cache_mode="lazy", theme="Soft", flagging_mode="never", ) demo.launch(debug=False)