Exemple #1
0
def setup_test_init():
    """Function that should be called in the root __init__ of all tests

    The call ensures that the Devices and the logging are initialized correctly
    """

    DeviceConfig(DeviceConfigParams())

    logging.logger(__name__).debug("Set up device config for testing")
Exemple #2
0
import argparse
import os
import shutil

import tfaip.util.logging as logging
from tfaip.data.pipeline.definitions import PipelineMode
from tqdm import tqdm

from calamari_ocr.ocr import CrossFold
from calamari_ocr.ocr.dataset.datareader.file import FileDataParams
from calamari_ocr.utils import split_all_ext, glob_all

logger = logging.logger(__name__)


def main():
    parser = argparse.ArgumentParser(
        description="Write split of folds to separate directories")
    parser.add_argument(
        "--files",
        nargs="+",
        help=
        "List all image files that shall be processed. Ground truth fils with the same "
        "base name but with '.gt.txt' as extension are required at the same location",
    )
    parser.add_argument(
        "--n_folds",
        type=int,
        required=True,
        help="The number of fold, that is the number of models to train",
    )
Exemple #3
0
from paiargparse import PAIArgumentParser
from tfaip.util.logging import logger

from calamari_ocr.ocr.training.cross_fold_trainer import CrossFoldTrainer, CrossFoldTrainerParams

logger = logger(__name__)


def run():
    return main(parse_args())


def parse_args(args=None):
    parser = PAIArgumentParser()
    parser.add_root_argument('root', CrossFoldTrainerParams,
                             CrossFoldTrainerParams())
    params: CrossFoldTrainerParams = parser.parse_args(args).root
    # TODO: add the training args (omit those params, that are set by the cross fold training)
    # setup_train_args(parser, omit=["files", "validation", "weights",
    #                              "early_stopping_best_model_output_dir", "early_stopping_best_model_prefix",
    #                              "output_dir"])
    return params


def main(params):
    trainer = CrossFoldTrainer(params)
    logger.info("Running cross fold train with params")
    logger.info(params.to_json(indent=2))
    trainer.run()