Esempio n. 1
0
def load_data(n_examples, im_width, im_height, type_data):
    """
        Output: Batch training data
        sze_of_img_all: Img size of each image in the batch
        group_img: stacked resized training images [n, 244,244,3]
        np.array(training_data): traning probability output
        np.array(encoded_training): training regression output

        NOTE USED
        np.array(selected_anchors):
        np.array(selected_anchors_normal):
    """
    shw_example = False
    JPEG_images, Annotation_images, df = read_voc.load_data_full(
        type_data, shw_example)
    bbxs_sizes = read_voc.getting_all_bbx(Annotation_images, type_data, df)
    training_data = []
    encoded_training = []
    selected_anchors = []
    selected_anchors_normal = []
    cnt = 0
    sze_of_img_all = np.zeros([len(n_examples), 2])
    group_img = np.zeros([len(n_examples), im_width, im_height, 3],
                         dtype=np.uint8)
    for n_example in n_examples:
        img = Image.open(JPEG_images[n_example])
        sze_of_img = img.size
        show_img_ = False
        #print bbxs_sizes[n_example]
        img = np.array(img.resize((im_width, im_height), Image.ANTIALIAS))
        group_img[cnt] = img
        sze_of_img_all[cnt] = sze_of_img
        cnt += 1

        bbxs_sizes[n_example] = resizing_targets(bbxs_sizes[n_example],
                                                 sze_of_img, im_width,
                                                 im_height)
        print("bbxs_sizes first example", bbxs_sizes[n_example])
        #training_data, encoded_training, selected_anchors = get_training_data(centres_mmxy, bbxs_sizes[1])
        single_training_data, single_encoded_training, single_selected_anchors, single_selected_anchors_normal = new_get_training_data(
            centres_mmxy, bbxs_sizes[n_example])
        training_data.append(single_training_data)
        encoded_training.append(single_encoded_training)
        selected_anchors.append(single_selected_anchors)
        selected_anchors_normal.append(single_selected_anchors_normal)
        print img.dtype, group_img.dtype, np.expand_dims(img, axis=0).dtype
        if show_img_:
            _, fig1 = plt.subplots(1)

            #fig1.axis([-600, 600, -600, 600])

            #print newImaa.shape
            fig1.imshow(group_img[cnt - 1], vmin=0, vmax=255)
            #fig1.imshow(img, vmin=0, vmax=255)
            draw_bbx(single_selected_anchors, fig1, sze_of_img, im_width,
                     im_height, True)
            plt.show()
    return sze_of_img_all, group_img, np.array(training_data), np.array(
        encoded_training), np.array(selected_anchors), np.array(
            selected_anchors_normal)
Esempio n. 2
0
def load_data(n_examples, im_width, im_height, type_data):
    shw_example = False
    JPEG_images, Annotation_images, df = read_voc.load_data_full(
        type_data, shw_example)
    bbxs_sizes = read_voc.getting_all_bbx(Annotation_images, type_data, df)
    training_data = []
    encoded_training = []
    selected_anchors = []
    selected_anchors_normal = []
    cnt = 0
    group_img = np.zeros([len(n_examples), im_width, im_height, 3])
    for n_example in n_examples:
        img = Image.open(JPEG_images[n_example])
        sze_of_img = img.size
        show_img_ = True
        #print bbxs_sizes[n_example]
        img = np.array(img.resize((im_width, im_height), Image.ANTIALIAS))
        group_img[cnt] = img
        cnt += 1

        if show_img_:
            _, fig1 = plt.subplots(1)
            #fig1.axis([-600, 600, -600, 600])
            fig1.imshow(img)
            plt.show()
        bbxs_sizes[n_example] = resizing_targets(bbxs_sizes[n_example],
                                                 sze_of_img, im_width,
                                                 im_height)
        print("bbxs_sizes first example", bbxs_sizes[n_example])
        #training_data, encoded_training, selected_anchors = get_training_data(centres_mmxy, bbxs_sizes[1])
        single_training_data, single_encoded_training, single_selected_anchors, single_selected_anchors_normal = new_get_training_data(
            centres_mmxy, bbxs_sizes[n_example])
        training_data.append(single_training_data)
        encoded_training.append(single_encoded_training)
        selected_anchors.append(single_selected_anchors)
        selected_anchors_normal.append(single_selected_anchors_normal)
    return group_img, np.array(training_data), np.array(
        encoded_training), np.array(selected_anchors), np.array(
            selected_anchors_normal)
Esempio n. 3
0
im_width = 224
im_height = 224
print "good till here1"
bbx_size = [8, 16, 32]  #[8, 64, 128]#[8, 64, 128]#[8, 16, 32]
bbx_ratio = [1, 1 / 1.5, 1.5]  #[1, 0.5, 2]

centres, centres_mmxy = gen_anchor_bx(bbx_size, bbx_ratio, im_width, im_height)
print 'centres', len(centres)
print 'centres_mmxy', len(centres_mmxy)
####Loading data######
type_data = ''
shw_example = False
n_example = 215  #25#432
JPEG_images, Annotation_images, df = read_voc.load_data_full(
    type_data, shw_example)
bbxs_sizes = read_voc.getting_all_bbx(Annotation_images, type_data, df)
#print "bbxs_sizes", bbxs_sizes

im_placeholder = tf.placeholder(tf.float32, [None, im_height, im_width, 3])

y_ = tf.placeholder(tf.float32, [None, 9 * 14 * 14, 2], name='ob_prob')
y_reg = tf.placeholder(tf.float32, [None, 9 * 14 * 14, 4], name='ob_reg')

net_cnn, net2, net1, logits = netvgg(im_placeholder, is_training=False)

sum_yreg = tf.reduce_sum(y_reg, axis=-1, keep_dims=True)
#sum_yreg = tf.cast(sum_yreg, tf.float32)
print "SUM!!!!!!!!!!!!!!", sum_yreg
sum_yreg = (tf.not_equal(sum_yreg, 0))
sum_yreg = tf.cast(sum_yreg, tf.float32)