code: def object_detection_data_to_df(
      data: Union[pd.DataFrame, dict, list, str]
  ) -> pd.DataFrame:
      """
      Construct a dataframe from a data dictionary, json file path (for COCO), folder path (for VOC),
      image path (for single image), list of image paths (for multiple images)
      Parameters
      ----------
      data (dict, str, list)
  
      Returns
      -------
      a pandas DataFrame with columns "image", "rois", and "label".
      """
      if isinstance(data, dict):
          return from_dict(data)
      if isinstance(data, list):
          return from_list(data)
      if isinstance(data, str):
          if os.path.isdir(data) or data.endswith(".json"):
              return from_coco_or_voc(data)
          return from_str(data)
      if isinstance(data, pd.DataFrame):
          sanity_check_dataframe(data)
          return data
  
      raise TypeError(
          "Expected data to be an instance of dict, list, str or pd.DataFrame, but got {} of type {}".format(
              data, type(data)
          )
      )
  
imports: import json
  import logging
  import os
  import warnings
  from pathlib import Path
  from typing import Dict, Iterable, List, Optional, Union
  import defusedxml.ElementTree
  import numpy
  import pandas
  import PIL
  from torchmetrics.detection.mean_ap import MeanAveragePrecision
  from ..constants import BBOX, LABEL, MAP, MAP_50, MAP_75, MAP_LARGE, MAP_MEDIUM, MAP_SMALL, MAR_1, MAR_10, MAR_100, MAR_LARGE, MAR_MEDIUM, MAR_SMALL, MEAN_AVERAGE_PRECISION
  from .download import download, is_url
label_desc: Use image node_id 4 for calling a global function with example usage: object_detection_data_to_df(data) and returns: from_dict, from_list, from_str, data, from_coco_or_voc