示例#1
0
文件: test.py 项目: schurterb/convnet
def testall(directory, pred_file=None, label_file=None, out_path=None):
    folders = os.listdir(directory)
    networks = []
    for folder in folders:
        if os.path.isfile(directory+folder+"/network.cfg") and os.path.exists(directory+folder+"/results"):
            networks.append(folder)
    
    config_file = directory+networks[0]+"/network.cfg"
    config = ConfigParser.ConfigParser()
    config.read(config_file)
    
    test_data = LoadData(directory = config.get('Testing Data', 'folders').split(','), 
                         data_file_name = config.get('Testing Data', 'data_file'),
                         label_file_name = config.get('Testing Data', 'label_file'),
                         seg_file_name = config.get('Testing Data', 'seg_file'))
    
    res = Analyzer(raw = test_data.get_data()[0], 
                   target = test_data.get_labels()[0])
                   
    for net in networks:
        config_file = directory+net+"/network.cfg"
        config = ConfigParser.ConfigParser()
        config.read(config_file)
        
        res.add_results(results_folder = config.get('General','directory'),
                        name = net,
                        prediction_file = config.get('Testing', 'prediction_file')+'_0', 
                        learning_curve_file = 'learning_curve')
                           
        res.analyze(-1, pred_file=pred_file, label_file=label_file, out_path=out_path)
        
    return res
示例#2
0
def ViewResults(**kwargs):
    directory = kwargs.get("directory", "")
    network = kwargs.get("network", None)
    prediction_file = kwargs.get("predictions_file", None)

    if network:
        # Assume that all networks are tested on the same set of data
        config = ConfigParser.ConfigParser()
        config.read("networks/" + network + "/network.cfg")
        data = LoadData(
            directory=config.get("Testing Data", "folders").split(",")[0],
            data_file_name=config.get("Testing Data", "data_file"),
            label_file_name=config.get("Testing Data", "label_file"),
        )

        if not prediction_file:
            prediction_file = "test_prediction_0"

        results = Analyzer(target=data.get_labels()[0], raw=data.get_data()[0])
        results.add_results(results_folder="networks/" + network + "/", name=network, prediction_file=prediction_file)

    else:
        folders = os.listdir(directory)
        networks = []
        for folder in folders:
            if os.path.isfile(directory + folder + "/network.cfg"):
                networks.append(folder)

        # Assume that all networks are tested on the same set of data
        config = ConfigParser.ConfigParser()
        config.read(directory + networks[0] + "/network.cfg")
        data = LoadData(
            directory=config.get("Testing Data", "folders").split(",")[0],
            data_file_name=config.get("Testing Data", "data_file"),
            label_file_name=config.get("Testing Data", "label_file"),
        )

        if not prediction_file:
            prediction_file = "test_prediction_0"

        results = Analyzer(target=data.get_labels()[0], raw=data.get_data()[0])
        for net in networks:
            results.add_results(results_folder=directory + net + "/", name=net, prediction_file=prediction_file)

    return results
示例#3
0
文件: test.py 项目: schurterb/convnet
def testprediction(config_file, pred_file=None, label_file=None, out_path=None):     
    config = ConfigParser.ConfigParser()
    config.read(config_file)
    
    test_data = LoadData(directory = config.get('Testing Data', 'folders').split(','), 
                         data_file_name = config.get('Testing Data', 'data_file'),
                         label_file_name = config.get('Testing Data', 'label_file'), 
                         seg_file_name = config.get('Testing Data', 'seg_file'))
    
    res = Analyzer(raw = test_data.get_data()[0],
                   target = test_data.get_labels()[0])
    res.add_results(results_folder = config.get('General','directory'),
                    name = config_file.split('/')[-3],
                    prediction_file = config.get('Testing', 'prediction_file')+'_0', 
                    learning_curve_file = 'learning_curve')           
    res.analyze(-1, pred_file=pred_file, label_file=label_file, out_path=out_path)
    
    return res