Beispiel #1
0
 def detected_bboxes(self,
                     predictions,
                     localisations,
                     select_threshold=None,
                     nms_threshold=0.5,
                     clipping_bbox=None,
                     top_k=400,
                     keep_top_k=200):
     """Get the detected bounding boxes from the SSD network output.
     """
     # Select top_k bboxes from predictions, and clip
     rscores, rbboxes = \
         ssd_common.tf_ssd_bboxes_select(predictions, localisations,
                                         select_threshold=select_threshold,
                                         num_classes=self.params.num_classes)
     rscores, rbboxes = \
         tfe.bboxes_sort(rscores, rbboxes, top_k=top_k)
     # Apply NMS algorithm.
     rscores, rbboxes = \
         tfe.bboxes_nms_batch(rscores, rbboxes,
                              nms_threshold=nms_threshold,
                              keep_top_k=keep_top_k)
     # if clipping_bbox is not None:
     #     rbboxes = tfe.bboxes_clip(clipping_bbox, rbboxes)
     return rscores, rbboxes
Beispiel #2
0
    def detected_bboxes(self,predictions,locations,selected_threshold=None,nms_threshold=0.5,clipping_bbox=None,top_k=400,keep_top_k=200):
        rscores,rbboxes=ssd_common.tf.ssd_bboxes_selected(predictions,locations,selected_threshold=selected_threshold,num_classes=self.num_classes)
        rscores,rbboxes= \
                tfe.bboxes_sort(rscores,rbboxes,top_k=top_k)

        rscores,rbboxes= \
                tfe.bboxes_nms_batch(rscores,rbboxes,nms_threshold=nms_threshold,keep_top_k=keep_top_k)

        return rscores,rbboxes
Beispiel #3
0
 def detected_bboxes(self, predictions, localisations,
                     select_threshold=None, nms_threshold=0.5,
                     clipping_bbox=None, top_k=400, keep_top_k=200):
     """Get the detected bounding boxes from the SSD network output.
     """
     # Select top_k bboxes from predictions, and clip
     rscores, rbboxes = \
         ssd_common.tf_ssd_bboxes_select(predictions, localisations,
                                         select_threshold=select_threshold,
                                         num_classes=self.params.num_classes)
     rscores, rbboxes = \
         tfe.bboxes_sort(rscores, rbboxes, top_k=top_k)
     # Apply NMS algorithm.
     rscores, rbboxes = \
         tfe.bboxes_nms_batch(rscores, rbboxes,
                              nms_threshold=nms_threshold,
                              keep_top_k=keep_top_k)
     # if clipping_bbox is not None:
     #     rbboxes = tfe.bboxes_clip(clipping_bbox, rbboxes)
     return rscores, rbboxes
Beispiel #4
0
    def detected_bboxes(self, predictions, localisations,   #通过SSD网络,得到检测到的bbox
                        select_threshold=None, nms_threshold=0.5,
                        clipping_bbox=None, top_k=400, keep_top_k=200):
        """Get the detected bounding boxes from the SSD network output.    
        """
        # Select top_k bboxes from predictions, and clip    #选取top_k=400个框,并对框做修建(超出原图尺寸范围的切掉)
        rscores, rbboxes = \                                                       #得到对应某个类别的得分值以及bbox
            ssd_common.tf_ssd_bboxes_select(predictions, localisations,
                                            select_threshold=select_threshold,
                                            num_classes=self.params.num_classes)
        rscores, rbboxes = \                                     #按照得分高低,筛选出400个bbox和对应得分
            tfe.bboxes_sort(rscores, rbboxes, top_k=top_k)
        # Apply NMS algorithm.                                   #应用非极大值抑制,筛选掉与得分最高bbox重叠率大于0.5的,保留200个
        rscores, rbboxes = \
            tfe.bboxes_nms_batch(rscores, rbboxes,
                                 nms_threshold=nms_threshold,
                                 keep_top_k=keep_top_k)
        if clipping_bbox is not None:
            rbboxes = tfe.bboxes_clip(clipping_bbox, rbboxes)
        return rscores, rbboxes                              #返回裁剪好的bbox和对应得分
#尽管一个ground truth可以与多个先验框匹配,但是ground truth相对先验框还是太少了,
#所以负样本相对正样本会很多。为了保证正负样本尽量平衡,SSD采用了hard negative mining,
#就是对负样本进行抽样,抽样时按照置信度误差(预测背景的置信度越小,误差越大)进行降序排列,
#选取误差的较大的top-k作为训练的负样本,以保证正负样本比例接近1:3
    def losses(self, logits, localisations,
               gclasses, glocalisations, gscores,
               match_threshold=0.5,
               negative_ratio=3.,
               alpha=1.,
               label_smoothing=0.,
               scope='ssd_losses'):