예제 #1
0

def main(args):
    deepspeech = setup_deepspeech(CONFIG_PATH,
                                  ALPHABET_PATH,
                                  pretrained_weights=args.pretrained_weights)
    train_generator, dev_generator = create_generators(deepspeech, args)
    deepspeech.fit(train_generator,
                   dev_generator,
                   epochs=args.epochs,
                   shuffle=False)
    deepspeech.save(WEIGHTS_PATH)


if __name__ == "__main__":
    chdir(to='ROOT')
    parser = create_parser()

    ARGUMENTS = parser.parse_args()
    LOG_PATH = os.path.join(ARGUMENTS.model_dir, 'training.log')
    CONFIG_PATH = os.path.join(ARGUMENTS.model_dir, 'configuration.yaml')
    ALPHABET_PATH = os.path.join(ARGUMENTS.model_dir, 'alphabet.txt')
    WEIGHTS_PATH = os.path.join(ARGUMENTS.model_dir, 'weights.hdf5')

    logger = create_logger(LOG_PATH,
                           level=ARGUMENTS.log_level,
                           name='deepspeech')
    logger.info(f'Arguments: \n{ARGUMENTS}')

    main(ARGUMENTS)
def run_consumer(queue):
    """ Run program in the infinite loop (a daemon process). """
    while True:
        try:
            command = next_in(queue)

            if command:
                logger.info(f'Program execute the command: {command}')
                execute(command)
                logger.info(f'Correct run: {command}')
            else:
                time.sleep(10)

        except subprocess.CalledProcessError:
            logger.error(f'Program can not execute the command')


if __name__ == "__main__":
    chdir(to='ROOT')
    parser = argparse.ArgumentParser()
    parser.add_argument('--queue', required=True, help='The queue with tasks to execute')
    parser.add_argument('--python', required=True, help='The interpreter path')
    args = parser.parse_args()

    logger = create_logger(name='consumer')
    logger.info('The consumer has been started')
    logger.info(f'Execute the queue: {args.queue}')

    run_consumer(queue=args.queue)
예제 #3
0
    logger.info(f'Model contains: {units//1e6:.0f}M units ({units})')

    metrics = evaluate(deepspeech, generator, save_activations, store_path)
    logger.info(f'Mean CER: {metrics.cer.mean():.4f}')
    logger.info(f'Mean WER: {metrics.wer.mean():.4f}')


if __name__ == '__main__':
    ARGUMENTS = parse_arguments()
    chdir(to='ROOT')

    CONFIG_PATH = os.path.join(ARGUMENTS.model_dir, 'configuration.yaml')
    ALPHABET_PATH = os.path.join(ARGUMENTS.model_dir, 'alphabet.txt')
    WEIGHTS_PATH = os.path.join(ARGUMENTS.model_dir, 'weights.hdf5')

    logger = create_logger(ARGUMENTS.log_file,
                           level=ARGUMENTS.log_level,
                           name='evaluate')
    logger.info(f'Arguments: \n{ARGUMENTS}')

    main(store_path=ARGUMENTS.store,
         features_store_path=ARGUMENTS.features_store,
         batch_size=ARGUMENTS.batch_size,
         save_activations=ARGUMENTS.save_activations,
         mask=ARGUMENTS.mask,
         mask_F=ARGUMENTS.mask_F,
         mask_mf=ARGUMENTS.mask_mf,
         mask_T=ARGUMENTS.mask_T,
         mask_mt=ARGUMENTS.mask_mt,
         mask_ratio_t=ARGUMENTS.mask_ratio_t)
예제 #4
0
                logger.info(f'Program execute the command: {command}')
                execute(command)
                logger.info(f'Correct run: {command}')
            else:
                time.sleep(10)

        except subprocess.CalledProcessError:
            logger.error(f'Program can not execute the command')


if __name__ == "__main__":
    chdir(to='ROOT')
    parser = argparse.ArgumentParser()
    parser.add_argument('--queue',
                        required=True,
                        help='The queue with tasks to execute')
    parser.add_argument('--python', required=True, help='The interpreter path')
    parser.add_argument('--log_file', required=True, help='The log file')
    parser.add_argument('--log_level',
                        type=int,
                        default=20,
                        help='The log level (default set to INFO)')
    args = parser.parse_args()

    logger = create_logger(args.log_file, args.log_level, name='consumer')

    logger.info('The consumer has been started')
    logger.info(f'Execute the queue: {args.queue}')

    run_consumer(queue=args.queue)
예제 #5
0
    parser.add_argument('--store',
                        required=True,
                        help='File hdf5 keeps evaluation results')
    parser.add_argument('--model_dir',
                        required=True,
                        help='Pretrained model directory')
    parser.add_argument('--features_store',
                        required=True,
                        help='HDF5 Store with precomputed features')
    parser.add_argument(
        '--batch_size',
        type=int,
        required=True,
        help=
        'Batch size (depends on model) should be the same as during training')
    parser.add_argument('--log_file', help='Log file')
    parser.add_argument('--log_level', type=int, default=20, help='Log level')
    parser.add_argument('--save_activations',
                        type=bool,
                        default=True,
                        help='Save all activation through evaluation')
    args = parser.parse_args()
    chdir(to='ROOT')

    logger = create_logger(args.log_file,
                           level=args.log_level,
                           name='evaluate')
    logger.info(f'Arguments: \n{args}')
    main(args.store, args.model_dir, args.features_store, args.batch_size,
         args.save_activations)
예제 #6
0
        deepspeech.load(args.pretrained_weights)

    train_generator = deepspeech.create_generator(
        args.train,
        batch_size=args.batch_size,
        source=args.source,
        shuffle_after_epoch=args.shuffle_after_epoch)
    dev_generator = deepspeech.create_generator(args.dev,
                                                batch_size=args.batch_size,
                                                source=args.source)

    deepspeech.fit(train_generator,
                   dev_generator,
                   epochs=args.epochs,
                   shuffle=False)
    deepspeech.save(weights_path)


if __name__ == "__main__":
    chdir(to='ROOT')
    arguments = parse_arguments()
    log_path = os.path.join(arguments.model_dir, 'training.log')
    config_path = os.path.join(arguments.model_dir, 'configuration.yaml')
    alphabet_path = os.path.join(arguments.model_dir, 'alphabet.txt')
    weights_path = os.path.join(arguments.model_dir, 'weights.hdf5')
    logger = create_logger(log_path,
                           level=arguments.log_level,
                           name='deepspeech')
    logger.info(f'Arguments: \n{arguments}')
    main(arguments)