torchsig.image_datasets.datasets.yolo_datasetsΒΆ

Functions

extract_yolo_boxes

returns a list of new YOLODatum objects which each contain a single box from the input object

read_yolo_datum

loads a YOLODatum from a root directory and file name that point to a dataset in yolo format

yolo_box_on_image

returns an image tensor containing the portion of img that falls within box, where box is a tuple (cx, cy, width, height) in yolo format

yolo_to_pixels_on_image

returns the (x_start, y_start, x_end, y_end) pixels of an input box in the yolo format (cx, cy, width, height) on img

Classes

YOLODatasetAdapter

A class for adapting generic image datasets to YOLO image datasets.

YOLODatum

A class for wrapping YOLO data; contains a single datum for a YOLO dataset, with image and label data together.

YOLOFileDataset

A Dataset class for loading image and label files in YOLO format from a root directory Inputs: filepath: a string file path to a folder containing the yolo dataset transforms: either a single function or list of functions from images to images to be applied to each loaded image; used for adding noise and impairments to data; defaults to None read_black_hot: whether or not to read loaded images as black-hot; this will invert the value of loaded SOIs

YOLOImageCompositeDataset

A Dataset class generating synthetic composite images in yolo format from other image datasets Inputs: composite_scale: a tuple of the form (height, width, num_channels) specifying the scale of the image compisites to be generated; (if a 2d tuple is passed in, it will work in greyscale) transforms: either a single function or list of functions from images to images to be applied to each SOI; used for adding noise and impairments to data; defaults to None

YOLOImageCompositeDatasetComponent

Defines a component of a composite dataset; this will contain any information the composites should use to place instances of this component in the composites, such as how many instances should be place Inputs: component_dataset: a Dataset object which contains instances of this component, represented as (image_component: ndarray(c,height,width), class_id: int) min_to_add: the fewest instances of this component type to be placed in each composite max_to_add: the most instances of this type to be placed in each composite; the number of instances will be selected unifomly from min_to_add to max_to_add class_id: the int id to use for labeling data; if provided, all returned data will be of the form (component_dataset[n], (class_id, 0.5, 0.5, 1.0, 1.0)) representing a single box taking up the full image component of class class_id use_source_yolo_labels: if true, load YOLO labels from the component_dataset; otherwise component_dataset is assumed to return only image tensors;

YOLOSOIExtractorDataset

A Dataset class for loading marked signals of interest (SOIs) from a yolo format dataset Inputs: filepath: a string file path to a folder containing images in which all signals of interest have been marked wit ha colored bounding box transforms: either a single function or list of functions from images to images to be applied to each SOI; used for adding noise and impairments to data; defaults to None read_black_hot: whether or not to read loaded images as black-hot; this will invert the value of loaded SOIs soi_classes: which classes from the yolo dataset are to be considered signals of interest; None for all classes; defaults to None