def dataset_creator(config): opt = config["opt"] hyper_params = config["hyper_params"] train_data, _ = data_utils.get_dataset("voc/2007", "train+validation") val_data, _ = data_utils.get_dataset("voc/2007", "test") if opt.with_voc12: voc_2012_data, _ = data_utils.get_dataset("voc/2012", "train+validation") train_data = train_data.concatenate(voc_2012_data) img_size = hyper_params["img_size"] train_data = train_data.map(lambda x: data_utils.preprocessing( x, img_size, img_size, augmentation.apply)) val_data = val_data.map( lambda x: data_utils.preprocessing(x, img_size, img_size)) data_shapes = data_utils.get_data_shapes() padding_values = data_utils.get_padding_values() train_data = train_data.shuffle(opt.batch_size * 4).padded_batch( opt.batch_size, padded_shapes=data_shapes, padding_values=padding_values) val_data = val_data.padded_batch(opt.batch_size, padded_shapes=data_shapes, padding_values=padding_values) prior_boxes = bbox_utils.generate_prior_boxes( hyper_params["feature_map_shapes"], hyper_params["aspect_ratios"]) ssd_train_feed = train_utils.generator(train_data, prior_boxes, hyper_params) ssd_val_feed = train_utils.generator(val_data, prior_boxes, hyper_params) return ssd_train_feed, ssd_val_feed
if backbone == "mobilenet_v2": from models.rpn_mobilenet_v2 import get_model else: from models.rpn_vgg16 import get_model hyper_params = train_utils.get_hyper_params(backbone) test_data, dataset_info = data_utils.get_dataset("voc/2007", "test") labels = data_utils.get_labels(dataset_info) labels = ["bg"] + labels hyper_params["total_labels"] = len(labels) img_size = hyper_params["img_size"] data_types = data_utils.get_data_types() data_shapes = data_utils.get_data_shapes() padding_values = data_utils.get_padding_values() if use_custom_images: img_paths = data_utils.get_custom_imgs(custom_image_path) total_items = len(img_paths) test_data = tf.data.Dataset.from_generator( lambda: data_utils.custom_data_generator(img_paths, img_size, img_size ), data_types, data_shapes) else: test_data = test_data.map( lambda x: data_utils.preprocessing(x, img_size, img_size)) test_data = test_data.padded_batch(batch_size, padded_shapes=data_shapes, padding_values=padding_values)