예제 #1
0
def test_train():
    trainset = os.path.join(PROJECT_PATH, _get_random_str())
    mod = os.path.join(PROJECT_PATH, "a.h5")
    config = {
        # fmt: off
        "video": {
            "path": VIDEO_PATH,
            "fps": 30,
        },
        "output": ".",
        "extras": {
            "save_train_set": trainset,
        }
    }
    run(config)

    # train
    keras_train(trainset, model_path=mod, epochs=1)
예제 #2
0
def test_run_calc():
    config = {
        # fmt: off
        "video": {
            "path": VIDEO_PATH,
        },
        "output": ".",
        "calc": {
            "output":
            f"{_get_random_str()}.json",
            "operators": [{
                "name": "calc_between_0_1",
                "calc_type": "between",
                "args": {
                    "from_stage": "0",
                    "to_stage": "1",
                },
            }, {
                "name": "display everything",
                "calc_type": "display",
            }]
        }
    }
    run(config)
예제 #3
0
def test_run_validation():
    # enum
    config = {
        # fmt: off
        "video": {
            "path": VIDEO_PATH,
        },
        "classifier": {
            "classifier_type": "unknwonwonn",
        },
        "output": ".",
    }
    try:
        run(config)
    except ValidationError:
        pass
    else:
        raise TypeError(
            "should raise an error if classifier_type is unexpected")

    config = {
        # fmt: off
        "video": {
            "path": VIDEO_PATH,
        },
        "output": ".",
        "calc": {
            "output": f"{_get_random_str()}.json",
            "operators": [
                {
                    "name": "error_test",
                    "calc_type": "unknwonww",
                },
            ]
        }
    }
    try:
        run(config)
    except ValidationError:
        pass
    else:
        raise TypeError("should raise an error if calc_type is unexpected")

    config = {
        # fmt: off
        "video": {
            "path": VIDEO_PATH,
        },
        "output": ".",
        "calc": {
            "output":
            f"{_get_random_str()}.json",
            "ignore_error":
            True,
            "operators": [
                {
                    "name": "error_test",
                    "calc_type": "between",
                    "args": {
                        "from_stage": "0",
                        # unexpected stage
                        "to_stage": "999",
                    }
                },
            ]
        }
    }
    run(config)