Exemple #1
0
        capacity=min_queue_examples + (num_threads+2)*BATCH_SIZE,
        seed=3,
        min_after_dequeue=min_queue_examples)
    return input_batch, mask_batch, label_batch

def next_batch(inputrgb_queue, inputmsk_queue, label_queue):
    input_batch, mask_batch, label_batch = train_label_reader(inputrgb_queue, inputmsk_queue, label_queue)
    batch = tf.concat([input_batch, mask_batch, label_batch], axis=3)
    return batch


sess = tf.InteractiveSession()
images = tf.placeholder("float")
batch_images = tf.expand_dims(images, 0)

vgg_fcn = fcn8_vgg_ours.FCN8VGG()
with tf.name_scope("content_vgg"):
    vgg_fcn.build(batch_images, debug=True)



labels = tf.placeholder("int32", [None, HEIGHT, WIDTH])
loss = fcn8_vgg_ours.pixel_wise_cross_entropy(vgg_fcn.upscore32, labels, num_classes = 2)    
tf.summary.scalar('pixel_wise_cross_entropy_loss', loss)
merged_summary = tf.summary.merge_all()
train_writer = tf.summary.FileWriter('./train_summary', sess.graph)

train_step = tf.train.AdamOptimizer(1e-4,0.9).minimize(loss)
logging.info("********* CNN constructed *********")

train_file = "./all_train_imgs.csv"
Exemple #2
0
                    stream=sys.stdout)

from tensorflow.python.framework import ops

img1 = scp.misc.imread("./test_data/tabby_cat.png")
fake_mask = scp.misc.imread("./test_data/tabby_cat.png", 'L')
msk_layer = np.expand_dims(fake_mask, axis=2)
print(msk_layer.shape, img1.shape)
input_img = np.append(img1, msk_layer, 2)
print("shape", input_img.shape)
with tf.Session() as sess:
    images = tf.placeholder("float")
    feed_dict = {images: input_img}
    batch_images = tf.expand_dims(images, 0)

    vgg_fcn = fcn8_vgg.FCN8VGG()
    with tf.name_scope("content_vgg"):
        vgg_fcn.build(batch_images, debug=True)

    print('Finished building Network.')

    logging.warning("Score weights are initialized random.")
    logging.warning("Do not expect meaningful results.")

    logging.info("Start Initializing Variabels.")

    init = tf.global_variables_initializer()
    sess.run(init)

    print('Running the Network')
    tensors = [vgg_fcn.pred, vgg_fcn.pred_up]
fake_mask = scp.misc.imread("./test_data/tabby_cat.png",
                            'L')  # ‘L’ (8-bit pixels, black and white) # &&
msk_layer = np.expand_dims(fake_mask, axis=2)
print(msk_layer.shape, img1.shape)
input_img = np.append(img1, msk_layer, 2)
print("shape", input_img.shape)

with tf.Session() as sess:  # open session
    images = tf.placeholder("float")
    feed_dict = {
        images: input_img
    }  # (feed_dict is just an argument for sess.run() function)  # &&
    batch_images = tf.expand_dims(images, 0)  # (to build vgg_fcn)

    vgg_fcn = fcn8_vgg.FCN8VGG(
    )  # build the vgg_fcn ("VGG OBJECT") for finetuning (FCN8 VGG here)
    with tf.name_scope("content_vgg"):
        vgg_fcn.build(
            batch_images,
            debug=True)  # "" batch_images to build vgg_fcn ("VGG OBJECT")

    print('Finished building Network.')

    logging.warning("Score weights are initialized random.")
    logging.warning("Do not expect meaningful results.")

    logging.info("Start Initializing Variabels.")

    init = tf.global_variables_initializer()
    sess.run(init)