def add_roi_batch_img_smry(self, img, rois, labels): positive_roi_indices = tf.reshape(tf.where(tf.greater_equal(labels, 1)), [-1]) negative_roi_indices = tf.reshape(tf.where(tf.equal(labels, 0)), [-1]) pos_roi = tf.gather(rois, positive_roi_indices) neg_roi = tf.gather(rois, negative_roi_indices) pos_in_img = show_box_in_tensor.only_draw_boxes(img_batch=img, boxes=pos_roi) neg_in_img = show_box_in_tensor.only_draw_boxes(img_batch=img, boxes=neg_roi) tf.summary.image('pos_rois', pos_in_img) tf.summary.image('neg_rois', neg_in_img)
def add_anchor_img_smry(self, img, anchors, labels, method): positive_anchor_indices = tf.reshape(tf.where(tf.greater_equal(labels, 1)), [-1]) negative_anchor_indices = tf.reshape(tf.where(tf.equal(labels, 0)), [-1]) positive_anchor = tf.gather(anchors, positive_anchor_indices) negative_anchor = tf.gather(anchors, negative_anchor_indices) pos_in_img = show_box_in_tensor.only_draw_boxes(img_batch=img, boxes=positive_anchor, method=method) neg_in_img = show_box_in_tensor.only_draw_boxes(img_batch=img, boxes=negative_anchor, method=method) tf.summary.image('positive_anchor', pos_in_img) tf.summary.image('negative_anchors', neg_in_img)
anchors = make_anchors(32, [2.], [2.0, 1 / 2], anchor_angles, featuremap_height=800 // 8, featuremap_width=800 // 8, stride=8) # anchors = make_anchors(base_anchor_size=cfgs.BASE_ANCHOR_SIZE_LIST[0], # anchor_scales=cfgs.ANCHOR_SCALES, # anchor_ratios=cfgs.ANCHOR_RATIOS, # anchor_angles=cfgs.ANCHOR_ANGLES, # featuremap_height=800 // 16, # featuremap_width=800 // 16, # stride=cfgs.ANCHOR_STRIDE[0], # name="make_anchors_forRPN") img = tf.zeros([800, 800, 3]) img = tf.expand_dims(img, axis=0) img1 = only_draw_boxes(img, anchors[9100:9110], 'r') with tf.Session() as sess: temp1, _img1 = sess.run([anchors, img1]) _img1 = _img1[0] cv2.imwrite('rotate_anchors.jpg', _img1) cv2.waitKey(0) print(temp1) print('debug')