您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

11 KiB

Table of Contents

pyrception_utils

pyrception_utils.cli

preview

@subcommand(
    [argument("--data", type=str, help="The path to the main perception data folder.")]
)
preview(args)

Previews the dataset in a streamlit app.

pyrception_utils.preview

list_datasets

list_datasets(path) -> List

Lists the datasets in a diretory.

Arguments:

  • path: path to a directory that contains dataset folders :type str:

Returns:

A list of dataset directories. :rtype: List

frame_selector_ui

frame_selector_ui(dataset: PyrceptionDataset) -> int

Frame selector streamlist widget to select which frame in the dataset to display

Arguments:

  • dataset: the PyrceptionDataset :type PyrceptionDataset:

Returns:

The image index :rtype: int

draw_image_with_boxes

draw_image_with_boxes

draw_image_with_boxes(image: Image, classes: Dict, labels: List, boxes: List[List], colors: Dict, header: str, description: str)

Draws an image in streamlit with labels and bounding boxes.

Arguments:

  • image: the PIL image :type PIL:
  • classes: the class dictionary :type Dict:
  • labels: list of integer object labels for the frame :type List:
  • boxes: List of bounding boxes (as a List of coordinates) for the frame :type List[List]:
  • colors: class colors :type Dict:
  • header: Image header :type str:
  • description: Image description :type str:

load_perception_dataset

@st.cache(show_spinner=True, allow_output_mutation=True)
load_perception_dataset(path: str) -> Tuple

Loads the perception dataset in the cache and caches the random bounding box color scheme.

Arguments:

  • path: Dataset path :type str:

Returns:

A tuple with the colors and PyrceptionDataset object as (colors, dataset) :rtype: Tuple

preview_dataset

preview_dataset(base_dataset_dir: str)

Adds streamlit components to the app to construct the dataset preview.

Arguments:

  • base_dataset_dir: The directory that contains the perceptions datasets. :type str:

preview_app

preview_app(args)

Starts the dataset preview app.

Arguments:

  • args: Arguments for the app, such as dataset :type args: Namespace

pyrception_utils.pyrception

FileType Objects

class FileType(Enum)

Enumerator for file types in the perception dataset. Based on

glob

glob(data_root: str, pattern: str) -> Iterator[str]

Find all files in a directory, data_dir, that match the pattern.

Arguments:

  • data_root: The path to the directory that contains the dataset. :type str:
  • pattern: The file pattern to match. :type str:

Returns:

Returns an string iterator containing the paths to the matching files. :rtype: Iterator[str]

file_number

file_number(filename)

Key function to sort glob list.

Arguments:

  • filename: POSIX path :type filename:

Returns:

:rtype:

glob_list

glob_list(data_root: str, pattern: str) -> List

Find all files in a directory, data_dir, that match the pattern.

Arguments:

  • data_root: The path to the directory that contains the dataset. :type str:
  • pattern: The file pattern to match. :type str:

Returns:

Returns an string iterator containing the paths to the matching files. :rtype: Iterator[str]

load_json

load_json(file: str, key: Union[str, List]) -> Dict

Loads top level records from json file given key or list of keys.

Arguments:

  • file: The json filename. :type str:
  • key: The top-level key or list of keys to load. :type Union[str, List]:

Returns:

Returns a dictionary representing the json record :rtype: Dict

PyrceptionDatasetMetadata Objects

class PyrceptionDatasetMetadata()

__init__

 | __init__(data_dir: str = None)

Creates a PyrceptionDataset object that can be used to iterate through the perception dataset.

Arguments:

  • data_dir: The path to the perception dataset. :type str:

PyrceptionDataset Objects

class PyrceptionDataset()

Pyrception class for reading and visualizing annotations generated by the perception SDK.

__init__

 | __init__(metadata: PyrceptionDatasetMetadata = None, data_dir: str = None)

Creates a PyrceptionDataset object that can be used to iterate through the perception dataset.

Arguments:

  • data_dir: The path to the perception dataset. :type str:

__getitem__

 | __getitem__(index: int) -> Tuple

Iterator to get one frame at a time based on index.

Arguments:

  • index: the index of the frame to retrieve :type int:

Returns:

Returns a tuple containing the image and target metadata as (image, target) :rtype: Tuple

__len__

 | __len__() -> int

Returns the length of the perception dataset.

Returns:

Length of the dataset. :rtype: int

pyrception_utils.pyrception_gcs

FileType Objects

class FileType(Enum)

Enumerator for file types in the perception dataset. Based on

glob

glob(data_root: str, pattern: str) -> Iterator[str]

Find all files in a directory, data_dir, that match the pattern.

Arguments:

  • data_root: The path to the directory that contains the dataset. :type str:
  • pattern: The file pattern to match. :type str:

Returns:

Returns an string iterator containing the paths to the matching files. :rtype: Iterator[str]

glob_list

glob_list(fs: GCSFileSystem, data_root: str, pattern: str) -> List

Find all files in a directory, data_dir, that match the pattern.

Arguments:

  • fs: the GCSFileSystem object :type GCSFileSystem
  • data_root: The path to the directory that contains the dataset. :type str:
  • pattern: The file pattern to match. :type str:

Returns:

Returns an string iterator containing the paths to the matching files. :rtype: Iterator[str]

load_json

load_json(fs: GCSFileSystem, file: str, key: Union[str, List]) -> Dict

Loads top level records from json file given key or list of keys.

Arguments:

  • fs: the GCSFileSystem object :type GCSFileSystem
  • file: The json filename. :type str:
  • key: The top-level key or list of keys to load. :type Union[str, List]:

Returns:

Returns a dictionary representing the json record :rtype: Dict

PyrceptionGCSDataset Objects

class PyrceptionGCSDataset()

Pyrception class for reading and visualizing annotations generated by the perception SDK.

__init__

 | __init__(project_id: str = None, dataset_bucket: str = None, dataset_folder: str = None)

Creates a PyrceptionDataset object that can be used to iterate through the perception dataset.

Arguments:

  • dataset_bucket: The path to the perception dataset. :type str:

__getitem__

 | __getitem__(index: int) -> Tuple

Iterator to get one frame at a time based on index.

Arguments:

  • index: the index of the frame to retrieve :type int:

Returns:

Returns a tuple containing the image and target metadata as (image, target) :rtype: Tuple

__len__

 | __len__() -> int

Returns the length of the perception dataset.

Returns:

Length of the dataset. :rtype: int