예제 #1
0
파일: utils.py 프로젝트: mjurkus/deep_lt
def load_model(
    device,
    model_path: str,
):
    with open('labels.json') as label_file:
        labels = json.load(label_file)

    hparams = {
        "model": {
            "hidden_size": 1024,
            "hidden_layers": 5,
        },
        "audio_conf": {
            "sample_rate": 16000,
            "window_size": .02,
            "window_stride": .01,
            "window": "hamming",
        },
        "num_classes": len(labels)
    }

    model = DeepSpeech.load_from_checkpoint(
        checkpoint_path=to_absolute_path(model_path),
        hparams=hparams,
        decoder=None,
    )
    model.to(device)
    model.eval()
    return model
예제 #2
0
def load_model(device, model_path):
    model = DeepSpeech.load_from_checkpoint(
        hydra.utils.to_absolute_path(model_path))
    model.eval()
    model = model.to(device)
    return model