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:
resnet18resnet34resnet50resnet101
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).
| Alias | Top-1 | Top-5 | Latency (ms) |
|---|---|---|---|
resnet18 | 69.8 | 89.1 | 1.4 |
resnet34 | 73.3 | 91.4 | 2.2 |
resnet50 | 76.1 | 92.9 | 2.4 |
resnet101 | 77.4 | 93.5 | 3.7 |
ResNet API
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"Install the dependencies
This package calls the model:
pip install -U inference-sdk supervisionRun 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.comfor the Serverless Cloud API.http://localhost:9001for a local Inference server.- Your Dedicated Deployment URL for a private endpoint.