"...git@developer.sourcefind.cn:OpenDAS/mmdetection3d.git" did not exist on "e8298d2450afd07889d4777a4dcca6938d67967c"
Unverified Commit 69715f2e authored by Nicolas Patry's avatar Nicolas Patry Committed by GitHub
Browse files

Adding doctest for `zero-shot-image-classification` pipeline. (#20272)

* Adding doctest for `zero-shot-image-classification` pipeline.

* Remove nested_simplify.
parent 291c17f6
...@@ -33,6 +33,27 @@ class ZeroShotImageClassificationPipeline(ChunkPipeline): ...@@ -33,6 +33,27 @@ class ZeroShotImageClassificationPipeline(ChunkPipeline):
Zero shot image classification pipeline using `CLIPModel`. This pipeline predicts the class of an image when you Zero shot image classification pipeline using `CLIPModel`. This pipeline predicts the class of an image when you
provide an image and a set of `candidate_labels`. provide an image and a set of `candidate_labels`.
Example:
```python
>>> from transformers import pipeline
>>> classifier = pipeline(model="openai/clip-vit-large-patch14")
>>> classifier(
... "https://huggingface.co/datasets/Narsil/image_dummy/raw/main/parrots.png",
... candidate_labels=["animals", "humans", "landscape"],
... )
[{'score': 0.965, 'label': 'animals'}, {'score': 0.03, 'label': 'humans'}, {'score': 0.005, 'label': 'landscape'}]
>>> classifier(
... "https://huggingface.co/datasets/Narsil/image_dummy/raw/main/parrots.png",
... candidate_labels=["black and white", "photorealist", "painting"],
... )
[{'score': 0.996, 'label': 'black and white'}, {'score': 0.003, 'label': 'photorealist'}, {'score': 0.0, 'label': 'painting'}]
```
[Learn more about the basics of using a pipeline in the [pipeline tutorial]](../pipeline_tutorial)
This image classification pipeline can currently be loaded from [`pipeline`] using the following task identifier: This image classification pipeline can currently be loaded from [`pipeline`] using the following task identifier:
`"zero-shot-image-classification"`. `"zero-shot-image-classification"`.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment