trw.train.sample_export

We assume throughout that the image format is (samples, channels, height, width)

Module Contents

Functions

as_rgb_image(value)

Try interpreting the value as an image. (e.g., 2D, RGB) and return a RGB image

as_image_ui8(image, min_value=None, max_value=None)

Rescale the image to fit in [0..255] range.

export_image(image, path)

Export an image

export_as_image(name, samples, sample_id, export_root, txt_file)

Export a value as an image

export_as_npy(name, samples, sample_id, export_root, txt_file)

export_as_string(name, samples, sample_id, export_root, txt_file, max_len=1024)

export_functions()

Default export functions

clean_mapping_name(name)

export_sample(batch, sample_id, export_root, txt_file, exports=export_functions, features_to_discard=None, clean_mapping_name_fn=clean_mapping_name, classification_mappings=None)

Export a sample from the batch

trw.train.sample_export.as_rgb_image(value)

Try interpreting the value as an image. (e.g., 2D, RGB) and return a RGB image :param value: an array of shape (y, x), (1, y, x), (3, y, x) :return: return a (3, y, x) array

trw.train.sample_export.as_image_ui8(image, min_value=None, max_value=None)

Rescale the image to fit in [0..255] range.

Image min will be mapped to 0 and max to 255. Values in this range are interpolated :param image: a RGB float image :return: a RGB unsigned char image

trw.train.sample_export.export_image(image, path)

Export an image

Parameters
  • image – a RGB image (float or ui8) with format (channels, height, width)

  • path – where to write the image

Returns

trw.train.sample_export.export_as_image(name, samples, sample_id, export_root, txt_file)

Export a value as an image :param name: :param samples: :param export_root: :param txt_file: :return:

trw.train.sample_export.export_as_npy(name, samples, sample_id, export_root, txt_file)
trw.train.sample_export.export_as_string(name, samples, sample_id, export_root, txt_file, max_len=1024)
trw.train.sample_export.export_functions()

Default export functions :return:

trw.train.sample_export.clean_mapping_name(name)
trw.train.sample_export.export_sample(batch, sample_id, export_root, txt_file, exports=export_functions, features_to_discard=None, clean_mapping_name_fn=clean_mapping_name, classification_mappings=None)

Export a sample from the batch :param batch: a batch :param sample_id: the index of the sample to export :param export_root: where to export the data (typically including the sample id) :param txt_file: where to export text data. Must be an opened file for write :param exports: a functor returning the functions to be used for the export :param features_to_discard: a list of feature names to discard :param clean_mapping_name_fn: function to translate the name of batch feature name to class output name :param classification_mappings: a dictionary of mapping output to translate class ID to class name