class_docstr: The ``ObjectDetectionData`` class is a :class:`~flash.core.data.data_module.DataModule` with a set of
  classmethods for loading data for object detection.
class_docstr_tok: ["The","``","ObjectDetectionData","``","class","is","a",":","class",":","`","~flash.core.data.data_module.DataModule","`","with","a","set","of","classmethods","for","loading","data","for","object","detection","."]
docstr: Creates a :class:`~flash.image.detection.data.ObjectDetectionData` object from the given from numpy arrays
  (or lists of arrays) and corresponding lists of bounding boxes and targets.
  
  The targets can be in any of our
  :ref:`supported classification target formats <formatting_classification_targets>`.
  The bounding boxes are expected to be dictionaries with integer values (representing pixels) and the following
  keys: ``xmin``, ``ymin``, ``width``, ``height``.
  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 to use when training.
      train_targets: The list of lists of targets to use when training.
      train_bboxes: The list of lists of bounding boxes to use when training.
      val_data: The numpy array or list of arrays to use when validating.
      val_targets: The list of lists of targets to use when validating.
      val_bboxes: The list of lists of bounding boxes to use when validating.
      test_data: The numpy array or list of arrays to use when testing.
      test_targets: The list of lists of targets to use when testing.
      test_bboxes: The list of lists of bounding boxes to use when testing.
      predict_data: The numpy array or list of arrays to use when predicting.
      target_formatter: Optionally provide a :class:`~flash.core.data.utilities.classification.TargetFormatter` to
          control how targets are handled. See :ref:`formatting_classification_targets` for more details.
      input_cls: The :class:`~flash.core.data.io.input.Input` type to use for loading the data.
      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.detection.data.ObjectDetectionData`.
  
  Examples
  ________
  
  .. doctest::
  
      >>> import numpy as np
      >>> from flash import Trainer
      >>> from flash.image import ObjectDetector, ObjectDetectionData
      >>> datamodule = ObjectDetectionData.from_numpy(
      ...     train_data=[np.random.rand(3, 64, 64), np.random.rand(3, 64, 64), np.random.rand(3, 64, 64)],
      ...     train_targets=[["cat"], ["dog"], ["cat"]],
      ...     train_bboxes=[
      ...         [{"xmin": 10, "ymin": 20, "width": 5, "height": 10}],
      ...         [{"xmin": 20, "ymin": 30, "width": 10, "height": 10}],
      ...         [{"xmin": 10, "ymin": 20, "width": 5, "height": 25}],
      ...     ],
      ...     predict_data=[np.random.rand(3, 64, 64)],
      ...     transform_kwargs=dict(image_size=(128, 128)),
      ...     batch_size=2,
      ... )
      >>> datamodule.num_classes
      3
      >>> datamodule.labels
      ['background', 'cat', 'dog']
      >>> model = ObjectDetector(labels=datamodule.labels)
      >>> 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: ["Creates","a",":","class",":","`","~flash.image.detection.data.ObjectDetectionData","`","object","from","the","given","from","numpy","arrays","(","or","lists","of","arrays",")","and","corresponding","lists","of","bounding","boxes","and","targets",".","The","targets","can","be","in","any","of","our",":","ref",":","`","supported","classification","target","formats","<","formatting_classification_targets",">","`",".","The","bounding","boxes","are","expected","to","be","dictionaries","with","integer","values","(","representing","pixels",")","and","the","following","keys",":","``","xmin","``",",","``","ymin","``",",","``","width","``",",","``","height","``",".","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","to","use","when","training",".","train_targets",":","The","list","of","lists","of","targets","to","use","when","training",".","train_bboxes",":","The","list","of","lists","of","bounding","boxes","to","use","when","training",".","val_data",":","The","numpy","array","or","list","of","arrays","to","use","when","validating",".","val_targets",":","The","list","of","lists","of","targets","to","use","when","validating",".","val_bboxes",":","The","list","of","lists","of","bounding","boxes","to","use","when","validating",".","test_data",":","The","numpy","array","or","list","of","arrays","to","use","when","testing",".","test_targets",":","The","list","of","lists","of","targets","to","use","when","testing",".","test_bboxes",":","The","list","of","lists","of","bounding","boxes","to","use","when","testing",".","predict_data",":","The","numpy","array","or","list","of","arrays","to","use","when","predicting",".","target_formatter",":","Optionally","provide","a",":","class",":","`","~flash.core.data.utilities.classification.TargetFormatter","`","to","control","how","targets","are","handled",".","See",":","ref",":","`","formatting_classification_targets","`","for","more","details",".","input_cls",":","The",":","class",":","`","~flash.core.data.io.input.Input","`","type","to","use","for","loading","the","data",".","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.detection.data.ObjectDetectionData","`",".","Examples","________","..","doctest",":",":",">",">",">","import","numpy","as","np",">",">",">","from","flash","import","Trainer",">",">",">","from","flash.image","import","ObjectDetector",",","ObjectDetectionData",">",">",">","datamodule","=","ObjectDetectionData.from_numpy","(","...","train_data=","[","np.random.rand","(","3",",","64",",","64",")",",","np.random.rand","(","3",",","64",",","64",")",",","np.random.rand","(","3",",","64",",","64",")","]",",","...","train_targets=","[","[","``","cat","''","]",",","[","``","dog","''","]",",","[","``","cat","''","]","]",",","...","train_bboxes=","[","...","[","{","``","xmin","''",":","10",",","``","ymin","''",":","20",",","``","width","''",":","5",",","``","height","''",":","10","}","]",",","...","[","{","``","xmin","''",":","20",",","``","ymin","''",":","30",",","``","width","''",":","10",",","``","height","''",":","10","}","]",",","...","[","{","``","xmin","''",":","10",",","``","ymin","''",":","20",",","``","width","''",":","5",",","``","height","''",":","25","}","]",",","...","]",",","...","predict_data=","[","np.random.rand","(","3",",","64",",","64",")","]",",","...","transform_kwargs=dict","(","image_size=","(","128",",","128",")",")",",","...","batch_size=2",",","...",")",">",">",">","datamodule.num_classes","3",">",">",">","datamodule.labels","[","'background","'",",","'cat","'",",","'dog","'","]",">",">",">","model","=","ObjectDetector","(","labels=datamodule.labels",")",">",">",">","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[Sequence[Sequence[Any]]] = None,
      train_bboxes: Optional[Sequence[Sequence[Dict[str, int]]]] = None,
      val_data: Optional[Collection[np.ndarray]] = None,
      val_targets: Optional[Sequence[Sequence[Any]]] = None,
      val_bboxes: Optional[Sequence[Sequence[Dict[str, int]]]] = None,
      test_data: Optional[Collection[np.ndarray]] = None,
      test_targets: Optional[Sequence[Sequence[Any]]] = None,
      test_bboxes: Optional[Sequence[Sequence[Dict[str, int]]]] = None,
      predict_data: Optional[Collection[np.ndarray]] = None,
      target_formatter: Optional[TargetFormatter] = None,
      input_cls: Type[Input] = ObjectDetectionNumpyInput,
      transform: INPUT_TRANSFORM_TYPE = IceVisionInputTransform,
      transform_kwargs: Optional[Dict] = None,
      **data_module_kwargs: Any,
  ) -> "ObjectDetectionData":
      """Creates a :class:`~flash.image.detection.data.ObjectDetectionData` object from the given from numpy arrays
      (or lists of arrays) and corresponding lists of bounding boxes and targets.
  
      The targets can be in any of our
      :ref:`supported classification target formats <formatting_classification_targets>`.
      The bounding boxes are expected to be dictionaries with integer values (representing pixels) and the following
      keys: ``xmin``, ``ymin``, ``width``, ``height``.
      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 to use when training.
          train_targets: The list of lists of targets to use when training.
          train_bboxes: The list of lists of bounding boxes to use when training.
          val_data: The numpy array or list of arrays to use when validating.
          val_targets: The list of lists of targets to use when validating.
          val_bboxes: The list of lists of bounding boxes to use when validating.
          test_data: The numpy array or list of arrays to use when testing.
          test_targets: The list of lists of targets to use when testing.
          test_bboxes: The list of lists of bounding boxes to use when testing.
          predict_data: The numpy array or list of arrays to use when predicting.
          target_formatter: Optionally provide a :class:`~flash.core.data.utilities.classification.TargetFormatter` to
              control how targets are handled. See :ref:`formatting_classification_targets` for more details.
          input_cls: The :class:`~flash.core.data.io.input.Input` type to use for loading the data.
          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.detection.data.ObjectDetectionData`.
  
      Examples
      ________
  
      .. doctest::
  
          >>> import numpy as np
          >>> from flash import Trainer
          >>> from flash.image import ObjectDetector, ObjectDetectionData
          >>> datamodule = ObjectDetectionData.from_numpy(
          ...     train_data=[np.random.rand(3, 64, 64), np.random.rand(3, 64, 64), np.random.rand(3, 64, 64)],
          ...     train_targets=[["cat"], ["dog"], ["cat"]],
          ...     train_bboxes=[
          ...         [{"xmin": 10, "ymin": 20, "width": 5, "height": 10}],
          ...         [{"xmin": 20, "ymin": 30, "width": 10, "height": 10}],
          ...         [{"xmin": 10, "ymin": 20, "width": 5, "height": 25}],
          ...     ],
          ...     predict_data=[np.random.rand(3, 64, 64)],
          ...     transform_kwargs=dict(image_size=(128, 128)),
          ...     batch_size=2,
          ... )
          >>> datamodule.num_classes
          3
          >>> datamodule.labels
          ['background', 'cat', 'dog']
          >>> model = ObjectDetector(labels=datamodule.labels)
          >>> 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 = {
          "target_formatter": target_formatter,
      }
  
      train_input = input_cls(
          RunningStage.TRAINING,
          train_data,
          train_targets,
          train_bboxes,
          **ds_kw,
      )
      ds_kw["target_formatter"] = getattr(
          train_input, "target_formatter", None
      )
  
      return cls(
          train_input,
          input_cls(
              RunningStage.VALIDATING,
              val_data,
              val_targets,
              val_bboxes,
              **ds_kw,
          ),
          input_cls(
              RunningStage.TESTING,
              test_data,
              test_targets,
              test_bboxes,
              **ds_kw,
          ),
          input_cls(RunningStage.PREDICTING, predict_data, **ds_kw),
          transform=transform,
          transform_kwargs=transform_kwargs,
          **data_module_kwargs,
      )
  
imports: from functools import partial
  from typing import Any, Callable, Collection, Dict, List, Optional, Sequence, Type, Union
  import numpy
  import torch
  from flash.core.data.data_module import DataModule
  from flash.core.data.io.input import Input
  from flash.core.data.utilities.classification import TargetFormatter
  from flash.core.data.utilities.sort import sorted_alphanumeric
  from flash.core.integrations.icevision.data import IceVisionInput
  from flash.core.integrations.icevision.transforms import IceVisionInputTransform
  from flash.core.utilities.imports import _FIFTYONE_AVAILABLE, _ICEVISION_AVAILABLE, _TOPIC_IMAGE_AVAILABLE, Image, requires
  from flash.core.utilities.stages import RunningStage
  from flash.core.utilities.types import INPUT_TRANSFORM_TYPE
  from flash.image.detection.input import ObjectDetectionFiftyOneInput, ObjectDetectionFilesInput, ObjectDetectionImageInput, ObjectDetectionNumpyInput, ObjectDetectionTensorInput
label_desc: Use image node_id 2 for calling the ObjectDetectionData obj's underlying member method code with example usage: obj.from_numpy(cls, train_data, train_targets, train_bboxes, val_data, val_targets, val_bboxes, test_data, test_targets, test_bboxes, predict_data, target_formatter, input_cls, transform, transform_kwargs) and returns: cls