class_docstr: Image classification pipeline using any `AutoModelForImageClassification`. This pipeline predicts the class of an
  image.
  
  Example:
  
  ```python
  >>> from transformers import pipeline
  
  >>> classifier = pipeline(model="microsoft/beit-base-patch16-224-pt22k-ft22k")
  >>> classifier("https://huggingface.co/datasets/Narsil/image_dummy/raw/main/parrots.png")
  [{'score': 0.442, 'label': 'macaw'}, {'score': 0.088, 'label': 'popinjay'}, {'score': 0.075, 'label': 'parrot'}, {'score': 0.073, 'label': 'parodist, lampooner'}, {'score': 0.046, 'label': 'poll, poll_parrot'}]
  ```
  
  Learn more about the basics of using a pipeline in the [pipeline tutorial](../pipeline_tutorial)
  
  This image classification pipeline can currently be loaded from [`pipeline`] using the following task identifier:
  `"image-classification"`.
  
  See the list of available models on
  [huggingface.co/models](https://huggingface.co/models?filter=image-classification).
class_docstr_tok: ["Image","classification","pipeline","using","any","`","AutoModelForImageClassification","`",".","This","pipeline","predicts","the","class","of","an","image",".","Example",":","``","`","python",">",">",">","from","transformers","import","pipeline",">",">",">","classifier","=","pipeline","(","model=","''","microsoft\/beit-base-patch16-224-pt22k-ft22k","''",")",">",">",">","classifier","(","``","https",":","\/\/huggingface.co\/datasets\/Narsil\/image_dummy\/raw\/main\/parrots.png","''",")","[","{","'score","'",":","0.442",",","'label","'",":","'macaw","'","}",",","{","'score","'",":","0.088",",","'label","'",":","'popinjay","'","}",",","{","'score","'",":","0.075",",","'label","'",":","'parrot","'","}",",","{","'score","'",":","0.073",",","'label","'",":","'parodist",",","lampooner","'","}",",","{","'score","'",":","0.046",",","'label","'",":","'poll",",","poll_parrot","'","}","]","``","`","Learn","more","about","the","basics","of","using","a","pipeline","in","the","[","pipeline","tutorial","]","(","..","\/pipeline_tutorial",")","This","image","classification","pipeline","can","currently","be","loaded","from","[","`","pipeline","`","]","using","the","following","task","identifier",":","`","``","image-classification","''","`",".","See","the","list","of","available","models","on","[","huggingface.co\/models","]","(","https",":","\/\/huggingface.co\/models","?","filter=image-classification",")","."]
code: def postprocess(self, model_outputs, function_to_apply=None, top_k=5):
      if function_to_apply is None:
          if (
              self.model.config.problem_type
              == "multi_label_classification"
              or self.model.config.num_labels == 1
          ):
              function_to_apply = ClassificationFunction.SIGMOID
          elif (
              self.model.config.problem_type
              == "single_label_classification"
              or self.model.config.num_labels > 1
          ):
              function_to_apply = ClassificationFunction.SOFTMAX
          elif (
              hasattr(self.model.config, "function_to_apply")
              and function_to_apply is None
          ):
              function_to_apply = self.model.config.function_to_apply
          else:
              function_to_apply = ClassificationFunction.NONE
  
      if top_k > self.model.config.num_labels:
          top_k = self.model.config.num_labels
  
      outputs = model_outputs["logits"][0]
      outputs = outputs.numpy()
  
      if function_to_apply == ClassificationFunction.SIGMOID:
          scores = sigmoid(outputs)
      elif function_to_apply == ClassificationFunction.SOFTMAX:
          scores = softmax(outputs)
      elif function_to_apply == ClassificationFunction.NONE:
          scores = outputs
      else:
          raise ValueError(
              f"Unrecognized `function_to_apply` argument: {function_to_apply}"
          )
  
      dict_scores = [
          {
              "label": self.model.config.id2label[i],
              "score": score.item(),
          }
          for i, score in enumerate(scores)
      ]
      dict_scores.sort(key=lambda x: x["score"], reverse=True)
      if top_k is not None:
          dict_scores = dict_scores[:top_k]
  
      return dict_scores
  
file_path: transformers/src/transformers/pipelines/image_classification.py
imports: from typing import List, Union
  import numpy
  from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends
  from .base import PIPELINE_INIT_ARGS, Pipeline
label_desc: Use image node_id 6 for calling the ImageClassificationPipeline obj's underlying member method code with example usage: obj.postprocess(model_outputs, function_to_apply, top_k) and returns: dict_scores