class_docstr: The ``SemanticSegmentationData`` class is a :class:`~flash.core.data.data_module.DataModule` with a set of
  classmethods for loading data for semantic segmentation.
docstr: Load the :class:`~flash.image.segmentation.data.SemanticSegmentationData` from numpy arrays containing images
  (or lists of arrays) and corresponding numpy arrays containing masks (or lists of arrays).
  
  To learn how to customize the transforms applied for each stage, read our
  :ref:`customizing transforms guide <customizing_transforms>`.
  
  Args:
      train_data: The numpy array or list of arrays containing images to use when training.
      train_targets: The numpy array or list of arrays containing masks to use when training.
      val_data: The numpy array or list of arrays containing images to use when validating.
      val_targets: The numpy array or list of arrays containing masks to use when validating.
      test_data: The numpy array or list of arrays containing images to use when testing.
      test_targets: The numpy array or list of arrays containing masks to use when testing.
      predict_data: The numpy array or list of arrays to use when predicting.
      input_cls: The :class:`~flash.core.data.io.input.Input` type to use for loading the data.
      num_classes: The number of segmentation classes.
      labels_map: An optional mapping from class to RGB tuple indicating the colour to use when visualizing masks.
          If not provided, a random mapping will be used.
      transform: The :class:`~flash.core.data.io.input_transform.InputTransform` type to use.
      transform_kwargs: Dict of keyword arguments to be provided when instantiating the transforms.
      data_module_kwargs: Additional keyword arguments to provide to the
        :class:`~flash.core.data.data_module.DataModule` constructor.
  
  Returns:
      The constructed :class:`~flash.image.segmentation.data.SemanticSegmentationData`.
  
  Examples
  ________
  
  .. doctest::
  
      >>> import numpy as np
      >>> from flash import Trainer
      >>> from flash.image import SemanticSegmentation, SemanticSegmentationData
      >>> datamodule = SemanticSegmentationData.from_numpy(
      ...     train_data=[np.random.rand(3, 64, 64), np.random.rand(3, 64, 64), np.random.rand(3, 64, 64)],
      ...     train_targets=[
      ...         np.random.randint(0, 10, (1, 64, 64), dtype="uint8"),
      ...         np.random.randint(0, 10, (1, 64, 64), dtype="uint8"),
      ...         np.random.randint(0, 10, (1, 64, 64), dtype="uint8"),
      ...     ],
      ...     predict_data=[np.random.rand(3, 64, 64)],
      ...     transform_kwargs=dict(image_size=(128, 128)),
      ...     num_classes=10,
      ...     batch_size=2,
      ... )
      >>> datamodule.num_classes
      10
      >>> model = SemanticSegmentation(backbone="resnet18", num_classes=datamodule.num_classes)
      >>> trainer = Trainer(fast_dev_run=True)
      >>> trainer.fit(model, datamodule=datamodule)  # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
      Training...
      >>> trainer.predict(model, datamodule=datamodule)  # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
      Predicting...
docstr_tok: ["Load","the",":","class",":","`","~flash.image.segmentation.data.SemanticSegmentationData","`","from","numpy","arrays","containing","images","(","or","lists","of","arrays",")","and","corresponding","numpy","arrays","containing","masks","(","or","lists","of","arrays",")",".","To","learn","how","to","customize","the","transforms","applied","for","each","stage",",","read","our",":","ref",":","`","customizing","transforms","guide","<","customizing_transforms",">","`",".","Args",":","train_data",":","The","numpy","array","or","list","of","arrays","containing","images","to","use","when","training",".","train_targets",":","The","numpy","array","or","list","of","arrays","containing","masks","to","use","when","training",".","val_data",":","The","numpy","array","or","list","of","arrays","containing","images","to","use","when","validating",".","val_targets",":","The","numpy","array","or","list","of","arrays","containing","masks","to","use","when","validating",".","test_data",":","The","numpy","array","or","list","of","arrays","containing","images","to","use","when","testing",".","test_targets",":","The","numpy","array","or","list","of","arrays","containing","masks","to","use","when","testing",".","predict_data",":","The","numpy","array","or","list","of","arrays","to","use","when","predicting",".","input_cls",":","The",":","class",":","`","~flash.core.data.io.input.Input","`","type","to","use","for","loading","the","data",".","num_classes",":","The","number","of","segmentation","classes",".","labels_map",":","An","optional","mapping","from","class","to","RGB","tuple","indicating","the","colour","to","use","when","visualizing","masks",".","If","not","provided",",","a","random","mapping","will","be","used",".","transform",":","The",":","class",":","`","~flash.core.data.io.input_transform.InputTransform","`","type","to","use",".","transform_kwargs",":","Dict","of","keyword","arguments","to","be","provided","when","instantiating","the","transforms",".","data_module_kwargs",":","Additional","keyword","arguments","to","provide","to","the",":","class",":","`","~flash.core.data.data_module.DataModule","`","constructor",".","Returns",":","The","constructed",":","class",":","`","~flash.image.segmentation.data.SemanticSegmentationData","`",".","Examples","________","..","doctest",":",":",">",">",">","import","numpy","as","np",">",">",">","from","flash","import","Trainer",">",">",">","from","flash.image","import","SemanticSegmentation",",","SemanticSegmentationData",">",">",">","datamodule","=","SemanticSegmentationData.from_numpy","(","...","train_data=","[","np.random.rand","(","3",",","64",",","64",")",",","np.random.rand","(","3",",","64",",","64",")",",","np.random.rand","(","3",",","64",",","64",")","]",",","...","train_targets=","[","...","np.random.randint","(","0",",","10",",","(","1",",","64",",","64",")",",","dtype=","''","uint8","''",")",",","...","np.random.randint","(","0",",","10",",","(","1",",","64",",","64",")",",","dtype=","''","uint8","''",")",",","...","np.random.randint","(","0",",","10",",","(","1",",","64",",","64",")",",","dtype=","''","uint8","''",")",",","...","]",",","...","predict_data=","[","np.random.rand","(","3",",","64",",","64",")","]",",","...","transform_kwargs=dict","(","image_size=","(","128",",","128",")",")",",","...","num_classes=10",",","...","batch_size=2",",","...",")",">",">",">","datamodule.num_classes","10",">",">",">","model","=","SemanticSegmentation","(","backbone=","''","resnet18","''",",","num_classes=datamodule.num_classes",")",">",">",">","trainer","=","Trainer","(","fast_dev_run=True",")",">",">",">","trainer.fit","(","model",",","datamodule=datamodule",")","#","doctest",":","+ELLIPSIS","+NORMALIZE_WHITESPACE","Training","...",">",">",">","trainer.predict","(","model",",","datamodule=datamodule",")","#","doctest",":","+ELLIPSIS","+NORMALIZE_WHITESPACE","Predicting","..."]
code: def from_numpy(
      cls,
      train_data: Optional[Collection[np.ndarray]] = None,
      train_targets: Optional[Collection[np.ndarray]] = None,
      val_data: Optional[Collection[np.ndarray]] = None,
      val_targets: Optional[Collection[np.ndarray]] = None,
      test_data: Optional[Collection[np.ndarray]] = None,
      test_targets: Optional[Collection[np.ndarray]] = None,
      predict_data: Optional[Collection[np.ndarray]] = None,
      input_cls: Type[Input] = SemanticSegmentationNumpyInput,
      num_classes: Optional[int] = None,
      labels_map: Dict[int, Tuple[int, int, int]] = None,
      transform: INPUT_TRANSFORM_TYPE = SemanticSegmentationInputTransform,
      transform_kwargs: Optional[Dict] = None,
      **data_module_kwargs: Any,
  ) -> "SemanticSegmentationData":
      """Load the :class:`~flash.image.segmentation.data.SemanticSegmentationData` from numpy arrays containing images
      (or lists of arrays) and corresponding numpy arrays containing masks (or lists of arrays).
  
      To learn how to customize the transforms applied for each stage, read our
      :ref:`customizing transforms guide <customizing_transforms>`.
  
      Args:
          train_data: The numpy array or list of arrays containing images to use when training.
          train_targets: The numpy array or list of arrays containing masks to use when training.
          val_data: The numpy array or list of arrays containing images to use when validating.
          val_targets: The numpy array or list of arrays containing masks to use when validating.
          test_data: The numpy array or list of arrays containing images to use when testing.
          test_targets: The numpy array or list of arrays containing masks to use when testing.
          predict_data: The numpy array or list of arrays to use when predicting.
          input_cls: The :class:`~flash.core.data.io.input.Input` type to use for loading the data.
          num_classes: The number of segmentation classes.
          labels_map: An optional mapping from class to RGB tuple indicating the colour to use when visualizing masks.
              If not provided, a random mapping will be used.
          transform: The :class:`~flash.core.data.io.input_transform.InputTransform` type to use.
          transform_kwargs: Dict of keyword arguments to be provided when instantiating the transforms.
          data_module_kwargs: Additional keyword arguments to provide to the
            :class:`~flash.core.data.data_module.DataModule` constructor.
  
      Returns:
          The constructed :class:`~flash.image.segmentation.data.SemanticSegmentationData`.
  
      Examples
      ________
  
      .. doctest::
  
          >>> import numpy as np
          >>> from flash import Trainer
          >>> from flash.image import SemanticSegmentation, SemanticSegmentationData
          >>> datamodule = SemanticSegmentationData.from_numpy(
          ...     train_data=[np.random.rand(3, 64, 64), np.random.rand(3, 64, 64), np.random.rand(3, 64, 64)],
          ...     train_targets=[
          ...         np.random.randint(0, 10, (1, 64, 64), dtype="uint8"),
          ...         np.random.randint(0, 10, (1, 64, 64), dtype="uint8"),
          ...         np.random.randint(0, 10, (1, 64, 64), dtype="uint8"),
          ...     ],
          ...     predict_data=[np.random.rand(3, 64, 64)],
          ...     transform_kwargs=dict(image_size=(128, 128)),
          ...     num_classes=10,
          ...     batch_size=2,
          ... )
          >>> datamodule.num_classes
          10
          >>> model = SemanticSegmentation(backbone="resnet18", num_classes=datamodule.num_classes)
          >>> trainer = Trainer(fast_dev_run=True)
          >>> trainer.fit(model, datamodule=datamodule)  # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
          Training...
          >>> trainer.predict(model, datamodule=datamodule)  # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
          Predicting...
  
      """
  
      ds_kw = {
          "num_classes": num_classes,
          "labels_map": labels_map,
      }
  
      return cls(
          input_cls(
              RunningStage.TRAINING, train_data, train_targets, **ds_kw
          ),
          input_cls(
              RunningStage.VALIDATING, val_data, val_targets, **ds_kw
          ),
          input_cls(
              RunningStage.TESTING, test_data, test_targets, **ds_kw
          ),
          input_cls(RunningStage.PREDICTING, predict_data, **ds_kw),
          transform=transform,
          transform_kwargs=transform_kwargs,
          **data_module_kwargs,
      )
  
imports: from typing import Any, Collection, Dict, Optional, Sequence, Tuple, Type
  import numpy
  from torch import Tensor
  from flash.core.data.callback import BaseDataFetcher
  from flash.core.data.data_module import DataModule
  from flash.core.data.io.input import Input
  from flash.core.utilities.imports import _FIFTYONE_AVAILABLE, _SEGMENTATION_MODELS_AVAILABLE, lazy_import
  from flash.core.utilities.stages import RunningStage
  from flash.core.utilities.types import INPUT_TRANSFORM_TYPE
  from flash.image.segmentation.input import SemanticSegmentationFiftyOneInput, SemanticSegmentationFilesInput, SemanticSegmentationFolderInput, SemanticSegmentationNumpyInput, SemanticSegmentationTensorInput
  from flash.image.segmentation.input_transform import SemanticSegmentationInputTransform
  from flash.image.segmentation.viz import SegmentationMatplotlibVisualization
label_desc: Use image node_id 4 for calling the SemanticSegmentationData obj's underlying member method code with example usage: obj.from_numpy(cls, train_data, train_targets, val_data, val_targets, test_data, test_targets, predict_data, input_cls, num_classes, labels_map, transform, transform_kwargs) and returns: cls