def predict_from_h5data(self, h5_data_path, val_fold_nb, use_channels, is_train=False, save_dir=None,
                            random_k_fold=False, random_k_fold_npy=None, input_channels=1,
                            output_channels=2, random_crop_size=None, mask_nb=0, batch_size=4
                            ):
        dataset = DataSet(h5_data_path, val_fold_nb, random_k_fold=random_k_fold, random_k_fold_npy=random_k_fold_npy,
                          input_channels=input_channels,
                          output_channels=output_channels, random_crop_size=random_crop_size, mask_nb=mask_nb,
                          batch_size=batch_size)
        images, _ = dataset.prepare_data(is_train)
        pred = self.predict(images, batch_size, use_channels=use_channels)

        if save_dir:
            keys = dataset.get_keys(is_train)
            mask_file_lst = ["{:03}.tif".format(int(key)) for key in keys]
            self.save_mask(pred, mask_file_lst, mask_nb, result_save_dir=save_dir)
        return pred
def do_evaluate():
    h5_data_path = "/home/topsky/helloworld/study/njai_challenge/cbct/inputs/data_0717.hdf5"
    val_fold_nb = "01"
    output_channels = 2
    is_train = False
    model_def = get_se_inception_resnet_v2_unet_sigmoid_gn(weights=None, output_channels=output_channels)
    model_weights = "/home/topsky/helloworld/study/njai_challenge/cbct/model_weights/new/20180802_0/se_inception_resnet_v2_gn_fold01_random_kfold_0_1i_2o.h5"

    model_obj = ModelDeployment(model_def, model_weights)
    dataset = DataSet(h5_data_path, val_fold_nb=val_fold_nb)
    images, masks = dataset.prepare_data(is_train=is_train)
    print(images.shape)
    print(masks.shape)
    # idx_lst = [0, 5, 10, 15, 20]
    # val_images = np.array([images[i] for i in idx_lst])
    # val_masks = np.array([masks[i] for i in idx_lst])
    # model_obj.evaluate(val_images, val_masks)
    model_obj.evaluate(images, masks)