예제 #1
0
def test_export():

    config_file = "tests/fixtures/configs/for_export.py"
    expriment_id = "test_export"
    train_run(None, None, config_file, expriment_id, recreate=True)

    setup_test_environment()

    run(expriment_id, None, (None, None), [], None)
예제 #2
0
def test_profile():

    config_file = "tests/fixtures/configs/for_profile.py"
    expriment_id = "test_profile"
    train_run(None, None, config_file, expriment_id, recreate=True)

    setup_test_environment()

    run(expriment_id, None, None, 2, [])
예제 #3
0
def test_build_tfds_classification():
    environment.setup_test_environment()

    # Build TFDS Dataset
    config_file = "tests/fixtures/configs/for_build_tfds_classification.py"
    run(config_file, overwrite=True)

    # Check if the builded dataset can be loaded with the same config file
    expriment_id = "tfds_classification"
    train_run(None, None, 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(TFDSClassification,
                                  subset="train",
                                  batch_size=config.BATCH_SIZE,
                                  pre_processor=config.PRE_PROCESSOR,
                                  **config.DATASET.TFDS_KWARGS)

    validation_dataset = setup_dataset(TFDSClassification,
                                       subset="validation",
                                       batch_size=config.BATCH_SIZE,
                                       pre_processor=config.PRE_PROCESSOR,
                                       **config.DATASET.TFDS_KWARGS)

    assert train_dataset.num_per_epoch == train_data_num
    assert validation_dataset.num_per_epoch == validation_data_num

    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] == train_dataset.num_classes

    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] == validation_dataset.num_classes
예제 #4
0
def test_predict_object_detection():

    config_file = "tests/fixtures/configs/for_predict_object_detection.py"
    expriment_id = "test_predict_object_detection"
    train_run(None, None, config_file, expriment_id, recreate=True)

    setup_test_environment()

    run("tests/fixtures/sample_images",
        "outputs",
        expriment_id,
        None,
        None,
        save_images=True)