PyTorchLearnerSampleWriter#

class PyTorchLearnerSampleWriter[source]#

Bases: SampleWriter

__init__(output_uri: str, class_config: ClassConfig, tmp_dir: str)[source]#

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.

write_chip(chip, path)

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

write_sample(sample)

Write a single sample to disk.

__init__(output_uri: str, class_config: ClassConfig, tmp_dir: str)[source]#

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

Decide which format to store the image in.

Parameters:

chip (ndarray) –

Return type:

str

get_image_path(sample: DataSample) str[source]#

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

Parameters:

sample (DataSample) –

Return type:

str

write_chip(chip: ndarray, path: str) None[source]#

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

Parameters:
Return type:

None

write_sample(sample: DataSample) None[source]#

Write a single sample to disk.

Parameters:

sample (DataSample) –

Return type:

None