def test_build_tfds_object_detection(): environment.setup_test_environment() # Build TFDS Dataset config_file = "unit/fixtures/configs/for_build_tfds_object_detection.py" run(config_file, overwrite=True) # Check if the builded dataset can be loaded with the same config file expriment_id = "tfds_object_detection" train_run(config_file, expriment_id, recreate=True) # Check if the dataset was build correctly train_data_num = 3 validation_data_num = 2 config = config_util.load(config_file) train_dataset = setup_dataset(TFDSObjectDetection, subset="train", batch_size=config.BATCH_SIZE, **config.DATASET.TFDS_KWARGS) validation_dataset = setup_dataset(TFDSObjectDetection, subset="validation", batch_size=config.BATCH_SIZE, **config.DATASET.TFDS_KWARGS) assert train_dataset.num_per_epoch == train_data_num assert validation_dataset.num_per_epoch == validation_data_num assert train_dataset.num_max_boxes == validation_dataset.num_max_boxes num_max_boxes = train_dataset.num_max_boxes for _ in range(train_data_num): images, labels = train_dataset.feed() assert isinstance(images, np.ndarray) assert images.shape[0] == config.BATCH_SIZE assert images.shape[1] == config.IMAGE_SIZE[0] assert images.shape[2] == config.IMAGE_SIZE[1] assert images.shape[3] == 3 assert isinstance(labels, np.ndarray) assert labels.shape[0] == config.BATCH_SIZE assert labels.shape[1] == num_max_boxes assert labels.shape[2] == 5 for _ in range(validation_data_num): images, labels = validation_dataset.feed() assert isinstance(images, np.ndarray) assert images.shape[0] == config.BATCH_SIZE assert images.shape[1] == config.IMAGE_SIZE[0] assert images.shape[2] == config.IMAGE_SIZE[1] assert images.shape[3] == 3 assert isinstance(labels, np.ndarray) assert labels.shape[0] == config.BATCH_SIZE assert labels.shape[1] == num_max_boxes assert labels.shape[2] == 5
def test_predict_object_detection(): config_file = "unit/fixtures/configs/for_predict_object_detection.py" expriment_id = "test_predict_object_detection" train_run(config_file, expriment_id, recreate=True) setup_test_environment() run("unit/fixtures/sample_images", "outputs", expriment_id, None, None, save_images=True)
def test_export(): config_file = "unit/fixtures/configs/for_export.py" expriment_id = "test_export" train_run(config_file, expriment_id, recreate=True, profile_step=7) setup_test_environment() run(expriment_id, None, (None, None), [], None)
def test_profile(): config_file = "unit/fixtures/configs/for_profile.py" expriment_id = "test_profile" train_run(config_file, expriment_id, recreate=True) setup_test_environment() run(expriment_id, None, None, 2, [])