> 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/yolov12.md).

# YOLOv12

YOLOv12 物体検出モデルを Serverless Cloud API 経由で使用します

弊社の YOLOv12 物体検出推論を [Serverless Cloud API](https://docs.roboflow.com/deployment/roboflow-cloud/serverless-api)。YOLOv12 は 5 つのサイズ（`n`, `s`, `m`, `l`, `x`）で物体検出タスクに対応しています。

セルフホスト型デプロイについては、 [Roboflow Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted).

YOLOv12 の入力サイズは、Roboflow でモデルを学習する際に設定します（一般的な値: 640x640 または 1280x1280）。

## YOLOv12 API

{% stepper %}
{% step %}

### APIキーを取得する

Roboflow アカウントを作成し、キーを [Roboflow API 設定ページ](https://app.roboflow.com/settings/api) で確認して、シェルで使えるようにします:

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

{% endstep %}

{% step %}

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

次をインストールします: [Inference SDK](https://docs.roboflow.com/reference/inference/inference-sdk) および [supervision](https://supervision.roboflow.com/) 予測をデコードして可視化するために:

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

{% endstep %}

{% step %}

### モデルを実行する

この例では、次で学習された公開 YOLOv12 モデルを実行します: [ネジのデータセット](https://universe.roboflow.com/erik-pe6au/rf-bolts) （screw、flat-washer、hex-nut）。ご自身の `{workspace}/{model-slug}` を使って、学習済み重みを実行してください（参照: [バージョン、トレーニング、モデル](/models/ja/versions-trainings-and-models.md)).

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

image = sv.load_image_from_url("https://media.roboflow.com/docs/bolts.jpg")

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
).configure(InferenceConfiguration(api_key_transport="header"))
result = client.infer(image, model_id="erik-pe6au/bolts-uzqzc-4-yolo12s-t1")

detections = sv.Detections.from_inference(result)

annotated = sv.BoxAnnotator().annotate(image.copy(), detections)

cv2.imwrite("annotated.png", annotated)
```

<figure><img src="https://1194881119-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fcmo9mhfIjYrvFFy1U7dk%2Fuploads%2Fgit-blob-c2ef4d06be0aef1325d9481411947abcd13d9035%2Fyolov12-screws-detection.webp?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

{% 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 %}

## ライセンス

YOLOv12 は AGPL-3.0 の下で公開されています。商用利用における意味は次のとおりです:

* **Roboflow クラウドでは:** 無料プランを含むすべてのユーザーに商用ライセンスが含まれます。
* **セルフホストの場合:** Enterprise ライセンスのアドオンが必要です。さもなければ、アプリケーションを AGPL-3.0 の下でオープンソース化する必要があります。
* **より制約の少ない代替案:** [RF-DETR](/models/ja/supported-models/rf-detr.md) は Apache 2.0 で、どこでも商用利用無料です。

参照: [Roboflow の Ultralytics ライセンス](https://roboflow.com/ultralytics) 詳細について。
