Ejemplo n.º 1
0
def init_logger(config, args):
    makedirs(config.summary_dir)
    makedirs(config.checkpoint_dir)

    # set logger
    path = os.path.dirname(os.path.abspath(__file__))
    path_model = os.path.join(path,
                              'models/base/%s.py' % config.network.lower())
    path_main = os.path.join(path, 'main_prune_non_imagenet.py')
    path_pruner = os.path.join(path, 'pruner/%s.py' % config.pruner_file)
    logger = get_logger('log',
                        logpath=config.summary_dir + '/',
                        filepath=path_model,
                        package_files=[path_main, path_pruner])
    logger.info(dict(config))
    summary_writer_path = config.summary_dir + '/' + args.init + '_sp' + str(
        args.target_ratio).replace('.', '_')
    if args.scaled_init:
        summary_writer_path += '_scaled'
    if args.bn:
        summary_writer_path += '_bn'

    if args.sigma_w2 != None and args.init == 'ordered':
        summary_writer_path += '_{}'.format(args.sigma_w2).replace('.', '_')
    summary_writer_path += '_' + args.act + '_' + str(config.depth)

    writer = SummaryWriter(summary_writer_path)
    # sys.stdout = open(os.path.join(config.summary_dir, 'stdout.txt'), 'w+')
    # sys.stderr = open(os.path.join(config.summary_dir, 'stderr.txt'), 'w+')
    return logger, writer
Ejemplo n.º 2
0
def init_logger(config):
    makedirs(config.summary_dir)
    makedirs(config.checkpoint_dir)

    # set logger
    path = os.path.dirname(os.path.abspath(__file__))
    path_model = os.path.join(path, 'models/base/%s.py' % 'vgg')
    path_main = os.path.join(path, 'main_prune_imagenet.py')
    path_pruner = os.path.join(path, 'pruner/%s.py' % config.pruner_file)
    logger = get_logger('log', logpath=config.summary_dir+'/',
                        filepath=path_model, package_files=[path_main, path_pruner])
    logger.info(dict(config))
    writer = SummaryWriter(config.summary_dir)
    return logger, writer
Ejemplo n.º 3
0
def init_logger(config):
    makedirs(config.summary_dir)
    makedirs(config.checkpoint_dir)

    # set logger
    path = os.path.dirname(os.path.abspath(__file__))
    path_model = os.path.join(path, 'models/base/%s.py' % config.network.lower())
    path_main = os.path.join(path, 'main_prune_non_imagenet.py')
    path_pruner = os.path.join(path, 'pruner/%s.py' % config.pruner_file)
    logger = get_logger('log', logpath=config.summary_dir + '/',
                        filepath=path_model, package_files=[path_main, path_pruner])
    logger.info(dict(config))
    writer = SummaryWriter(config.summary_dir)
    # sys.stdout = open(os.path.join(config.summary_dir, 'stdout.txt'), 'w+')
    # sys.stderr = open(os.path.join(config.summary_dir, 'stderr.txt'), 'w+')
    return logger, writer
Ejemplo n.º 4
0
def init_summary_writer(config):
    makedirs(config.summary_dir)
    makedirs(config.checkpoint_dir)
    print(config.checkpoint, os.path.exists(config.checkpoint))
    if not os.path.exists(config.checkpoint):
        os.makedirs(config.checkpoint)

    # set logger
    path = os.path.dirname(os.path.abspath(__file__))
    path_model = os.path.join(path, 'models/%s.py' % config.network)
    path_main = os.path.join(path, 'main_prune.py')
    path_pruner = os.path.join(path, 'pruner/%s.py' % config.pruner)

    logger = get_logger(f'log{running_time}.log_time',
                        logpath=config.saving_log,
                        filepath=path_model,
                        package_files=[path_main, path_pruner])
    logger.info(dict(config))
    writer = SummaryWriter(config.summary_dir)

    return logger, writer
            color_tuple = tuple([int(i) for i in color_tuple])
            encoding = (code_encoding[code_index], code_encoding[code_index],
                        code_encoding[code_index])
            encoding_counter = encoding_counter + 1
            label_class_code[color_tuple] = [class_name, encoding]

        log.info(label_class_code)

        return label_class_code


if __name__ == "__main__":

    # iterate through output folder

    log = get_logger(__name__)

    data_preparer_obj = DataPreparerSegmentation()

    # Create "Raw_Masks" and "Encoded_Masks" folders
    data_preparer_obj._create_folders()

    folders_list = data_preparer_obj.list_all_folders()

    codes = ['background', 'jsv', 'rsv']
    encodings = [0, 3, 4]
    label_class_code = data_preparer_obj.get_label_map(
        folders_list=folders_list, codes=codes, code_encoding=encodings)

    # Copy all Masks in Raw_Masks folder
    data_preparer_obj._copy_masks_in_raw_masks_folder(folders_list)