def main():
    # capture the config path from the run arguments
    # then process the json configuration file
    try:
        args = get_args()
        config = process_config(args.config)

    except:
        print("missing or invalid arguments")
        exit(0)

    # create the experiments dirs
    create_dirs([config.summary_dir, config.checkpoint_dir])
    # create tensorflow session
    sess = tf.Session()
    # create an instance of the model you want
    model = MyModel(config)
    # create your data generator
    data = DataGenerator(config)
    # create tensorboard logger
    logger = Logger(sess, config)
    # create trainer and pass all the previous components to it
    trainer = SimpleTrainer(sess, model, data, config, logger)

    # here you train your model
    trainer.train()
    trainer.validate()
示例#2
0
def main():
    # capture the config path from the run arguments
    # then process the json configuration file
    try:
        args = get_args()
        config = process_config(args.config)

    except:
        print("missing or invalid arguments")
        exit(0)

    # create the experiments dirs
    create_dirs([config.summary_dir, config.checkpoint_dir])
    # create tensorflow session
    sess = tf.Session()
    # create an instance of the model you want
    model = ExampleModel(config)
    # create your data generator
    data = DataGenerator(config)
    # create tensorboard logger
    logger = Logger(sess, config)
    # create trainer and pass all the previous components to it
    trainer = SimpleTrainer(sess, model, data, config, logger)

    # here you train your model
    trainer.train()
def main():
    # capture the config path from the run arguments
    # then process the json configuration file
    try:
        args = get_args()
        config = process_config(args.config)

    except:
        print("missing or invalid arguments")
        exit(0)

    # create the experiments dirs
    create_dirs([config.summary_dir, config.checkpoint_dir])
    # create tensorflow session
    sess = tf.Session()
    # create an instance of the model you want
    model = MyModel(config)
    # create your data generator
    data = DataGenerator(config)
    # create tensorboard logger
    logger = Logger(sess, config)
    # create trainer and pass all the previous components to it
    trainer = SimpleTrainer(sess, model, data, config, logger)
    saverExternal = tf.train.Saver(var_list=tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES, scope='external'))
    saverExternal.restore(sess, "experiments/model_8/model8.ckpt_2")

    # here you train your model
    trainer.train()
    trainer.validate()
示例#4
0
def main():

    cfg = config()
    print('Loading Data...')
    data_loader = CaptchaDataLoader(cfg)

    print('Loading Model...')
    model = SimpleCaptchaModel(cfg)

    print('Loading Trainer...')
    trainer = SimpleTrainer(model.model, data_loader.get_train_data(), cfg)

    trainer.train()
示例#5
0
def main():
    modalities = [
        DatasetFeaturesSet.VIDEO_SCENE_R2PLUS1_FEATURES,
        DatasetFeaturesSet.VIDEO_FACE,
        DatasetFeaturesSet.AUDIO,
        DatasetFeaturesSet.PULSE,
        DatasetFeaturesSet.VIDEO_SCENE,
    ]

    fusion_types = ['sum', 'concatenation', 'fbp']
    for i in range((len(modalities))):
        for fusion in fusion_types:
            processor = MultimodalDatasetFeaturesProcessor(modalities_list=modalities[i:])

            data_manager = DataManager(
                tf_record_path=config.DATASET_TF_RECORDS_PATH,
                batch_size=1)

            model = MultimodalModel(
                fusion_type=fusion,
                modalities_list=modalities[i:],
                fc_units=64,
                first_layer=128,
                second_layer=64,
                learning_rate=0.0001,
                cp_dir=config.CHECKPOINT_DIR + "/" + fusion + "_" + modalities[i].name,
                cp_name=config.CHECKPOINT_NAME
            )

            _, epoch = model.load()

            trainer = SimpleTrainer(
                dataset_processor=processor,
                model=model,
                data=data_manager,
                board_path=config.TENSORBOARD_DIR + "/" + fusion + "_" + modalities[i].name,
                log_freq=config.LOG_AND_SAVE_FREQ_BATCH,
                num_epochs=2,
                initial_epoch=epoch,
                create_dirs_flag=True
            )

            metrics = trainer.train()
            print(metrics)
def main():
    # capture the config path from the run arguments
    # then process the json configuration file
    try:
        args = get_args()
        config = process_config(args.config)

    except:
        print("missing or invalid arguments")
        exit(0)

    # create the experiments dirs
    create_dirs([config.summary_dir, config.checkpoint_dir])
    # create tensorflow session
    sess = tf.Session()
    # create an instance of the model you want
    model = MyModel(config)
    # create your data generator
    data = DataGenerator(config)
    # create tensorboard logger
    logger = Logger(sess, config)
    # create trainer and pass all the previous components to it
    trainer = SimpleTrainer(sess, model, data, config, logger)
    saverExternal = tf.train.Saver(var_list=tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES, scope='external'))
    saverExternal.restore(sess, "experiments/model_8/model8.ckpt_2")

    # here you train your model
    trainer.train()
    trainer.validate()
示例#7
0
def main():
    modalities = [
        DatasetFeaturesSet.AUDIO, DatasetFeaturesSet.VIDEO_FACE,
        DatasetFeaturesSet.VIDEO_SCENE, DatasetFeaturesSet.PULSE,
        DatasetFeaturesSet.VIDEO_SCENE_R2PLUS1_FEATURES
    ]

    for modality in modalities:
        processor = MultimodalDatasetFeaturesProcessor(
            modalities_list=[modality])

        data_manager = DataManager(
            tf_record_path=config.DATASET_TF_RECORDS_PATH, batch_size=1)

        model = UnimodalModel(
            modality=modality,
            fc_units=64,
            first_layer=128,
            second_layer=64,
            learning_rate=0.001,
            pretrained_model_path=modality.config.extractor.config.
            pretrained_path if modality.config.extractor is not None else None,
            cp_dir=config.CHECKPOINT_DIR,
            cp_name=config.CHECKPOINT_NAME)

        _, epoch = model.load()

        trainer = SimpleTrainer(dataset_processor=processor,
                                model=model,
                                data=data_manager,
                                board_path=config.TENSORBOARD_DIR,
                                log_freq=config.LOG_AND_SAVE_FREQ_BATCH,
                                num_epochs=2,
                                initial_epoch=epoch,
                                create_dirs_flag=True)

        metrics = trainer.train()
        print(metrics)
示例#8
0
import argparse
import yaml

from trainers.base_trainer import BaseTrainer
from trainers.rgb_only_trainer import RGBOnlyTrainer
from trainers.simple_trainer import SimpleTrainer
from trainers.local_global_trainer import LocalGlobalTrainer

parser = argparse.ArgumentParser()
parser.add_argument("--config", type=str, help='path to config file')

try:
    args = parser.parse_args()
except IOError as msg:
    parser.error(str(msg))

with open("configs/" + args.config, 'r') as f:
    params = yaml.load(f, Loader=yaml.FullLoader)

if params["type"] == "simple":
    trainer = SimpleTrainer(params)
elif params["type"] == "local_global":
    trainer = LocalGlobalTrainer(params)
elif params["type"] == "rgb":
    trainer = RGBOnlyTrainer(params)
trainer.train()