PyTorchSemanticSegmentationSampleWriter#

class PyTorchSemanticSegmentationSampleWriter[source]#

Bases: PyTorchLearnerSampleWriter

__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.

get_label_path(sample, label_arr)

write_chip(chip, path)

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

write_sample(sample)

Write sample.

__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

get_label_path(sample: DataSample, label_arr: ndarray) str[source]#
Parameters
Return type

str

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]#

Write sample.

This writes a training or validation sample to (train|valid)/img/{scene_id}-{ind}.png and (train|valid)/labels/{scene_id}-{ind}.png

Parameters

sample (DataSample) –