> 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/models/ja/supported-models/yolo-world.md).

# YOLO-World

YOLO-World は、学習なしで任意のテキストクラス名から物体を検出するオープンボキャブラリー物体検出モデルです。YOLO-World の推論は、当社の [サーバーレス Cloud API](https://docs.roboflow.com/deployment/roboflow-cloud/serverless-api).

YOLO-World の実行に関する詳細は、次を参照してください [推論ドキュメント](https://docs.roboflow.com/deployment/self-hosted/self-hosted).

## YOLO-World API

HTTP エンドポイントを介して YOLO-World を直接実行するには、 `curl`、または [`inference-sdk`](https://docs.roboflow.com/reference/inference/inference-sdk) ラッパー。

{% tabs %}
{% tab title="HTTP（curl）" icon="webhook" %}
{% stepper %}
{% step %}

### API キーを取得

Roboflow アカウントを作成し、次でキーを見つけてください [Roboflow API 設定ページ](https://app.roboflow.com/settings/api) そしてシェルで使用できるようにします：

```bash
export ROBOFLOW_API_KEY="your-key-here"
```

{% endstep %}

{% step %}

### モデルを実行

次を呼び出します `/yolo_world/infer` エンドポイントを `curl`:

```bash
curl --location 'https://serverless.roboflow.com/yolo_world/infer' \
  --header 'Content-Type: application/json' \
  --data '{
    "api_key": "'"$ROBOFLOW_API_KEY"'",
    "image": {"type": "url", "value": "https://media.roboflow.com/quickstart/traffic.jpg"},
    "text": ["car", "truck"],
    "yolo_world_version_id": "v2-s",
    "confidence": 0.05
  }'
```

{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="SDK（Python）" icon="python" %}
{% stepper %}
{% step %}

### API キーを取得

Roboflow アカウントを作成し、次でキーを見つけてください [Roboflow API 設定ページ](https://app.roboflow.com/settings/api) そしてシェルで使用できるようにします：

```bash
export ROBOFLOW_API_KEY="your-key-here"
```

{% endstep %}

{% step %}

### 依存関係をインストール

SDK と [supervision](https://supervision.roboflow.com/):

```bash
pip install -U inference-sdk supervision
```

{% endstep %}

{% step %}

### モデルを実行

カスタムクラス名で YOLO-World を実行し、その後 supervision で予測をデコードして可視化します。

```python
import os
import cv2
import supervision as sv
from inference_sdk import InferenceHTTPClient

image = sv.load_image_from_url("https://media.roboflow.com/quickstart/traffic.jpg")

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

results = client.infer_from_yolo_world(
    inference_input=image,
    class_names=["car", "truck"],
    model_version="v2-s",
    confidence=0.05,
)

detections = sv.Detections.from_inference(results[0])

labels = [
    f"{name} {conf:.2f}"
    for name, conf in zip(detections.data["class_name"], detections.confidence)
]
annotated = sv.BoxAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator().annotate(annotated, detections, labels=labels)
cv2.imwrite("annotated.png", annotated)
```

<figure><img src="/files/926228b5a1828397249ea518f38492080b3b622b" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}
{% endtab %}
{% endtabs %}

この `class_names` 引数には任意のクラス名リストを指定できます。使用可能な `model_version` の値： `v2-s`, `v2-m`, `v2-l`, `v2-x`, `s`, `m`, `l`, `x`.

## YOLO-World の推論速度

レイテンシの計測条件： [Roboflow Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted) 1 基の NVIDIA L4、バッチサイズ 1、ウォームアップ後の平均値。

<table data-search="false"><thead><tr><th>モデル</th><th>レイテンシ（ms）</th></tr></thead><tbody><tr><td><code>yolo-world</code></td><td>12.4</td></tr></tbody></table>

次の `v2-s` 2 クラスのバリアントで計測しました。クラスリストを設定するとテキストエンコーダーが 1 回実行されますが、フレームごとに繰り返されないため、この図には含めていません。

{% hint style="info" %}
設定 `api_url` をデプロイ先に合わせます：

* `https://serverless.roboflow.com` Serverless Cloud API 用。
* `http://localhost:9001` ローカルの [Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted) サーバー。
* あなたの [専用デプロイ](https://docs.roboflow.com/deployment/roboflow-cloud/dedicated-deployments) プライベートエンドポイントの URL。
  {% endhint %}

## セルフホストの Inference で YOLO-World を実行

YOLO-World は独自のハードウェアでも動作し、次の [`inference`](https://docs.roboflow.com/deployment/self-hosted/self-hosted) パッケージでプロセス内に読み込むか、ローカルの Inference サーバーから提供できます。対応ハードウェア（たとえば V100 GPU）ではリアルタイムで動作するため、動画用途に実用的です。

{% tabs %}
{% tab title="Inference（ネイティブ）" icon="server" %}

```bash
pip install "inference[yolo-world]" supervision
```

```python
import cv2
import supervision as sv

from inference.models.yolo_world.yolo_world import YOLOWorld

image = cv2.imread("image.jpeg")

model = YOLOWorld(model_id="yolo_world/l")
classes = ["person", "backpack", "dog"]
results = model.infer("image.jpeg", text=classes, confidence=0.03)[0]

detections = sv.Detections.from_inference(results)
labels = [classes[class_id] for class_id in detections.class_id]

annotated = sv.BoxAnnotator().annotate(scene=image, detections=detections)
annotated = sv.LabelAnnotator().annotate(
    scene=annotated, detections=detections, labels=labels
)
sv.plot_image(annotated)
```

{% endtab %}

{% tab title="ローカル Inference サーバー" icon="docker" %}

```bash
pip install inference inference-sdk
inference server start  # http://localhost:9001 を提供します
```

```python
import os
from inference_sdk import InferenceHTTPClient

client = InferenceHTTPClient(
    api_url="http://127.0.0.1:9001",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)

results = client.infer_from_yolo_world(
    inference_input=["https://media.roboflow.com/dog.jpeg"],
    class_names=["person", "backpack", "dog"],
    model_version="l",
    confidence=0.1,
)[0]
```

{% endtab %}

{% tab title="動画" icon="video" %}
Workflow に YOLO-World ブロックを追加し、検出したいクラスを設定します。次に、Web カメラ、カメラフィード、または動画ファイルをその Workflow に通して、次の [Inference SDK WebRTC クライアント](https://docs.roboflow.com/workflows/deploy/video-processing).
{% endtab %}
{% endtabs %}

ネイティブパッケージでは、YOLO-World のチェックポイントは次のように識別されます `yolo_world/<version>`、ここで `<version>` は次のいずれかです `s`, `m`, `l`, `x`, `v2-s`, `v2-m`, `v2-l`, `v2-x`。 `v2-` のチェックポイントはより新しく、評価指標でもより高いスコアを示します。

{% hint style="info" %}
多くのゼロショット検出器と同様に、YOLO-World は一般的な物体（車、人、犬）に最も強く、狭く細分化されたカテゴリは苦手です。プロンプトの言い回しを試して、シーンに合うものを見つけてください。
{% endhint %}
