> 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画像分類を実行するには、 [Serverless Cloud API](https://docs.roboflow.com/deployment/roboflow-cloud/serverless-api)、または以下を使用してセルフホストします [Roboflow Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted).

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

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

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

## ResNetの精度と推論速度

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

精度は、標準のtorchvision重みに関する公開済みのImageNet-1k仕様です（[ソース](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>

## ResNet API

{% 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, InferenceConfiguration

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"],
).configure(InferenceConfiguration(api_key_transport="header"))
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` サーバーレスクラウドAPI用。
* `http://localhost:9001` ローカルの [Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted) サーバー用。
* あなたの [Dedicated Deployment](https://docs.roboflow.com/deployment/roboflow-cloud/dedicated-deployments) プライベートエンドポイント用のURL。
  {% endhint %}
