Ejemplo n.º 1
0
def evaluate_deepspeech():
    setup_logging(LOGGER)
    path_to_model_checkpoint = '/Users/florianlay/roboy/sonosco/pretrained/deepspeech_final.pth'
    config_path = "bootstrap_deepspeech.yaml"

    config = parse_yaml(config_path)

    experiment = Experiment.create(config, LOGGER)

    model = DeepSpeech2.load_model(path_to_model_checkpoint)
    model.eval()

    processor = AudioDataProcessor(**config)
    test_dataset = AudioDataset(processor, manifest_filepath=config["test_manifest"])
    sampler = RandomSampler(data_source=test_dataset, replacement=True,
                                       num_samples=2)
    test_loader = AudioDataLoader(dataset=test_dataset, num_workers=config["num_data_workers"], sampler=sampler)

    device = torch.device("cuda" if CUDA_ENABLED else "cpu")

    metrics = [word_error_rate, character_error_rate]
    evaluator = ModelEvaluator(model,
                               test_loader,
                               config['bootstrap_size'],
                               config['num_bootstraps'],
                               decoder=GreedyDecoder(config['labels']),
                               device=device,
                               metrics=metrics)

    evaluator.start_evaluation(log_path=experiment.logs)
Ejemplo n.º 2
0
    model.to(device)

    # Create data loaders
    train_loader, val_loader, test_loader = create_data_loaders(**config)

    # Create model trainer
    trainer = ModelTrainer(model, loss=cross_entropy_loss, epochs=config["max_epochs"],
                           train_data_loader=train_loader, val_data_loader=val_loader,
                           test_data_loader=test_loader,
                           lr=config["learning_rate"], custom_model_eval=True,
                           metrics=[word_error_rate, character_error_rate],
                           decoder=GreedyDecoder(config["decoder"]['labels']),
                           device=device, test_step=config["test_step"])

    trainer.add_callback(TbTextComparisonCallback(log_dir=experiment.plots_path))
    trainer.add_callback(TbTeacherForcingTextComparisonCallback(log_dir=experiment.plots_path))
    trainer.add_callback(DisableSoftWindowAttention())
    # Setup experiment with a model trainer
    experiment.setup_model_trainer(trainer, checkpoints=True, tensorboard=True)

    try:
        experiment.start()
    except KeyboardInterrupt:
        experiment.stop()


if __name__ == '__main__':
    setup_logging(LOGGER)
    main()
Ejemplo n.º 3
0
def main(**kwargs):
    global LOGGER
    LOGGER = logging.getLogger(SONOSCO)
    setup_logging(LOGGER)
    try_download_common_voice(**kwargs)
Ejemplo n.º 4
0
def main(*args, **kwargs):
    setup_logging(LOGGER)
    create_manifest(*args, **kwargs)