Skip to main content

ZeroShotImageClassificationPipeline

pipe(image, candidate_labels) -> [{"label": str, "score": float}], best first: each label's cosine similarity with the image in the model's shared embedding space (the rows are unit length, so the dot product is the cosine; no softmax and no temperature, the model carries none). hypothesis_template renders each label into the text the model embeds: "{}", the label itself, by default; "a photo of a {}" is the other common choice.