예제 #1
0
val_step_update = cfg.val_step_update
######################################

######################################
# Load training and validation images & labels
######################################
#load training volumes id numbers to train the unet
train_list = data_list.train_data(parse_config.no_of_tr_imgs,
                                  parse_config.comb_tr_imgs)
#load saved training data in cropped dimensions directly
print('loading train volumes')
train_imgs, train_labels = dt.load_cropped_img_labels(train_list)
#print('train shape',train_imgs.shape,train_labels.shape)

#load validation volumes id numbers to save the best model during training
val_list = data_list.val_data(parse_config.no_of_tr_imgs,
                              parse_config.comb_tr_imgs)
#load val data both in original dimensions and its cropped dimensions
print('loading val volumes')
val_label_orig, val_img_crop, val_label_crop, pixel_val_list = load_val_imgs(
    val_list, dt, orig_img_dt)

# get test volumes id list
print('get test volumes list')
test_list = data_list.test_data()
######################################

######################################
#define directory to save the model
save_dir = str(cfg.srt_dir) + '/models/' + str(
    parse_config.dataset) + '/trained_models/train_baseline/'
######################################
# load train and val images
train_list = data_list.train_data(parse_config.no_of_tr_imgs,parse_config.comb_tr_imgs)
#load train data cropped images directly
print('loading train imgs')
train_imgs,train_labels = dt.load_acdc_cropped_img_labels(train_list)

if(parse_config.no_of_tr_imgs=='tr1'):
    train_imgs_copy=np.copy(train_imgs)
    train_labels_copy=np.copy(train_labels)
    while(train_imgs.shape[2]<cfg.batch_size):
        train_imgs=np.concatenate((train_imgs,train_imgs_copy),axis=2)
        train_labels=np.concatenate((train_labels,train_labels_copy),axis=2)
    del train_imgs_copy,train_labels_copy

val_list = data_list.val_data()
#load both val data and its cropped images
print('loading val imgs')
val_label_orig,val_img_crop,val_label_crop,pixel_val_list=load_val_imgs(val_list,dt,orig_img_dt)

# # load unlabeled images
unl_list = data_list.unlabeled_data()
print('loading unlabeled imgs')
unlabeled_imgs=dt.load_acdc_cropped_img_labels(unl_list,label_present=0)
#print('unlabeled_imgs',unlabeled_imgs.shape)

# get test list
print('get test imgs list')
test_list = data_list.test_data()
struct_name=cfg.struct_name
val_step_update=cfg.val_step_update