Esempio n. 1
0
def main():
    with open(config_filename) as handle:
        model_config = yaml.load(handle, Loader=yaml.FullLoader)
    data_name = []
    data_name.append(
        os.path.join(os.path.abspath('..'), model_config['category']))
    data_name.append(
        os.path.join(os.path.abspath('..'), model_config['category_valid']))
    data_name.append(
        os.path.join(os.path.abspath('..'), model_config['category_test']))
    if model_config['mask_name'] == 'Original':
        mask_name = None
    else:
        mask_name = os.path.join(os.path.abspath('..'),
                                 model_config['category_mask'],
                                 model_config['mask_name'])

    dataset_name = (data_name, mask_name)

    tf_config = tf.ConfigProto()
    # os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2" # ignore waring
    # os.environ["CUDA_VISIBLE_DEVICES"] = "0"
    os.environ["CUDA_VISIBLE_DEVICES"] = model_config['GPU']

    # tf.device("GPU:1")
    tf_config = tf.ConfigProto()
    tf_config.gpu_options.allow_growth = True

    with tf.Session(config=tf_config) as sess:
        Cube_Decoder = Decoder_Handler(dataset_name=dataset_name,
                                       model_config=model_config,
                                       sess=sess,
                                       is_training=True)
        Cube_Decoder.train()
Esempio n. 2
0
def main():
    ave_folder, ave_config = 'TSA-Model', 'config_188.yaml'

    folder_id, config_id = ave_folder, ave_config
    with open(config_filename) as handle:
        model_config = yaml.load(handle, Loader=yaml.FullLoader)
    data_dir = []
    data_dir.append(model_config['category_train'])
    data_dir.append(model_config['category_valid'])
    data_dir.append(model_config['category_test'])

    mask_dir = model_config['category_mask']
    log_dir = os.path.join(os.path.abspath('.'), model_config['result_dir'],
                           model_config['result_model'], folder_id)

    with open(os.path.join(log_dir, config_id)) as handle:
        model_config = yaml.load(handle, Loader=yaml.FullLoader)

    dataset_dir = (data_dir, mask_dir)

    tf_config = tf.ConfigProto()
    os.environ["CUDA_VISIBLE_DEVICES"] = "1"
    tf_config = tf.ConfigProto()
    tf_config.gpu_options.allow_growth = True

    with tf.Session(config=tf_config) as sess:
        Cube_Decoder = Decoder_Handler(dataset_dir=dataset_dir,
                                       model_config=model_config,
                                       sess=sess,
                                       is_training=False)
        Cube_Decoder.test()
Esempio n. 3
0
def main():

    folder_id, config_id = 'NBA-Decoder-TNN', 'config-nba.yaml'

    with open(config_filename) as handle:
        model_config = yaml.load(handle)
    log_dir = os.path.join(os.path.abspath('.'), model_config['result_dir'],
                           model_config['result_model'], folder_id)

    with open(os.path.join(log_dir, config_id)) as handle:
        model_config = yaml.load(handle)
    data_name = os.path.join(os.path.abspath('.'), 'Data',
                             model_config['category'],
                             model_config['data_name'])
    if model_config['mask_name'] == 'Original':
        mask_name = None
    else:
        mask_name = os.path.join(os.path.abspath('.'), 'Data',
                                 model_config['category'],
                                 model_config['mask_name'])

    dataset_name = (data_name, mask_name)

    tf_config = tf.ConfigProto()
    os.environ[
        "CUDA_VISIBLE_DEVICES"] = "2"  # Please change the id of GPU in your local server accordingly
    tf_config = tf.ConfigProto()
    tf_config.gpu_options.allow_growth = True

    with tf.Session(config=tf_config) as sess:
        Cube_Decoder = Decoder_Handler(dataset_name=dataset_name,
                                       model_config=model_config,
                                       sess=sess,
                                       is_training=False)
        Cube_Decoder.test()
Esempio n. 4
0
def main():
    with open(config_filename) as handle:
        model_config = yaml.load(handle, Loader=yaml.FullLoader)
    data_name = []
    data_name.append(
        os.path.join(os.path.abspath('.'), model_config['category'],
                     model_config['data_name']))
    data_name.append(
        os.path.join(os.path.abspath('.'), model_config['category_valid'],
                     model_config['data_name']))
    data_name.append(
        os.path.join(os.path.abspath('.'), model_config['category_test'],
                     model_config['data_name']))

    mask_name = os.path.join(os.path.abspath('.'), model_config['category'],
                             model_config['mask_name'])

    dataset_name = (data_name, mask_name)

    tf_config = tf.ConfigProto()
    os.environ["CUDA_VISIBLE_DEVICES"] = "0"
    # tf.device("GPU:1")
    tf_config = tf.ConfigProto()
    tf_config.gpu_options.allow_growth = True

    with tf.Session(config=tf_config) as sess:
        Cube_Decoder = Decoder_Handler(dataset_name=dataset_name,
                                       model_config=model_config,
                                       sess=sess,
                                       is_training=True)
        Cube_Decoder.train()
Esempio n. 5
0
def main():

    ### pre-trainded model
    # pre_model_name [modify]
    pre_model_name = 'binary_mask_256_8f_original_model/models-0.0744-256404'

    pre_model_dir = 'Result/Model-Config'
    model_filename = os.path.join(os.path.abspath('.'), pre_model_dir,
                                  pre_model_name)
    model_config = {
        'model_filename': model_filename,
        'result_data': 'Validation-Result',
        'result_dir': 'Result',
        'compressive_ratio': 8,  # [modify]
        'batch_size': 1
    }  # [modify]

    ### test set
    # test_data_dir [modify]
    test_data_dir = os.path.join(os.path.abspath('..'),
                                 'data_simu/testing_truth/')

    # mask_name [modify]
    # mask_name = 'mask/binary_mask_256_8f_original_model'
    # mask_name = 'mask/combine_binary_mask_256_10f'
    mask_name = 'mask/mask_256'

    ## test_data
    data_name = []
    data_name.append('')  # placeholder
    data_name.append('')
    data_name.append(test_data_dir)

    ## mask
    # used to initialize the network input
    mask_name = os.path.join(os.path.abspath('..'), 'data_simu', mask_name)

    ## test set
    dataset_name = (data_name, mask_name)

    ### inference
    ## tf config
    tf_config = tf.ConfigProto()
    os.environ["CUDA_VISIBLE_DEVICES"] = "0"
    tf_config = tf.ConfigProto()
    tf_config.gpu_options.allow_growth = True

    ## run
    with tf.Session(config=tf_config) as sess:
        # Cube_Decoder = Decoder_Handler_meas(dataset_name=dataset_name, model_config=model_config, sess = sess, is_training=False,Cr=Cr)
        Cube_Decoder = Decoder_Handler(dataset_name=dataset_name,
                                       model_config=model_config,
                                       sess=sess,
                                       is_training=False,
                                       is_testing_meas=False)
        Cube_Decoder.test()
Esempio n. 6
0
def main():
    Cr = 10
    test_data_name = 'waterBalloon'
    if Cr == 10:
        ave_folder, ave_config = 'Cr10_model', 'config_Cr10_model.yaml'
    elif Cr == 20:
        ave_folder, ave_config = 'Cr20_model', 'config_Cr20_model.yaml'
    else:
        ave_folder, ave_config = 'Cr30_model', 'config_Cr30_model.yaml'
    folder_id, config_id = ave_folder, ave_config
    with open(config_filename) as handle:
        model_config = yaml.load(handle, Loader=yaml.FullLoader)
    data_name = []
    data_name.append(
        os.path.join(os.path.abspath('.'), model_config['category'],
                     model_config['data_name']))
    data_name.append(
        os.path.join(os.path.abspath('.'), model_config['category_valid'],
                     model_config['data_name']))
    data_name.append(
        os.path.join(os.path.abspath('..'), 'dataset',
                     'meas_' + test_data_name))
    log_dir = os.path.join(os.path.abspath('.'), model_config['result_dir'],
                           model_config['result_model'], folder_id)

    with open(os.path.join(log_dir, config_id)) as handle:
        model_config = yaml.load(handle, Loader=yaml.FullLoader)

    mask_name = os.path.join(os.path.abspath('..'), 'dataset', 'mask')

    dataset_name = (data_name, mask_name)

    tf_config = tf.ConfigProto()
    os.environ["CUDA_VISIBLE_DEVICES"] = "0"
    tf_config = tf.ConfigProto()
    tf_config.gpu_options.allow_growth = True

    with tf.Session(config=tf_config) as sess:
        Cube_Decoder = Decoder_Handler(dataset_name=dataset_name,
                                       model_config=model_config,
                                       sess=sess,
                                       is_training=False,
                                       Cr=Cr)
        Cube_Decoder.test(test_data_name)
Esempio n. 7
0
def main():
    with open(config_filename) as handle:
        model_config = yaml.load(handle, Loader=yaml.FullLoader)
    data_dir = []
    data_dir.append(model_config['category_train'])
    data_dir.append(model_config['category_valid'])
    data_dir.append(model_config['category_test'])
    mask_dir = model_config['category_mask']

    dataset_dir = (data_dir, mask_dir)

    tf_config = tf.ConfigProto()
    os.environ["CUDA_VISIBLE_DEVICES"] = "1"
    tf_config = tf.ConfigProto()
    tf_config.gpu_options.allow_growth = True

    with tf.Session(config=tf_config) as sess:
        Cube_Decoder = Decoder_Handler(dataset_dir=dataset_dir,
                                       model_config=model_config,
                                       sess=sess,
                                       is_training=True)
        Cube_Decoder.train()
Esempio n. 8
0
def main():
    ave_folder, ave_config = 'Decoder-T0427184230-D0.10L0.010-RMSE/', 'config_45.yaml'
    # ave_folder,ave_config = 'Decoder-T0510154141-D0.10L0.010-RMSE/','config_311.yaml'

    folder_id, config_id = ave_folder, ave_config
    with open(config_filename) as handle:
        model_config = yaml.load(handle, Loader=yaml.FullLoader)

    data_name = []
    data_name.append(
        os.path.join(os.path.abspath('..'), model_config['category']))
    data_name.append(
        os.path.join(os.path.abspath('..'), model_config['category_valid']))
    data_name.append(
        os.path.join(os.path.abspath('..'), model_config['category_test']))
    log_dir = os.path.join(os.path.abspath('.'), model_config['result_dir'],
                           model_config['result_model'], folder_id)

    with open(os.path.join(log_dir, config_id)) as handle:
        model_config = yaml.load(handle, Loader=yaml.FullLoader)
    if model_config['mask_name'] == 'Original':
        mask_name = None
    else:
        mask_name = os.path.join(os.path.abspath('..'),
                                 model_config['category_mask'],
                                 model_config['mask_name'])

    dataset_name = (data_name, mask_name)

    os.environ["CUDA_VISIBLE_DEVICES"] = "0"
    tf_config = tf.ConfigProto()
    tf_config.gpu_options.allow_growth = True

    with tf.Session(config=tf_config) as sess:
        Cube_Decoder = Decoder_Handler(dataset_name=dataset_name,
                                       model_config=model_config,
                                       sess=sess,
                                       is_training=False)
        Cube_Decoder.test()