readme: ---
  language:
  - en
  tags:
  - ResNet-50
  ---
  
  # ResNet-50
  
  ## Model Description
  
  ResNet-50 model from [Deep Residual Learning for Image Recognition](https://arxiv.org/abs/1512.03385) paper.
  
  ## Original implementation
  
  Follow [this link](https://huggingface.co/microsoft/resnet-50) to see the original implementation.
  
  # How to use
  
  You can use the `base` model that returns `last_hidden_state`.
  ```python
  from transformers import AutoFeatureExtractor
  from onnxruntime import InferenceSession
  from datasets import load_dataset
  
  # load image
  dataset = load_dataset("huggingface/cats-image")
  image = dataset["test"]["image"][0]
  
  # load model
  feature_extractor = AutoFeatureExtractor.from_pretrained("microsoft/resnet-50")
  session = InferenceSession("onnx/model.onnx")
  
  # ONNX Runtime expects NumPy arrays as input
  inputs = feature_extractor(image, return_tensors="np")
  outputs = session.run(output_names=["last_hidden_state"], input_feed=dict(inputs))
  ```
  
  Or you can use the model with classification head that returns `logits`.
  ```python
  from transformers import AutoFeatureExtractor
  from onnxruntime import InferenceSession
  from datasets import load_dataset
  
  # load image
  dataset = load_dataset("huggingface/cats-image")
  image = dataset["test"]["image"][0]
  
  # load model
  feature_extractor = AutoFeatureExtractor.from_pretrained("microsoft/resnet-50")
  session = InferenceSession("onnx/model_cls.onnx")
  
  # ONNX Runtime expects NumPy arrays as input
  inputs = feature_extractor(image, return_tensors="np")
  outputs = session.run(output_names=["logits"], input_feed=dict(inputs))
  ```
  