Exemple #1
0
def evaluate_protocol(evaluate_config_path,model_config_path,image_config_path,write=False):
    
    model_config_gen = get_config(model_config_path)
    image_config_gen = get_config(image_config_path)
    
    overall_config_gen = SON([('models',model_config_gen['models']),
                              ('images',image_config_gen['images'])])
    feature_hash = get_config_string(overall_config_gen)
    feature_certificate = '../.feature_certificates/' + feature_hash   
 
    evaluate_config = get_config(evaluate_config_path)
    task_config = evaluate_config.pop('train_test')
    
    D = []
    ext_hashes = []
    for task in task_config:
        overall_config_gen = SON([('models',model_config_gen),
                                  ('image',image_config_gen),('task',task)])
        ext_hash = get_config_string(overall_config_gen)
        outfile = '../.performance_certificates/' + ext_hash
        op = ('svm_evaluation_' + ext_hash,evaluate,(outfile,feature_certificate,
                                            evaluate_config_path,task,ext_hash))
        D.append(op)
        ext_hashes.append(ext_hash)
    if write:
        actualize(D)
    return D,ext_hashes
Exemple #2
0
def extract_and_evaluate_protocol(evaluate_config_path,model_config_path,image_config_path,convolve_func_name='numpy', write=False,parallel=False):
    
    model_config_gen = get_config(model_config_path)
    model_hash = get_config_string(model_config_gen['models'])
    model_certificate = '../.model_certificates/' + model_hash
    
    image_config_gen = get_config(image_config_path)
    image_hash =  get_config_string(image_config_gen['images'])
    image_certificate = '../.image_certificates/' + image_hash

    evaluate_config = get_config(evaluate_config_path)
    task_config = evaluate_config.pop('train_test')

    D = []
    DH = {}
    for task in task_config:
        overall_config_gen = SON([('models',model_config_gen),('images',image_config_gen),('task',task)])
        ext_hash = get_config_string(overall_config_gen)    
        
        if not parallel:
            performance_certificate = '../.performance_certificates/' + ext_hash
            op = ('evaluation_' + ext_hash,extract_and_evaluate,(performance_certificate,image_certificate,model_certificate,evaluate_config_path,convolve_func_name,task,ext_hash))
            D.append(op)
            DH[ext_hash] = [op]
        else:
            performance_certificate = '../.performance_certificates/' + ext_hash
            batch_certificate = '../.batch_certificates/' + ext_hash
            op = ('evaluation' + ext_hash,extract_and_evaluate_parallel,(batch_certificate,image_certificate,model_certificate,evaluate_config_path,convolve_func_name,task,ext_hash))
            D.append(op)
            DH[ext_hash] = [op]
             
    if write:
        actualize(D)
    return DH
def v1_greedy_optimization_protocol(config_path,use_cpu = False,write=False):

    D = DBAdd(image_initialize,args = (config_path,))
    
    oplist = do_initialization(image_initialize,args = (config_path,))    
    image_certificate = oplist[0]['outcertpaths'][0]
    
    if use_cpu or not GPU_SUPPORT:    
        convolve_func = v1f.v1like_filter_numpy
    else:
        convolve_func = v1f.v1like_filter_pyfft

    config = get_config(config_path)
    
    task = config['evaluation_task']
    initial_model = config['model']
    
    modifier_args = config['modifier_args']
    modifier_class = config.get('modifier')
    rep_limit = config.get('rep_limit')
    
    if modifier_class is None:
        modifier = config_modifiers.BaseModifier(modifier_args)
    else:
        modifier = modifier_class(modifier_args)
              
    newhash = get_config_string(config)
    outfile = '../.optimization_certificates/' + newhash
    op = ('optimization_' + newhash,greedy_optimization,(outfile,task,image_certificate,initial_model,convolve_func,rep_limit,modifier_args,modifier))
    D.append(op)

    if write:
        actualize(D)
    return D
Exemple #4
0
def v1_evaluation_protocol(task_config_path,feature_config_path,use_cpu=False):
    oplist = do_initialization(v1_initialize,args = (feature_config_path,use_cpu))
    feature_creates = tuple(oplist[-1]['outcertpaths'])
    hash = get_config_string(oplist[-1]['out_args'])
    
    feature_config = get_config(feature_config_path)
    task_config = get_config(task_config_path)
    
    D = []
    for task in task_config['train_test']:
        c = (feature_config,task)       
        newhash = get_config_string(c)
        outfile = '../.performance_certificates/' + newhash
        op = ('svm_evaluation_' + newhash,train_test_loop,(outfile,feature_creates,task,feature_config_path,hash))
        D.append(op)

    return D    
Exemple #5
0
def model_protocol(config_path,write = False,parallel=False):

    config = get_config(config_path)

    model_hash = get_config_string(config['models'])
    model_certificate = '../.model_certificates/' + model_hash

    D = [('generate_models',generate_models,(model_certificate,model_hash,config))]
    
    if write:
        actualize(D)
    return D,model_hash
Exemple #6
0
def extract_features_protocol(image_config_path,
                              model_config_path,
                              convolve_func_name = 'numpy',
                              write = False,
                              parallel=False,
                              batch_size=1000):

    model_config_gen = get_config(model_config_path)
    model_hash = get_config_string(model_config_gen['models'])
    model_certificate = '../.model_certificates/' + model_hash
    
    image_config_gen = get_config(image_config_path)
    image_hash = get_config_string(image_config_gen['images'])
    image_certificate = '../.image_certificates/' + image_hash
    
    overall_config_gen = SON([('models',model_config_gen['models']),('images',image_config_gen['images'])])
    feature_hash = get_config_string(overall_config_gen)
    feature_certificate = '../.feature_certificates/' + feature_hash
       
    if not parallel:
        D = [('extract_features',
              extract_features,(feature_certificate,
                                image_certificate,
                                model_certificate,
                                overall_config_gen,
                                feature_hash,
                                convolve_func_name))]
    else:
        D = [('extract_features',
              extract_features_parallel,(feature_certificate,
                                         image_certificate,
                                         model_certificate,
                                         overall_config_gen,
                                         feature_hash,
                                         convolve_func_name,
                                         batch_size))]
    
    if write:
        actualize(D)
    return D, feature_hash
Exemple #7
0
def image_protocol_hash(config_path):
    config = get_config(config_path)
    image_hash = get_config_string(config['images'])
    return image_hash