> 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/roboflow/roboflow-ko/deploy/supported-models/clip.md).

# CLIP

OpenAI의 [CLIP](https://github.com/openai/CLIP) 이미지 및 텍스트 임베딩을 생성하고, 이들 간의 zero-shot 유사도 비교를 수행하는 모델을, 저희의 [Serverless Hosted API](/roboflow/roboflow-ko/deploy/serverless-hosted-api-v2.md). 저희는 세 개의 엔드포인트를 제공합니다:

* [`/clip/embed_image`](#post-clip-embed_image), 이미지에 대한 임베딩 벡터를 반환합니다
* [`/clip/embed_text`](#post-clip-embed_text), 문자열 또는 문자열 목록에 대한 임베딩 벡터를 반환합니다
* [`/clip/compare`](#post-clip-compare), subject와 prompt 목록 사이의 유사도 점수를 반환합니다

임베딩은 캐시하여 분류, 검색, 클러스터링, 시맨틱 검색과 같은 작업에 재사용할 수 있습니다. 더 자세한 사용 방법은 다음을 참조하세요: [Inference 문서](https://inference.roboflow.com/).

## 코드 샘플

아래는 다음을 사용하여 이미지와 텍스트 레이블 목록을 비교하는 코드 샘플입니다: [`inference-sdk`](https://inference.roboflow.com/inference_helpers/inference_sdk/). 전달하세요 [Roboflow의 API Key](https://app.roboflow.com/settings/api) 다음을 통해 `API_KEY` env 변수.

다음을 호출하세요 `/clip/compare` 엔드포인트를 직접 사용하여 `curl`:

```bash
curl --location 'https://serverless.roboflow.com/clip/compare' \
  --header 'Content-Type: application/json' \
  --data '{
    "api_key": "YOUR_API_KEY",
    "subject": {"type": "url", "value": "https://media.roboflow.com/notebooks/examples/dog.jpeg"},
    "subject_type": "image",
    "prompt": ["a photo of a dog", "a photo of a cat", "a photo of a car"],
    "prompt_type": "text"
  }'
```

SDK를 통해 동일한 호출을 할 수 있습니다. 설치하려면:

```bash
pip install inference-sdk
```

비교를 실행합니다(이미지 출처 [여기](https://media.roboflow.com/notebooks/examples/dog.jpeg)):

```python
import os
import urllib.request
from inference_sdk import InferenceHTTPClient

image_url = "https://media.roboflow.com/notebooks/examples/dog.jpeg"
image_path = "dog.jpeg"
urllib.request.urlretrieve(image_url, image_path)

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["API_KEY"],
)

result = client.clip_compare(
    subject=image_path,
    prompt=[
        "a photo of a dog",
        "a photo of a cat",
        "a photo of a car",
    ],
    subject_type="image",
    prompt_type="text",
)

# similarity는 prompt마다 하나씩 있는 코사인 유사도 점수 목록입니다
print(result["similarity"])
```

위 코드는 inference 결과를 터미널에 출력합니다:

```
[0.2726989686489105, 0.19865083694458008, 0.20997387170791626]
```

{% hint style="info" %}
설정하세요 `api_url` 를 배포 대상에 맞게:

* `https://serverless.roboflow.com` 은 Serverless Hosted API용입니다.
* `http://localhost:9001` 로컬 [Inference](https://inference.roboflow.com/) 서버용입니다.
* 귀하의 [Dedicated Deployment](/roboflow/roboflow-ko/deploy/dedicated-deployments.md) 비공개 엔드포인트용 URL입니다.
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.roboflow.com/roboflow/roboflow-ko/deploy/supported-models/clip.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
