Skip to content

ResNet50 v1.5

ResNet50 v1.5 backbone model trained on ImageNet (224x224). This model has been used since MLCommons v0.5.

Overall

  • Framework: PyTorch
  • Model format: ONNX
  • Model task: Image classification
  • Source: This model is originated from ResNet50 v1.5 in ONNX available at MLCommons - Supported Models.

Usages

from furiosa.models.vision import ResNet50
from furiosa.runtime.sync import create_runner

image = "tests/assets/cat.jpg"

resnet50 = ResNet50()
with create_runner(resnet50.model_source()) as runner:
    inputs, _ = resnet50.preprocess(image)
    outputs = runner.run(inputs)
    resnet50.postprocess(outputs)

Inputs

The input is a 3-channel image of 224x224 (height, width).

  • Data Type: numpy.float32
  • Tensor Shape: [1, 3, 224, 224]
  • Memory Format: NCHW, where:
    • N - batch size
    • C - number of channels
    • H - image height
    • W - image width
  • Color Order: BGR
  • Optimal Batch Size (minimum: 1): <= 8

Outputs

The output is a numpy.float32 tensor with the shape ([1,]), including a class id. postprocess() transforms the class id to a label string.

Pre/Postprocessing

furiosa.models.vision.ResNet50 class provides preprocess and postprocess methods that convert input images to input tensors and the model outputs to labels respectively. You can find examples at ResNet50 Usage.

furiosa.models.vision.ResNet50.preprocess

Convert an input image to a model input tensor

Parameters:

Name Type Description Default
image Union[str, ArrayLike]

A path of an image or an image loaded as a numpy array in BGR order.

required
with_scaling bool

Whether to apply model-specific techniques that involve scaling the model's input and converting its data type to float32. Refer to the code to gain a precise understanding of the techniques used. Defaults to False.

False

Returns:

Type Description
Tuple[ndarray, None]

The first element of the tuple is a numpy array that meets the input requirements of the ResNet50 model. The second element of the tuple is unused in this model and has no value. To learn more information about the output numpy array, please refer to Inputs.

furiosa.models.vision.ResNet50.postprocess

Convert the outputs of a model to a label string, such as car and cat.

Parameters:

Name Type Description Default
model_outputs Sequence[ArrayLike]

the outputs of the model. Please learn more about the output of model, please refer to Outputs.

required

Returns:

Name Type Description
str str

A classified label, e.g., "tabby, tabby cat".