ResNet

Use ResNet image classification through our Serverless Cloud API

Run ImageNet-pretrained ResNet image classification through the Serverless Cloud API, or self-host using Roboflow Inference.

ResNet pretrained aliases

Pass any of these aliases as the model_id when using the inference-sdk:

  • resnet18
  • resnet34
  • resnet50
  • resnet101

ResNet accuracy and inference speed

Latency is measured with Roboflow Inference on 1x NVIDIA L4, batch size 1, mean of 1,000 inferences (100 warmup). These aliases run on ONNX (no prebuilt TensorRT engine). Batching does not help: these checkpoints export a fixed batch dimension of 1.

Accuracy is the published ImageNet-1k spec for the standard torchvision weights (source).

AliasTop-1Top-5Latency (ms)
resnet1869.889.11.4
resnet3473.391.42.2
resnet5076.192.92.4
resnet10177.493.53.7

ResNet API

1

Get your API Key

Create a Roboflow account, find your key on the Roboflow API settings page and make it available to your shell:

export ROBOFLOW_API_KEY="your-key-here"
2

Install the dependencies

This package calls the model:

pip install -U inference-sdk supervision
3

Run the model

The sample below runs resnet50 against a remote image.

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)

Set api_url to match your deployment target:

  • https://serverless.roboflow.com for the Serverless Cloud API.
  • http://localhost:9001 for a local Inference server.
  • Your Dedicated Deployment URL for a private endpoint.