def _main(): """Main script.""" args = default_config_parse( default_config_path='settings/dataloader/KITTI.yaml') config = Config.build_from_yaml(args.config) configure_logging_verbosity(verbose=args.verbose) save_labels_as_dataframe(**config.config)
def _main(): """Main script.""" args = default_config_parse( default_config_path='settings/scripts/compute_embedded_space.yaml') configure_logging_verbosity(verbose=args.verbose) config = Config.build_from_yaml(args.config) save_embedded_features(**config.config)
def compute_feature_maps(output_path, input_path, inference_list_path, resnet_config_path, verbose=False): """Compute feature maps and save to disk. The feature maps will be stored to output_path. Args: output_path (str or pathlib.Path): Path to save feature maps to. input_path (str or pathlib.Path): Path to image folder. inference_list_path (str or pathlib.Path): Path to inference list (example creation and details at scripts/computer_inference_list.py). resnet_config_path (str or pathlib.Path): Path to ResNet config file. verbose (bool): Set verbosity. """ LOGGER.info("Compute feature maps ... ") configure_logging_verbosity(verbose=verbose) label_names = _get_label_names(inference_list_path) image_paths = [input_path/(label_name + '.png') for label_name in label_names] model = resnet.ResNet.build_from_yaml(resnet_config_path) save_features(file_list=image_paths, output_path=output_path, model=model)
def _main(): """Main script.""" args = default_config_parse( default_config_path='settings/scripts/compute_inference_list.yaml') configure_logging_verbosity(verbose=args.verbose) config = Config.build_from_yaml(args.config) compute_inference_list(**config.config, verbose=args.verbose)
def _main(): """Main script.""" args = default_config_parse( default_config_path= 'settings/scripts/plot_class_distribution_in_dataset.yaml') configure_logging_verbosity(verbose=args.verbose) config = Config.build_from_yaml(args.config) plot_class_distribution(**config.config)
def compute_inference_list(label_path, output_path, seed=42, verbose=False): """Compute inference list and save to disk. This method will save a .txt file with each column holding an unique identifier for a label. For each class n amount of samples are written to the file. n is equal to the minimum amount of samples for a class. For KITTI, Pedestrian_sitting is the class with the fewest occurrences (222), so for every class 222 samples would be chosen. Args: label_path (str or pathlib.Path): Path to labels as pickled pandas Data Frame file. output_path (str or pathlib.Path): Path to save the inference list to. seed (int): Random seed to enable reproducibility. verbose (True): Set verbosity. """ LOGGER.info("Compute inference list ... ") configure_logging_verbosity(verbose=verbose) random_state = np.random.RandomState(seed) labels = pd.read_pickle(str(label_path)) n_samples_dict = dict() # Count samples per class for class_types in CLASS_LIST: n_samples_dict[class_types] = np.sum(labels[TYPE] == class_types) # From each class get the same amount of samples like the class with the fewest n of samples min_n = n_samples_dict[min(n_samples_dict, key=n_samples_dict.get)] inference_list = [] for class_types in CLASS_LIST: labels_one_class = labels[labels[TYPE] == class_types] identifier = random_state.choice(labels_one_class.index.values, size=min_n, replace=False) inference_list.append(identifier) inference_list = [item for sublist in inference_list for item in sublist] np.savetxt(str(output_path), inference_list, fmt='%s')
def _main(): """Main script.""" args = default_config_parse(default_config_path='settings/run.yaml') configure_logging_verbosity(verbose=args.verbose) config = Config.build_from_yaml(args.config) _run_toolchain(config=config.config)