class_docstr: Simple container holding score calibration related parameters.
class_docstr_tok: ["Simple","container","holding","score","calibration","related","parameters","."]
docstr: Creates ScoreCalibration from the file.
  
  Args:
    transformation_type: type of the function used for transforming the
      uncalibrated score before applying score calibration.
    file_path: file_path of the score calibration file [1]. Contains
      sigmoid-based score calibration parameters, formatted as CSV. Lines
      contain for each index of an output tensor the scale, slope, offset and
      (optional) min_score parameters to be used for sigmoid fitting (in this
      order and in `strtof`-compatible [2] format). Scale should be a
      non-negative value. A line may be left empty to default calibrated
      scores for this index to default_score. In summary, each line should
      thus contain 0, 3 or 4 comma-separated values.
    default_score: the default calibrated score to apply if the uncalibrated
      score is below min_score or if no parameters were specified for a given
      index.
    [1]:
      https://github.com/google/mediapipe/blob/f8af41b1eb49ff4bdad756ff19d1d36f486be614/mediapipe/tasks/metadata/metadata_schema.fbs#L133
    [2]:
      https://en.cppreference.com/w/c/string/byte/strtof
  
  Returns:
    A ScoreCalibration object.
  Raises:
    ValueError: if the score_calibration file is malformed.
code: def create_from_file(
      cls,
      transformation_type: metadata_fb.ScoreTransformationType,
      file_path: str,
      default_score: int = 0,
  ) -> "ScoreCalibration":
      """Creates ScoreCalibration from the file.
  
      Args:
        transformation_type: type of the function used for transforming the
          uncalibrated score before applying score calibration.
        file_path: file_path of the score calibration file [1]. Contains
          sigmoid-based score calibration parameters, formatted as CSV. Lines
          contain for each index of an output tensor the scale, slope, offset and
          (optional) min_score parameters to be used for sigmoid fitting (in this
          order and in `strtof`-compatible [2] format). Scale should be a
          non-negative value. A line may be left empty to default calibrated
          scores for this index to default_score. In summary, each line should
          thus contain 0, 3 or 4 comma-separated values.
        default_score: the default calibrated score to apply if the uncalibrated
          score is below min_score or if no parameters were specified for a given
          index.
        [1]:
          https://github.com/google/mediapipe/blob/f8af41b1eb49ff4bdad756ff19d1d36f486be614/mediapipe/tasks/metadata/metadata_schema.fbs#L133
        [2]:
          https://en.cppreference.com/w/c/string/byte/strtof
  
      Returns:
        A ScoreCalibration object.
      Raises:
        ValueError: if the score_calibration file is malformed.
      """
      with open(file_path, "r") as calibration_file:
          csv_reader = csv.reader(calibration_file, delimiter=",")
          parameters = []
          for row in csv_reader:
              if not row:
                  parameters.append(None)
                  continue
  
              if len(row) != 3 and len(row) != 4:
                  raise ValueError(
                      f"Expected empty lines or 3 or 4 parameters per line in score"
                      f" calibration file, but got {len(row)}."
                  )
  
              if float(row[0]) < 0:
                  raise ValueError(
                      f"Expected scale to be a non-negative value, but got "
                      f"{float(row[0])}."
                  )
  
              parameters.append(
                  CalibrationParameter(
                      scale=float(row[0]),
                      slope=float(row[1]),
                      offset=float(row[2]),
                      min_score=None
                      if len(row) == 3
                      else float(row[3]),
                  )
              )
  
      return cls(transformation_type, parameters, default_score)
  
imports: import collections
  import csv
  import dataclasses
  import os
  import tempfile
  from typing import List, Optional, Tuple, Union
  import flatbuffers
  from mediapipe.tasks.metadata import metadata_schema_py_generated
  from mediapipe.tasks.python.metadata import metadata
  from mediapipe.tasks.python.metadata.metadata_writers import metadata_info
  from mediapipe.tasks.python.metadata.metadata_writers import writer_utils
label_desc: Use image node_id 2 for calling the ScoreCalibration obj's underlying member method code with example usage: obj.create_from_file(cls, transformation_type, file_path, default_score) and returns: cls