scripts namespace

Submodules

scripts.create_seg_labels_and_index_files module

generate segmentation label files (png) and the required index files for training and testing

usage: create_seg_labels_and_index_files.py –root <path to dataset> –train_files <comma seperated list of json files containing train data> –test_files <list containing test data>

scripts.create_seg_labels_and_index_files.calc_k(line)[source]

Calculate the direction of lanes

scripts.create_seg_labels_and_index_files.draw(im, line, idx, show=False)[source]

Generate the segmentation label according to json annotation

scripts.create_seg_labels_and_index_files.generate_segmentation_and_train_list(root, line_txt, names)[source]

The lane annotations of the Tusimple dataset is not strictly in order, so we need to find out the correct lane order for segmentation. We use the same definition as CULane, in which the four lanes from left to right are represented as 1,2,3,4 in segentation label respectively.

scripts.create_seg_labels_and_index_files.get_args()[source]
scripts.create_seg_labels_and_index_files.get_tusimple_list(root, label_list)[source]

Get all the files’ names from the json annotation

scripts.create_smaller_train_set module

scripts.create_smaller_train_set.create_smaller_train_set(file_in, keep: int = 10, out_filename='small_train_labels.json')[source]

Training with large datasets will take a huge amount of time. Especially if the dataset was recorded at a high framerate this script could be used to increase training speed by creating a smaller train_labels file.

Parameters
  • file_in – absolute path to a train_labels.json file

  • keep – Percentage of frames to keep (20% -> 20)

  • out_filename – Filename of the new labels file. It will be created in the same directory where file_in is located

Returns:

scripts.reduce_h_samples module

scripts.reduce_h_samples.reduce_h_samples(file_in: str, file_out: str, keep_h_samples: List[int])[source]

Reduces the amount of h_samples.

Parameters
  • file_in – Source labels file

  • file_out – target labels file

  • keep_h_samples – array of h_samples to keep (eg [10, 20, 30])

Returns:

scripts.show_labels_on_image module

scripts.show_labels_on_image.get_lane_color(i)[source]
scripts.show_labels_on_image.input_images(input_file, data_root)[source]

This method provides an easy way to visually validate train data by drawing labels on the frames and displaying them

Parameters
  • input_file – labels file (filepath relative to data_root)

  • data_root – path to dataset

scripts.split_dataset module

scripts.split_dataset.split_dataset(file_in, test_split: int = 10, validate_split: int = 10)[source]

split one labels file into train, test, validate labels files. Creates the following files: train_labels.json, test.json, validate.json in the same folder as the source file is located

Parameters
  • file_in – path to labels file

  • test_split – test percentage

  • validate_split – validate percentage