예제 #1
0
    print('Compute node: {}'.format(compute_node))
else: 
    os.environ["CUDA_VISIBLE_DEVICES"]= "-1"

# Turn on soft memory allocation
tf_config = tf.compat.v1.ConfigProto()
tf_config.gpu_options.allow_growth = True
tf_config.log_device_placement = False
sess = tf.compat.v1.Session(config=tf_config)
#K.v1.set_session(sess)


# In[4]:


data_loader = data_selector(cgf['DATASET']['name'], cgf['DATASET']['arguments'])
data, labels, diff = data_loader.load_data() 


# In[5]:


data = data[:3000,:,:]
labels = labels[:3000]

'''
data = np.load(cgf["DATASET"]["arguments"]["images"])
labels = np.load(cgf["DATASET"]["arguments"]["labels"])
'''

예제 #2
0
import yaml
import sys
from data_bank import data_selector

if __name__ == '__main__':

    configfile = 'config_files/create_images_shades.yml'
    with open(configfile) as ymlfile:
        cgf = yaml.load(ymlfile, Loader=yaml.SafeLoader)

    data_loader = data_selector(cgf['DATA']['name'], cgf['DATA']['arguments'])

    images, labels, diff = data_loader.load_data()

    print('Data done.')
예제 #3
0
    configfile = 'config_files/config_visualise.yml'
    with open(configfile) as ymlfile:
        cgf = yaml.load(ymlfile, Loader=yaml.SafeLoader)

    configfile1 = 'config_files/config.yml'
    with open(configfile1) as ymlfile:
        cgf1 = yaml.load(ymlfile, Loader=yaml.SafeLoader)

    model_id = cgf['data_arguments']['model']
    model_dest = cgf['data_arguments']['model_dest']
    model_path = join(model_dest, str(model_id))

    data_name = cgf['data_name']
    data_arguments = cgf['data_arguments']

    data_loader = data_selector(data_name, data_arguments)
    print(data_loader)
    data_images, data_labels, data_diff = data_loader.load_data()

    model_name = cgf1['MODEL']['name']
    model_arguments = cgf1['MODEL']['arguments']

    input_shape = data_images.shape[1:]
    output_shape = data_labels.shape[1]

    # Set the default precision
    model_precision = cgf1['MODEL_METADATA']['precision']
    K.set_floatx(model_precision)

    model = mb.model_selector(model_name, input_shape, output_shape,
                              model_arguments)
예제 #4
0
import numpy as np
import yaml
from data_bank import data_selector
import os 
from os.path import join
import sys
from shade2_algo import shades2_alg

if __name__ == "__main__":

    configfile = 'config_files/config_exist.yml'
    with open(configfile) as ymlfile:
        cgf = yaml.load(ymlfile, Loader=yaml.SafeLoader)

    data_loader_test = data_selector(cgf['DATASET_TEST']['name'], cgf['DATASET_TEST']['arguments'])
    test_data, test_labels, _ = data_loader_test.load_data()

    score = 0

    for i in range(len(test_labels)):
        
        if shades2_alg(test_data[i])==test_labels[i]:
            score += 1

    print('Accuracy on test set: {}%'.format(100*score/len(test_labels)))
        

예제 #5
0
    os.environ['CUDA_VISIBLE_DEVICES']= "-1"

    with open('config_files/config_evaluate.yml') as ymlfile:
        cgf_eval = yaml.load(ymlfile, Loader= yaml.SafeLoader)

    model_id = cgf_eval['MODEL']['model_id']
    model_dest = cgf_eval['MODEL']['model_dest']
    model_path = join(model_dest, str(model_id))

    with open(join(model_path, 'config.yml')) as ymlfile:
        cgf = yaml.load(ymlfile, Loader= yaml.SafeLoader)

    # Select dataset
    use_default_test = cgf_eval['DATASET']['use_default']
    if use_default_test:
        data_loader = data_selector(cgf['DATASET_TEST']['name'], cgf['DATASET_TEST']['arguments'])
    else:
        data_loader = data_selector(cgf_eval['DATASET']['name'], cgf_eval['DATASET']['arguments'])


    print('\nDATASET TEST')
    print(data_loader)
    test_data, test_labels, test_diff = data_loader.load_data()

    print(test_data.shape)

    model_name = cgf['MODEL']['name']
    model_arguments = cgf['MODEL']['arguments']

    input_shape = test_data.shape[1:]
    output_shape = test_labels.shape[1];
예제 #6
0
    if use_gpu:
        compute_node = cgf['COMPUTER_SETUP']['compute_node']
        os.environ["CUDA_VISIBLE_DEVICES"] = "%d" % (compute_node)
        print('Compute node: {}'.format(compute_node))
    else:
        os.environ["CUDA_VISIBLE_DEVICES"] = "-1"

    # Turn on soft memory allocation
    tf_config = tf.compat.v1.ConfigProto()
    tf_config.gpu_options.allow_growth = True
    tf_config.log_device_placement = False
    sess = tf.compat.v1.Session(config=tf_config)
    #K.v1.set_session(sess)

    # Load train and validatation data
    data_loader_train = data_selector(cgf['DATASET_TRAIN']['name'],
                                      cgf['DATASET_TRAIN']['arguments'])
    data_loader_validate = data_selector(cgf['DATASET_VAL']['name'],
                                         cgf['DATASET_VAL']['arguments'])
    print('\nDATASET TRAIN')
    print(data_loader_train)
    print('DATASET VALIDATION')
    print(data_loader_validate)

    train_data, train_labels, _ = data_loader_train.load_data()
    val_data, val_labels, _ = data_loader_validate.load_data()

    # Trying for resnet since memory seems to be the issue
    train_data = train_data[:3000, :, :]
    train_labels = train_labels[:3000]

    if (cgf['MODEL']['name'] == "resnet"):