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

# ResNet

ImageNet事前学習済みResNetの画像分類を、〜で実行 [サーバーレスホスト型 API](https://docs.roboflow.com/deployment/roboflow-cloud/serverless-api)、または次を使用してセルフホストできます [Roboflow Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted).

## デフォルトのエイリアス

次のいずれかのエイリアスを `model_id` 〜を使用する場合 [inference-sdk](https://docs.roboflow.com/deployment/roboflow-cloud/serverless-api#python-sdk):

* `resnet18`
* `resnet34`
* `resnet50`
* `resnet101`

## 精度と推論速度

レイテンシは〜を用いて測定されます [Roboflow Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted) 1x NVIDIA L4、バッチサイズ1、1,000回の推論の平均（100回のウォームアップ）で測定。これらのエイリアスはONNX上で実行されます（事前ビルド済みのTensorRTエンジンはありません）。バッチ処理は役に立ちません。これらのチェックポイントは固定バッチ次元1でエクスポートされます。

精度は、標準のtorchvision重み（[ソース](https://pytorch.org/vision/stable/models.html)).

<table data-search="false"><thead><tr><th>別名</th><th>Top-1</th><th>Top-5</th><th>レイテンシ（ms）</th></tr></thead><tbody><tr><td><code>resnet18</code></td><td>69.8</td><td>89.1</td><td>1.4</td></tr><tr><td><code>resnet34</code></td><td>73.3</td><td>91.4</td><td>2.2</td></tr><tr><td><code>resnet50</code></td><td>76.1</td><td>92.9</td><td>2.4</td></tr><tr><td><code>resnet101</code></td><td>77.4</td><td>93.5</td><td>3.7</td></tr></tbody></table>

## コード例

{% stepper %}
{% step %}

### API キーを取得する

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

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

{% endstep %}

{% step %}

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

このパッケージは次のモデルを呼び出します：

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

{% endstep %}

{% step %}

### モデルを実行する

以下のサンプルを実行します `resnet50` リモート画像に対して。

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

image = sv.load_image_from_url("https://media.roboflow.com/notebooks/examples/dog.jpeg")

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)
results = client.infer(image, model_id="resnet50")
print(results)
```

<figure><img src="/files/6423c89ceae161e5a1a2c5520a8ec1e8d03473b8" alt=""><figcaption></figcaption></figure>
{% 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 %}
