class_docstr: Displays a classification label, along with confidence scores of top categories, if provided.
  Preprocessing: this component does *not* accept input.
  Postprocessing: expects a {Dict[str, float]} of classes and confidences, or {str} with just the class or an {int}/{float} for regression outputs, or a {str} path to a .json file containing a json dictionary in the structure produced by Label.postprocess().
  
  Demos: main_note, titanic_survival
  Guides: image-classification-in-pytorch, image-classification-in-tensorflow, image-classification-with-vision-transformers
class_docstr_tok: ["Displays","a","classification","label",",","along","with","confidence","scores","of","top","categories",",","if","provided",".","Preprocessing",":","this","component","does","*","not","*","accept","input",".","Postprocessing",":","expects","a","{","Dict","[","str",",","float","]","}","of","classes","and","confidences",",","or","{","str","}","with","just","the","class","or","an","{","int","}","\/","{","float","}","for","regression","outputs",",","or","a","{","str","}","path","to","a",".json","file","containing","a","json","dictionary","in","the","structure","produced","by","Label.postprocess","(",")",".","Demos",":","main_note",",","titanic_survival","Guides",":","image-classification-in-pytorch",",","image-classification-in-tensorflow",",","image-classification-with-vision-transformers"]
code: def postprocess(
      self, value: dict[str, float] | str | float | None
  ) -> LabelData | dict | None:
      if value is None or value == {}:
          return {}
      if (
          isinstance(value, str)
          and value.endswith(".json")
          and Path(value).exists()
      ):
          return LabelData(**json.loads(Path(value).read_text()))
      if isinstance(value, (str, float, int)):
          return LabelData(label=str(value))
      if isinstance(value, dict):
          if "confidences" in value and isinstance(
              value["confidences"], dict
          ):
              value = value["confidences"]
              value = {c["label"]: c["confidence"] for c in value}
          sorted_pred = sorted(
              value.items(), key=operator.itemgetter(1), reverse=True
          )
          if self.num_top_classes is not None:
              sorted_pred = sorted_pred[: self.num_top_classes]
          return LabelData(
              label=sorted_pred[0][0],
              confidences=[
                  LabelConfidence(label=pred[0], confidence=pred[1])
                  for pred in sorted_pred
              ],
          )
      raise ValueError(
          "The `Label` output interface expects one of: a string label, or an int label, a "
          "float label, or a dictionary whose keys are labels and values are confidences. "
          f"Instead, got a {type(value)}"
      )
  
file_path: gradio/gradio/components/label.py
imports: from __future__ import annotations
  import json
  import operator
  from pathlib import Path
  from typing import Any, Callable, List, Optional, Union
  from gradio_client.documentation import document, set_documentation_group
  from gradio.components.base import Component
  from gradio.data_classes import GradioModel
  from gradio.events import Events
label_desc: Use image node_id 2 for calling the Label obj's underlying member method code with example usage: obj.postprocess(value) and returns: dict, LabelData, LabelData, LabelData