code: def segmentations_to_polylines(
      sample_collection,
      in_field,
      out_field,
      mask_targets=None,
      mask_types="stuff",
      tolerance=2,
  ):
      """Converts the semantic segmentations masks in the specified field of the
      collection into :class:`fiftyone.core.labels.Polylines` instances.
  
      Each ``"stuff"`` class will be converted to a single
      :class:`fiftyone.core.labels.Polylines` that may contain multiple disjoint
      shapes capturing the class.
  
      Each ``"thing"`` class will result in one
      :class:`fiftyone.core.labels.Polylines` instance per connected region of
      that class.
  
      Args:
          sample_collection: a
              :class:`fiftyone.core.collections.SampleCollection`
          in_field: the name of the :class:`fiftyone.core.labels.Segmentation`
              field to convert
          out_field: the name of the
              :class:`fiftyone.core.labels.Polylines` field to populate
          mask_targets (None): a dict mapping pixel values (2D masks) or RGB hex
              strings (3D masks) to label strings defining which object classes
              to label and which pixel values to use for each class. If omitted,
              all labels are assigned to the pixel values
          mask_types ("stuff"): whether the classes are ``"stuff"`` (amorphous
              regions of pixels) or ``"thing"`` (connected regions, each
              representing an instance of the thing). Can be any of the
              following:
  
              -   ``"stuff"`` if all classes are stuff classes
              -   ``"thing"`` if all classes are thing classes
              -   a dict mapping pixel values (2D masks) or RGB hex strings (3D
                  masks) to ``"stuff"`` or ``"thing"`` for each class
          tolerance (2): a tolerance, in pixels, when generating approximate
                  polylines for each region. Typical values are 1-3 pixels
      """
      fov.validate_collection_label_fields(
          sample_collection,
          in_field,
          fol.Segmentation,
      )
  
      samples = sample_collection.select_fields(in_field)
      in_field, processing_frames = samples._handle_frame_field(
          in_field
      )
      out_field, _ = samples._handle_frame_field(out_field)
  
      for sample in samples.iter_samples(autosave=True, progress=True):
          if processing_frames:
              images = sample.frames.values()
          else:
              images = [sample]
  
          for image in images:
              label = image[in_field]
              if label is None:
                  continue
  
              image[out_field] = label.to_polylines(
                  mask_targets=mask_targets,
                  mask_types=mask_types,
                  tolerance=tolerance,
              )
  
file_path: fiftyone/fiftyone/utils/labels.py
imports: import eta.core.utils
  import fiftyone.core.labels
  import fiftyone.core.utils
  import fiftyone.core.validation
label_desc: Use image node_id 8 for calling a global function with example usage: segmentations_to_polylines(sample_collection, in_field, out_field, mask_targets, mask_types, tolerance) without return types