def bboxes_encode(self, labels, bboxes, anchors, scope='ssd_bboxes_encode'): """Encode labels and bounding boxes. """ return ssd_common.tf_ssd_bboxes_encode( labels, bboxes, anchors, matching_threshold=0.5, prior_scaling=self.params.prior_scaling, scope=scope)
def bboxes_encode(self, labels, bboxes, anchors, scope=None): """Encode labels and bounding boxes. """ return ssd_common.tf_ssd_bboxes_encode( labels, bboxes, anchors, self.params.num_classes, self.params.no_annotation_label, ignore_threshold=0.5, prior_scaling=self.params.prior_scaling, scope=scope)
def bboxes_encode(self, labels, bboxes, anchors, #编码,用于将标签信息,真实目标信息和锚点框信息编码在一起;得到预测真实框到参考框的转换值 scope=None): """Encode labels and bounding boxes. """ return ssd_common.tf_ssd_bboxes_encode( labels, bboxes, anchors, self.params.num_classes, self.params.no_annotation_label, #未标注的标签(应该代表背景) ignore_threshold=0.5, #IOU筛选阈值 prior_scaling=self.params.prior_scaling, #特征图目标与参考框间的尺寸缩放(0.1,0.1,0.2,0.2) scope=scope)
def bboxes_encode(self, labels, bboxes, anchors, positive_threshold=0.5, ignore_threshold=0.3, scope=None): """Encode labels and bounding boxes. """ return ssd_common.tf_ssd_bboxes_encode( labels, bboxes, anchors, self.params.num_classes, self.params.img_shape, self.params.allowed_borders, self.params.no_annotation_label, positive_threshold=positive_threshold, ignore_threshold=ignore_threshold, prior_scaling=self.params.prior_scaling, scope=scope)
reuse = True if 'ssd' in locals() else None params = ssd_vgg_300.SSDNet.default_params ssd = ssd_vgg_300.SSDNet(params) with slim.arg_scope(ssd.arg_scope(weight_decay=0.0005)): predictions, localisations, logits, end_points = ssd.net(image_4d, is_training=False, reuse=reuse) # SSD default anchor boxes. img_shape = out_shape layers_anchors = ssd.anchors(img_shape, dtype=np.float32) # In[41]: # Targets encoding. target_labels, target_localizations, target_scores = ssd_common.tf_ssd_bboxes_encode( labels, bboxes_pre, layers_anchors, 8, 8) # In[43]: # Initialize variables. init_op = tf.global_variables_initializer() sess.run(init_op) # Restore SSD model. saver = tf.train.Saver() saver.restore(sess, ckpt_filename) # In[45]: # Run model. [ rimg, rpredictions, rlocalisations, glabels, gbboxes, rbbox_img, rt_labels,
# SSD construction. with slim.arg_scope(ssd.arg_scope(weight_decay=0.0005)): predictions, localisations, logits, end_points = ssd.net(image_4d, is_training=False, reuse=reuse) # SSD default anchor boxes. img_shape = out_shape layers_anchors = ssd.anchors(img_shape, dtype=np.float32) for k in sorted(end_points.keys()): print(k, end_points[k].get_shape()) # Targets encoding. target_labels, target_localizations, target_scores = \ ssd_common.tf_ssd_bboxes_encode(labels, bboxes_pre, layers_anchors, num_classes=params.num_classes, no_annotation_label=params.no_annotation_label) nms_threshold = 0.5 # Output decoding. localisations = ssd.bboxes_decode(localisations, layers_anchors) tscores, tbboxes = ssd.detected_bboxes(predictions, localisations, select_threshold=0.8, nms_threshold=0.5) # Initialize variables. init_op = tf.global_variables_initializer() isess.run(init_op) # Restore SSD model. saver = tf.train.Saver()
def bboxes_encode(self, labels, bboxes, anchors, scope=None): """ Encode labels and bounding boxes. """ return ssd_common.tf_ssd_bboxes_encode()