> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/workflows/blocks/blocks/run-a-model/clip-comparison.md).

# Clip Comparison

## v2

Use the OpenAI CLIP zero-shot classification model to classify images.

This block accepts an image and a list of text prompts. The block then returns the similarity of each text label to the provided image.

This block is useful for classifying images without having to train a fine-tuned classification model. For example, you could use CLIP to classify the type of vehicle in an image, or if an image contains NSFW material.

### Type identifier

Use the following identifier in step `"type"` field: `roboflow_core/clip_comparison@v2` to add the block as a step in your workflow.

### Properties

| **Name**  | **Type**    | **Description**                                                   | Refs |
| --------- | ----------- | ----------------------------------------------------------------- | ---- |
| `name`    | `str`       | Unique name of step in workflows.                                 | ❌    |
| `classes` | `List[str]` | List of classes to calculate similarity against each input image. | ✅    |
| `version` | `str`       | Variant of CLIP model.                                            | ✅    |

The **Refs** column marks possibility to parametrise the property with dynamic values available in `workflow` runtime. See *Bindings* for more info.

### Input and Output Bindings

The available connections depend on its binding kinds. Check what binding kinds `Clip Comparison` in version `v2` has.

<details>

<summary>Input and output bindings</summary>

* input
  * `images` ([*`image`*](https://inference.roboflow.com/workflows/kinds/image/)): The image to infer on..
  * `classes` ([*`list_of_values`*](https://inference.roboflow.com/workflows/kinds/list_of_values/)): List of classes to calculate similarity against each input image.
  * `version` ([*`string`*](https://inference.roboflow.com/workflows/kinds/string/)): Variant of CLIP model.
* output
  * `similarities` ([`list_of_values`](https://inference.roboflow.com/workflows/kinds/list_of_values/)): List of values of any type.
  * `max_similarity` ([`float_zero_to_one`](https://inference.roboflow.com/workflows/kinds/float_zero_to_one/)): `float` value in range `[0.0, 1.0]`.
  * `most_similar_class` ([`string`](https://inference.roboflow.com/workflows/kinds/string/)): String value.
  * `min_similarity` ([`float_zero_to_one`](https://inference.roboflow.com/workflows/kinds/float_zero_to_one/)): `float` value in range `[0.0, 1.0]`.
  * `least_similar_class` ([`string`](https://inference.roboflow.com/workflows/kinds/string/)): String value.
  * `classification_predictions` ([`classification_prediction`](https://inference.roboflow.com/workflows/kinds/classification_prediction/)): Predictions from classifier.
  * `parent_id` ([`parent_id`](https://inference.roboflow.com/workflows/kinds/parent_id/)): Identifier of parent for step output.
  * `root_parent_id` ([`parent_id`](https://inference.roboflow.com/workflows/kinds/parent_id/)): Identifier of parent for step output.

</details>

<details>

<summary>Example JSON definition</summary>

```json
{
	    "name": "<your_step_name_here>",
	    "type": "roboflow_core/clip_comparison@v2",
	    "images": "$inputs.image",
	    "classes": [
	        "a",
	        "b",
	        "c"
	    ],
	    "version": "ViT-B-16"
	}
```

</details>

## v1

Use the OpenAI CLIP zero-shot classification model to classify images.

This block accepts an image and a list of text prompts. The block then returns the similarity of each text label to the provided image.

This block is useful for classifying images without having to train a fine-tuned classification model. For example, you could use CLIP to classify the type of vehicle in an image, or if an image contains NSFW material.

### Type identifier

Use the following identifier in step `"type"` field: `roboflow_core/clip_comparison@v1` to add the block as a step in your workflow.

### Properties

| **Name** | **Type**    | **Description**                                                 | Refs |
| -------- | ----------- | --------------------------------------------------------------- | ---- |
| `name`   | `str`       | Unique name of step in workflows.                               | ❌    |
| `texts`  | `List[str]` | List of texts to calculate similarity against each input image. | ✅    |

The **Refs** column marks possibility to parametrise the property with dynamic values available in `workflow` runtime. See *Bindings* for more info.

### Input and Output Bindings

The available connections depend on its binding kinds. Check what binding kinds `Clip Comparison` in version `v1` has.

<details>

<summary>Input and output bindings</summary>

* input
  * `images` ([*`image`*](https://inference.roboflow.com/workflows/kinds/image/)): The image to infer on..
  * `texts` ([*`list_of_values`*](https://inference.roboflow.com/workflows/kinds/list_of_values/)): List of texts to calculate similarity against each input image.
* output
  * `similarity` ([`list_of_values`](https://inference.roboflow.com/workflows/kinds/list_of_values/)): List of values of any type.
  * `parent_id` ([`parent_id`](https://inference.roboflow.com/workflows/kinds/parent_id/)): Identifier of parent for step output.
  * `root_parent_id` ([`parent_id`](https://inference.roboflow.com/workflows/kinds/parent_id/)): Identifier of parent for step output.
  * `prediction_type` ([`prediction_type`](https://inference.roboflow.com/workflows/kinds/prediction_type/)): String value with type of prediction.

</details>

<details>

<summary>Example JSON definition</summary>

```json
{
	    "name": "<your_step_name_here>",
	    "type": "roboflow_core/clip_comparison@v1",
	    "images": "$inputs.image",
	    "texts": [
	        "a",
	        "b",
	        "c"
	    ]
	}
```

</details>
