def test_shape_dataset_creation(shapes_image_size, shapes_nb_labels): """Create a Shapes dataset """ d = ShapeDataset(shapes_image_size) assert d.image_size == shapes_image_size assert d.get_nb_labels() == shapes_nb_labels assert d.get_nb_images() == 0
def test_shape_dataset_population(shapes_image_size, shapes_nb_images, shapes_nb_labels, shapes_config, shapes_temp_dir): """Populate a Shapes dataset """ d = ShapeDataset(shapes_image_size) d.populate(str(shapes_temp_dir), nb_images=shapes_nb_images) d.save(str(shapes_config)) assert d.get_nb_labels() == shapes_nb_labels assert d.get_nb_images() == shapes_nb_images assert os.path.isfile(str(shapes_config)) assert all( len(os.listdir(os.path.join(str(shapes_temp_dir), tmp_dir))) == shapes_nb_images for tmp_dir in ["images", "labels"])
def test_shape_dataset_loading(shapes_image_size, shapes_nb_images, shapes_nb_labels, shapes_sample_config): """Load images into a Shapes dataset """ d = ShapeDataset(shapes_image_size) d.load(shapes_sample_config) assert d.get_nb_labels() == shapes_nb_labels assert d.get_nb_images() == shapes_nb_images
aggregate_value = "full" if not args.aggregate_label else "aggregated" input_folder = utils.prepare_input_folder(args.datapath, args.dataset) prepro_folder = utils.prepare_preprocessed_folder(args.datapath, args.dataset, args.image_size, aggregate_value) # Dataset creation if args.dataset == "mapillary": config_name = "config.json" if not args.aggregate_label else "config_aggregate.json" config_path = os.path.join(input_folder, config_name) train_dataset = MapillaryDataset(args.image_size, config_path) validation_dataset = MapillaryDataset(args.image_size, config_path) test_dataset = MapillaryDataset(args.image_size, config_path) elif args.dataset == "shapes": train_dataset = ShapeDataset(args.image_size) validation_dataset = ShapeDataset(args.image_size) test_dataset = ShapeDataset(args.image_size) else: utils.logger.error( "Unsupported dataset type. Please choose 'mapillary' or 'shapes'") sys.exit(1) # Dataset populating/loading (depends on the existence of a specification file) if os.path.isfile(prepro_folder["training_config"]): train_dataset.load(prepro_folder["training_config"], args.nb_training_image) else: utils.logger.info( ("No existing configuration file for this dataset. Create {}" "").format(prepro_folder["training_config"]))