bboxconverter.core.bbox_parser

bboxconverter.core.bbox_parser.FORMAT

List of supported formats. Can be one of the following: ‘voc’, ‘coco’, ‘yolo’, ‘jsonlines’

Type:

list

bboxconverter.core.bbox_parser.TYPES

List of supported bounding box types. Can be one of the following: ‘tlbr’, ‘tlwh’, ‘cwh’

Type:

list

Module Contents

Classes

BboxParser

The BboxParser class is used to ingest bounding boxes from various format into a pandas dataframe and output them in various formats.

Attributes

FORMAT

TYPES

bboxconverter.core.bbox_parser.FORMAT = ['voc', 'coco', 'yolo', 'jsonlines']
bboxconverter.core.bbox_parser.TYPES = ['tlbr', 'tlwh', 'cwh']
class bboxconverter.core.bbox_parser.BboxParser(data: pandas.core.frame.DataFrame, bbox_type)

The BboxParser class is used to ingest bounding boxes from various format into a pandas dataframe and output them in various formats.

data: pandas.core.frame.DataFrame
bbox_type: str
create_bbox(bbox_type: str, **kwargs) bboxconverter.core.bbox.BBox

Create bounding box object from a dictionary of parameters

Parameters:
  • bbox_type (str) – Type of bounding box. Can be one of the following: ‘tlbr’, ‘tlwh’, ‘cwh’

  • **kwargs (dict) – Dictionary of parameters for bounding box

create_data_splits(ds_path, train_size=0.8, val_size=0.1, test_size=0.1, save_func=to_coco) None
create_kfold_splits(ds_path, kfold, train_size=0.8, test_size=0.2, save_func=to_coco) None

Create kfold splits of the dataset and save them in the specified format

Parameters:
  • ds_path (str | Path) – Path to dataset

  • kfold (int) – Number of folds

  • train_size (float) – Size of the train split

  • test_size (float) – Size of the test split

  • save_func (function) – Function to convert bbox

export(output_path: str | Path, format: str, split=False, train_size=0.8, test_size=0.1, val_size=0.1, kfold=None) None

Export bounding boxes to a popular file format:

  • “voc” => Pascal VOC

  • “coco” => COCO

  • “yolo” => YOLO

  • “jsonlines” => Sagemaker

If split is False, the output file will contain all bounding boxes. If split is True, the output file will contain the train and test split of the dataset.

If kfold is not None, the output folder will contain the kfold split of the dataset.

Parameters:
  • output_path (str | Path) – Path to output folder. It will add the file name and extension automatically.

  • format (str) – Format of output file. Can be one of the following: ‘voc’, ‘coco’, ‘yolo’, ‘sagemaker’

  • type (str) – Type of bounding box. Can be one of the following: ‘tlbr’, ‘tlwh’, ‘cwh’

  • split (bool) – Split the dataset into train and test using scikit-learn train_test_split function.

  • train_size (float) – If float, should be between 0.0 and 1.0 and represent the proportion of the dataset to include in the test split. If int, represents the absolute number of test samples. If None, the value is set to the complement of the train size.

  • test_size (float) – If float, should be between 0.0 and 1.0 and represent the proportion of the dataset to include in the train split. If int, represents the absolute number of train samples. If None, the value is automatically set to the complement of the test size.

  • kfold (int) – Number of folds to split the dataset into. If None, the dataset will not be split into folds.

to_csv(output_path: str | Path, type) None

Export bounding boxes to a csv file.

Parameters:
  • output_path (str | Path) – Path to output file

  • type (str) – Type of bounding box. Can be one of the following: ‘tlbr’, ‘tlwh’, ‘cwh’

__str__() str

Return str(self).