ResNet

Use ResNet image classification through our Serverless Hosted API

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

Default aliases

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

  • resnet18

  • resnet34

  • resnet50

  • resnet101

Code sample

Install the SDK:

pip install inference-sdk

The sample below runs resnet50 against a remote image. Pass Roboflow's API Key via the API_KEY env variable.

import os
import urllib.request
from inference_sdk import InferenceHTTPClient

image_url = "https://media.roboflow.com/notebooks/examples/dog.jpeg"
image_path = "dog.jpeg"
urllib.request.urlretrieve(image_url, image_path)

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.getenv("API_KEY"),
)
results = client.infer(image_path, model_id="resnet50")
print(results)

Set api_url to match your deployment target:

  • https://serverless.roboflow.com for the Serverless Hosted API.

  • http://localhost:9001 for a local Inference server.

  • Your Dedicated Deployment URL for a private endpoint.

Last updated

Was this helpful?