예제 #1
0
파일: classify.py 프로젝트: vansky/dnnseg
import argparse

from dnnseg.config import Config
from dnnseg.util import load_dnnseg, stderr

if __name__ == '__main__':
    argparser = argparse.ArgumentParser('''
    Trains a DNN-Seg model from a config file.
    ''')
    argparser.add_argument('config', help='Path to configuration file.')
    argparser.add_argument('-p', '--partition', default='train', help='Name of partition from which to extract classifications (one of ["train", "dev", "test"]')
    argparser.add_argument('-s', '--segtype', type=str, default='phn', help='Segment type to use for training (one of ["vad", "wrd", "phn"]')
    argparser.add_argument('-g', '--goldfeats', type=str, default=None, help='Path to gold features file to merge with classification table. If unspecified, no gold features columns will be added.')
    args = argparser.parse_args()

    p = Config(args.config)

    if not p['use_gpu_if_available']:
        os.environ['CUDA_VISIBLE_DEVICES'] = '-1'

    t0 = time.time()
    data_path = 'data'
    if p['os']:
        data_path += '_os'
    if p['root']:
        data_path += '_root'
    data_path += '.obj'

    stderr('Loading saved training data...\n')
    sys.stderr.flush()
예제 #2
0
파일: ensemble.py 프로젝트: vansky/dnnseg
        '--force_cpu',
        action='store_true',
        help=
        'Do not use GPU. If not specified, GPU usage defaults to the value of the **use_gpu_if_available** configuration parameter.'
    )
    argparser.add_argument('-o',
                           '--outdir',
                           default=None,
                           help='Directory in which to save outputs.')
    args = argparser.parse_args()

    outputs = {}
    val_data = None

    for config in args.config:
        p = Config(config)

        if args.force_cpu or not p['use_gpu_if_available']:
            os.environ['CUDA_VISIBLE_DEVICES'] = '-1'

        t0 = time.time()

        if p['data_type'].lower() == 'acoustic':
            data_name = 'data_%s_f%s_d%s.obj' % (p['filter_type'], p['n_coef'],
                                                 p['order'])
        else:
            data_name = 'data.obj'

        preprocessed = True

        if val_data is None:
예제 #3
0
        '-l',
        '--layers',
        default=None,
        nargs='+',
        help=
        'IDs of layers to plot (0, ..., L). If unspecified, plots all available layers.'
    )
    args = argparser.parse_args()

    if args.class_limit.lower() == 'inf':
        class_limit = np.inf
    else:
        class_limit = int(args.class_limit)

    for config_path in args.config:
        p = Config(config_path)
        stderr('Plotting model defined at path %s...\n' % p['outdir'])

        if p['label_map_file'] is not None and os.path.exists(
                p['label_map_file']):
            label_map = pd.read_csv(p['label_map_file'])
            label_map = dict(zip(label_map.source, label_map.target))
        else:
            label_map = None

        if p['feature_map_file'] is not None and os.path.exists(
                p['feature_map_file']):
            feature_table = pd.read_csv(p['feature_map_file'])
            new_cols = []
            for i in range(len(feature_table.columns)):
                new_cols.append(feature_table.columns[i].replace(' ',
예제 #4
0
파일: evaluate.py 프로젝트: vansky/dnnseg
        'Do not use GPU. If not specified, GPU usage defaults to the value of the **use_gpu_if_available** configuration parameter.'
    )
    args = argparser.parse_args()

    measures = []
    for m in args.eval_measures:
        if m.lower() == 'all':
            measures = [
                "all", "segmentation", "classification", "objective",
                "label_probe", "feature_probe"
            ]
            break
        measures.append(m.lower())

    for c in args.configs:
        p = Config(c)

        if args.force_cpu or not p['use_gpu_if_available']:
            os.environ['CUDA_VISIBLE_DEVICES'] = '-1'

        t0 = time.time()

        if 'segmentation' in measures or 'classification' in measures or 'objective' in measures or args.force_predict:
            if p['data_type'].lower() == 'acoustic':
                data_name = 'data_%s_f%s_d%s.obj' % (p['filter_type'],
                                                     p['n_coef'], p['order'])
            else:
                data_name = 'data.obj'

            if 'objective' in measures:
                train_data_dirs = p.train_data_dir.split()