示例#1
0
    if seed is not None:
        train_config["seed"] = seed
        train_config["gqcnn"]["seed"] = seed
    if tensorboard_port is not None:
        train_config["tensorboard_port"] = tensorboard_port
    gqcnn_params = train_config["gqcnn"]

    # Create a unique output folder based on the date and time.
    if save_datetime:
        # Create output dir.
        unique_name = time.strftime("%Y%m%d-%H%M%S")
        output_dir = os.path.join(output_dir, unique_name)
        utils.mkdir_safe(output_dir)

    # Set visible devices.
    if "gpu_list" in train_config:
        gqcnn_utils.set_cuda_visible_devices(train_config["gpu_list"])

    # Fine-tune the network.
    start_time = time.time()
    gqcnn = get_gqcnn_model(backend)(gqcnn_params)
    trainer = get_gqcnn_trainer(backend)(gqcnn,
                                         dataset_dir,
                                         split_name,
                                         output_dir,
                                         train_config,
                                         name=name)
    trainer.finetune(model_dir)
    logger.info("Total Fine-tuning Time: " +
                str(utils.get_elapsed_time(time.time() - start_time)))
示例#2
0
from gqcnn import get_gqcnn_model, get_gqcnn_trainer, utils as gqcnn_utils

#%%
logger = Logger.get_logger('tools/train.py')

dataset_dir = '/home/ai/git/gqcnn/data/training/Dexnet-2.0_testTraining'
train_config = YamlConfig('cfg/train_dex-net_2.0.yaml')
gqcnn_params = train_config['gqcnn']

#%%
print(os.path.join(dataset_dir, 'config.json'))
config_filename = os.path.join(dataset_dir, 'config.json')
print(config_filename)
# print(os.getcwd())
#%%
open(config_filename, 'r')
config = json.load(open(config_filename, 'r'))
#%%
start_time = time.time()
gqcnn = get_gqcnn_model('tf')(gqcnn_params)
#%%
trainer = get_gqcnn_trainer('tf')(gqcnn,
                                  'data/training/Dexnet-2.0_testTraining',
                                  'image_wise', 'models/', train_config,
                                  'GQCNN-2.0_Training_from_Scratch')
#%%
trainer.train()

#%%
logger.info('Total Training Time: ' +
            str(utils.get_elapsed_time(time.time() - start_time)))