batchsize = C.onegpu * num_gpu
print('Batch size: {}'.format(batchsize))
os.environ["CUDA_VISIBLE_DEVICES"] = C.gpu_ids

# experiment specification
specif = sys.argv[2]

# get the training data
cache_path = sys.argv[1]
with open(cache_path, 'rb') as fid:
    train_data = cPickle.load(fid)
num_imgs_train = len(train_data)
random.shuffle(train_data)
print
'num of training samples: {}'.format(num_imgs_train)
data_gen_train = data_generators.get_data(train_data, C, batchsize=batchsize)

# define the base network (resnet here, can be MobileNet, etc)
if C.network == 'resnet50':
    from keras_csp import resnet50 as nn

    weight_path = 'data/models/resnet50_weights_tf_dim_ordering_tf_kernels.h5'

input_shape_img = (C.size_train[0], C.size_train[1], 3)
img_input = Input(shape=input_shape_img)
# define the network prediction
preds = nn.nn_p3p4p5(img_input,
                     offset=C.offset,
                     num_scale=C.num_scale,
                     trainable=True)
preds_tea = nn.nn_p3p4p5(img_input,
Example #2
0
max_nonimproving_epochs = 10
C.offset = True

num_gpu = len(C.gpu_ids.split(','))
batchsize = C.onegpu * num_gpu
os.environ["CUDA_VISIBLE_DEVICES"] = C.gpu_ids

# get the training data
cache_path_train = 'data/cache/cityperson_trainValTest/train_h50{}'.format(exp_name)
with open(cache_path_train, 'rb') as fid:
    train_data = cPickle.load(fid)
print('Loaded training cache from {}'.format(cache_path_train))
num_imgs_train = len(train_data)
random.shuffle(train_data)
print('num of training samples: {}'.format(num_imgs_train))
data_gen_train = data_generators.get_data(train_data, C, batchsize=batchsize, exp_name=exp_name)

# get the validation data
cache_path_val = 'data/cache/cityperson_trainValTest/val'
with open(cache_path_val, 'rb') as fid:
    val_data = cPickle.load(fid)
print('Loaded validation cache from {}'.format(cache_path_val))
num_imgs_val = len(val_data)
random.shuffle(val_data)
print('num of validation samples: {}'.format(num_imgs_val))
data_gen_val = data_generators.get_data_eval(val_data, C, batchsize=batchsize)
n_iter_eval = len(val_data) // batchsize
eval_report_after = n_iter_eval // 10

# define the base network (resnet here, can be MobileNet, etc)
if C.network == 'resnet50':