Ejemplo n.º 1
0
        mask_names.append(bbox_path)
        #gt_images.append(image)
        if i % batch_size == 0:
            yield (gt_images[(i - batch_size):i],
                   input_images[(i - batch_size):i],
                   file_names[(i - batch_size):i],
                   mask_names[(i - batch_size):i])
    #input_images = np.array(input_images)
    #print('Shape of image: {}'.format(input_images.shape))


if __name__ == "__main__":
    ng.get_gpus(1)
    args = parser.parse_args()

    model = InpaintGCModel()

    sess_config = tf.ConfigProto()
    sess_config.gpu_options.allow_growth = True
    with tf.Session(config=sess_config) as sess:
        input_image = tf.placeholder(tf.float32, shape=[1, 256, 256, 3])
        input_mask = tf.placeholder(tf.float32, shape=[1, 256, 256, 1])
        input_guide = tf.placeholder(tf.float32, shape=[1, 256, 256, 1])
        output = model.build_server_graph(input_image, input_mask, input_guide)
        output = (output + 1.) * 127.5
        output = tf.reverse(output, [-1])
        output = tf.saturate_cast(output, tf.uint8)
        # load pretrained model
        vars_list = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES)
        assign_ops = []
Ejemplo n.º 2
0
    else:
        data_mask_data = DataFromFNames(fnames,
                                        config.IMG_SHAPES,
                                        random_crop=config.RANDOM_CROP)
        images = data_mask_data.data_pipeline(config.BATCH_SIZE)
        masks = None
    # # Mask Data
    # with open(config.DATA_FLIST[config.MASKDATASET][0]) as f:
    #     fnames = f.read().splitlines()
    # mask_data = MaskFromFNames(
    #     fnames, config.MASK_SHAPES, random_crop=config.RANDOM_CROP)
    # masks = mask_data.data_pipeline(config.BATCH_SIZE)

    guides = None
    # main model
    model = InpaintGCModel()
    g_vars, d_vars, losses = model.build_graph_with_losses(images,
                                                           masks,
                                                           guides,
                                                           config=config)
    # validation images
    if config.VAL:
        with open(config.DATA_FLIST[config.DATASET][1]) as f:
            val_fnames = f.read().splitlines()
        with open(config.DATA_FLIST[config.MASKDATASET][1]) as f:
            val_mask_fnames = f.read().splitlines()
        # progress monitor by visualizing static images
        for i in range(config.STATIC_VIEW_SIZE):
            static_fnames = val_fnames[i:i + 1]

            if config.MASKFROMFILE: