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 import session

image = "tests/assets/cat.jpg"

resnet50 = ResNet50.load()
with session.create(resnet50.enf) as sess:
    inputs, _ = resnet50.preprocess(image)
    outputs = sess.run(inputs).numpy()
    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, npt.ArrayLike]

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

required

Returns:

Type Description
Tuple[np.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