parameters: (outputs, anchors, downsample_ratios, num_classes, img_hw, obj_thresh, nms_threshold, scale_x_y=1.05)
return_statement: return box, clss, score
docstring: box list
docstring_summary: box list
docstring_tokens: box list
function: def decode_outputs(outputs, anchors, downsample_ratios, num_classes, img_hw, obj_thresh, nms_threshold, scale_x_y=1.05):
      """ box list """
      _xyxy_box = []
      _xyxy_box_scores = []
      """ preprocess label """
      for pred_label, anchor, downsample in zip(outputs, anchors, downsample_ratios):
          """ split the label """
          pred_xy = pred_label[..., 0: 2]
          pred_wh = pred_label[..., 2: 4]
          pred_confidence = pred_label[..., 4: 5]
          pred_cls = pred_label[..., 5:]
          if num_classes > 1:
              box_scores = sigmoid(pred_cls) * sigmoid(pred_confidence)
          else:
              box_scores = sigmoid(pred_confidence)
  
          """ calc pred box  """
          # xywh_to_all will use sigmoid
          pred_xy_A, pred_wh_A = xywh_to_all(
              pred_xy, pred_wh, img_hw, downsample, anchor, scale=scale_x_y)
          # boxes from xywh to xyxy
          boxes = center_to_corner(np.concatenate((pred_xy_A, pred_wh_A), -1))
          boxes = np.reshape(boxes, (-1, 4))
          box_scores = np.reshape(box_scores, (-1, num_classes))
          """ append box and scores to global list """
          _xyxy_box.append(boxes)
          _xyxy_box_scores.append(box_scores)
  
      xyxy_box = np.concatenate(_xyxy_box, axis=0)
      xyxy_box_scores = np.concatenate(_xyxy_box_scores, axis=0)
  
      mask = xyxy_box_scores >= obj_thresh
  
      """ do nms for every classes"""
      _boxes = []
      _scores = []
      _classes = []
      for c in range(num_classes):
          class_boxes = xyxy_box[mask[:, c]]
          class_box_scores = xyxy_box_scores[:, c][mask[:, c]]
          select = nms_oneclass(class_boxes, class_box_scores,
                                nms_threshold, method='iou')
          class_boxes = class_boxes[select]
          class_box_scores = class_box_scores[select]
          _boxes.append(class_boxes)
          _scores.append(class_box_scores)
          _classes.append(np.ones_like(class_box_scores) * c)
  
      box: np.ndarray = np.concatenate(_boxes, axis=0)
      clss: np.ndarray = np.concatenate(_classes, axis=0)
      score: np.ndarray = np.concatenate(_scores, axis=0)
      return box, clss, score
function_tokens: def decode_outputs ( outputs , anchors , downsample_ratios , num_classes , img_hw , obj_thresh , nms_threshold , scale_x_y = 1.05 ) : _xyxy_box = [ ] _xyxy_box_scores = [ ] """ preprocess label """ for pred_label , anchor , downsample in zip ( outputs , anchors , downsample_ratios ) : """ split the label """ pred_xy = pred_label [ ... , 0 : 2 ] pred_wh = pred_label [ ... , 2 : 4 ] pred_confidence = pred_label [ ... , 4 : 5 ] pred_cls = pred_label [ ... , 5 : ] if num_classes > 1 : box_scores = sigmoid ( pred_cls ) * sigmoid ( pred_confidence ) else : box_scores = sigmoid ( pred_confidence ) """ calc pred box  """ # xywh_to_all will use sigmoid pred_xy_A , pred_wh_A = xywh_to_all ( pred_xy , pred_wh , img_hw , downsample , anchor , scale = scale_x_y ) # boxes from xywh to xyxy boxes = center_to_corner ( np . concatenate ( ( pred_xy_A , pred_wh_A ) , - 1 ) ) boxes = np . reshape ( boxes , ( - 1 , 4 ) ) box_scores = np . reshape ( box_scores , ( - 1 , num_classes ) ) """ append box and scores to global list """ _xyxy_box . append ( boxes ) _xyxy_box_scores . append ( box_scores ) xyxy_box = np . concatenate ( _xyxy_box , axis = 0 ) xyxy_box_scores = np . concatenate ( _xyxy_box_scores , axis = 0 ) mask = xyxy_box_scores >= obj_thresh """ do nms for every classes""" _boxes = [ ] _scores = [ ] _classes = [ ] for c in range ( num_classes ) : class_boxes = xyxy_box [ mask [ : , c ] ] class_box_scores = xyxy_box_scores [ : , c ] [ mask [ : , c ] ] select = nms_oneclass ( class_boxes , class_box_scores , nms_threshold , method = 'iou' ) class_boxes = class_boxes [ select ] class_box_scores = class_box_scores [ select ] _boxes . append ( class_boxes ) _scores . append ( class_box_scores ) _classes . append ( np . ones_like ( class_box_scores ) * c ) box : np . ndarray = np . concatenate ( _boxes , axis = 0 ) clss : np . ndarray = np . concatenate ( _classes , axis = 0 ) score : np . ndarray = np . concatenate ( _scores , axis = 0 ) return box , clss , score