class_docstr: App for visualizing predictions in Label Studio results format.
class_docstr_tok: ["App","for","visualizing","predictions","in","Label","Studio","results","format","."]
docstr: Construction Label Studio result from data source and prediction values.
docstr_tok: ["Construction","Label","Studio","result","from","data","source","and","prediction","values","."]
code: def _construct_result(self, pred):
      """Construction Label Studio result from data source and prediction values."""
      # get label
      if isinstance(pred, list):
          label = [list(self.parameters.classes)[p] for p in pred]
      else:
          label = list(self.parameters.classes)[pred]
      # get data type, if len(data_types) > 1 take first data type
      data_type = list(self.parameters.data_types)[0]
      # get tag type, if len(tag_types) > 1 take first tag
      tag_type = list(self.parameters.tag_types)[0]
      return {
          "result": [
              {
                  "id": "".join(
                      random.SystemRandom().choice(
                          string.ascii_uppercase
                          + string.ascii_lowercase
                          + string.digits
                      )
                      for _ in range(10)
                  ),
                  "from_name": "tag",
                  "to_name": data_type,
                  "type": tag_type,
                  "value": {
                      tag_type: label
                      if isinstance(label, list)
                      else [label]
                  },
              }
          ]
      }
  
file_path: lightning-flash/src/flash/core/integrations/labelstudio/visualizer.py
imports: import json
  import random
  import string
  from pytorch_lightning.utilities.cloud_io import get_filesystem
  from flash.core.data.data_module import DataModule
  from flash.core.integrations.labelstudio.input import LabelStudioParameters
label_desc: Use image node_id 4 for calling the App obj's underlying member method code with example usage: obj._construct_result(pred) and returns: dict