PyTorchObjectDetectionSampleWriter#

class PyTorchObjectDetectionSampleWriter[source]#

Bases: PyTorchLearnerSampleWriter

Writes data in COCO format.

__init__(output_uri: str, class_config: ClassConfig, tmp_dir: str)#

Constructor.

Parameters
  • output_uri (str) – URI of directory where zip file of chips should be placed.

  • class_config (ClassConfig) – used to convert class ids to names which may be needed for some training data formats.

  • tmp_dir (str) – local directory which is root of any temporary directories that are created.

Methods

__init__(output_uri, class_config, tmp_dir)

Constructor.

get_image_ext(chip)

Decide which format to store the image in.

get_image_path(sample)

Decide the save location of the image.

update_coco_data(sample, img_path)

write_chip(chip, path)

Save chip as either a PNG image or a numpy array.

write_sample(sample)

This writes a training or validation sample to (train|valid)/img/{scene_id}-{ind}.png and updates some COCO data structures.

__init__(output_uri: str, class_config: ClassConfig, tmp_dir: str)#

Constructor.

Parameters
  • output_uri (str) – URI of directory where zip file of chips should be placed.

  • class_config (ClassConfig) – used to convert class ids to names which may be needed for some training data formats.

  • tmp_dir (str) – local directory which is root of any temporary directories that are created.

get_image_ext(chip: ndarray) str#

Decide which format to store the image in.

Parameters

chip (ndarray) –

Return type

str

get_image_path(sample: DataSample) str#

Decide the save location of the image. Also, ensure that the target directory exists.

Parameters

sample (DataSample) –

Return type

str

update_coco_data(sample: DataSample, img_path: str)[source]#
Parameters
write_chip(chip: ndarray, path: str) None#

Save chip as either a PNG image or a numpy array.

Parameters
Return type

None

write_sample(sample: DataSample)[source]#

This writes a training or validation sample to (train|valid)/img/{scene_id}-{ind}.png and updates some COCO data structures.

Parameters

sample (DataSample) –