> 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-nas.md).

# YOLO-NAS

YOLO-NAS は、ニューラルアーキテクチャサーチによって作成された Deci の物体検出モデルです。Roboflow では、COCO で事前学習された YOLO-NAS のチェックポイントを短い別名で提供しており、 [独自の重みをアップロードして](/models/ja/moderunomi/upload-custom-weights.md) 他で学習したモデルを実行できます。

Roboflow では YOLO-NAS の学習はサポートされていません。Roboflow で学習された検出器については、参照してください [RF-DETR](/models/ja/supported-models/rf-detr.md), [YOLO26](/models/ja/supported-models/yolo26.md)、または [YOLO11](/models/ja/supported-models/yolo11.md).

## 事前学習済みエイリアス

次のいずれかの ID を `model_id` として渡すと、何も学習せずに COCO で事前学習済みのチェックポイントを実行できます。完全な一覧は [事前学習済みモデルのエイリアス](/models/ja/pretrained-aliases.md) ページにあります。

| モデル         | 入力サイズ | タスク  | モデルID            | テスト                                                               |
| ----------- | ----- | ---- | ---------------- | ----------------------------------------------------------------- |
| YOLO-NAS（小） | 640   | 物体検出 | `yolo-nas-s-640` | [ブラウザでテスト](https://universe.roboflow.com/microsoft/coco/model/14) |
| YOLO-NAS（中） | 640   | 物体検出 | `yolo-nas-m-640` | [ブラウザでテスト](https://universe.roboflow.com/microsoft/coco/model/15) |
| YOLO-NAS（大） | 640   | 物体検出 | `yolo-nas-l-640` | [ブラウザでテスト](https://universe.roboflow.com/microsoft/coco/model/16) |

## コード例

{% stepper %}
{% step %}

### APIキーを取得する

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

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

{% endstep %}

{% step %}

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

Inference SDK と [supervision](https://supervision.roboflow.com/) をインストールして、予測のデコードと描画に使います:

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

{% endstep %}

{% step %}

### モデルを実行する

この例では、事前学習済みの `yolo-nas-s-640` チェックポイントを実行します。独自の重みを提供するには、 `{workspace}/{model-slug}` の [バージョン、学習、モデル](/models/ja/versions-trainings-and-models.md)).

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

image = sv.load_image_from_url("https://media.roboflow.com/inference/people-walking.jpg")

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)
results = client.infer(image, model_id="yolo-nas-s-640")

detections = sv.Detections.from_inference(results)

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)
```

{% endstep %}
{% endstepper %}

{% hint style="info" %}
設定する `api_url` をデプロイ先に合わせてください:

* `https://serverless.roboflow.com` Serverless Hosted 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`](https://docs.roboflow.com/deployment/self-hosted/self-hosted) パッケージを使って、チェックポイントをプロセス内で読み込むこともできます:

```python
from inference import get_model

model = get_model(model_id="yolo-nas-s-640")
results = model.infer("https://media.roboflow.com/inference/people-walking.jpg")
```
