class_docstr: The BlazeFace face detection model from MediaPipe.
  
  The version from MediaPipe is simpler than the one in the paper;
  it does not use the "double" BlazeBlocks.
  
  Because we won't be training this model, it doesn't need to have
  batchnorm layers. These have already been "folded" into the conv
  weights by TFLite.
  
  The conversion to PyTorch is fairly straightforward, but there are
  some small differences between TFLite and PyTorch in how they handle
  padding on conv layers with stride 2.
  
  This version works on batches, while the MediaPipe version can only
  handle a single image at a time.
  
  Based on code from https://github.com/tkat0/PyTorch_BlazeFace/ and
  https://github.com/google/mediapipe/
docstr: The alternative NMS method as mentioned in the BlazeFace paper:
  
  "We replace the suppression algorithm with a blending strategy that
  estimates the regression parameters of a bounding box as a weighted
  mean between the overlapping predictions."
  
  The original MediaPipe code assigns the score of the most confident
  detection to the weighted detection, but we take the average score
  of the overlapping detections.
  
  The input detections should be a Tensor of shape (count, 17).
  
  Returns a list of PyTorch tensors, one for each detected face.
  
  This is based on the source code from:
  mediapipe/calculators/util/non_max_suppression_calculator.cc
  mediapipe/calculators/util/non_max_suppression_calculator.proto
docstr_tok: ["The","alternative","NMS","method","as","mentioned","in","the","BlazeFace","paper",":","''","We","replace","the","suppression","algorithm","with","a","blending","strategy","that","estimates","the","regression","parameters","of","a","bounding","box","as","a","weighted","mean","between","the","overlapping","predictions",".","''","The","original","MediaPipe","code","assigns","the","score","of","the","most","confident","detection","to","the","weighted","detection",",","but","we","take","the","average","score","of","the","overlapping","detections",".","The","input","detections","should","be","a","Tensor","of","shape","(","count",",","17",")",".","Returns","a","list","of","PyTorch","tensors",",","one","for","each","detected","face",".","This","is","based","on","the","source","code","from",":","mediapipe\/calculators\/util\/non_max_suppression_calculator.cc","mediapipe\/calculators\/util\/non_max_suppression_calculator.proto"]
code: def _weighted_non_max_suppression(self, detections):
      """The alternative NMS method as mentioned in the BlazeFace paper:
  
      "We replace the suppression algorithm with a blending strategy that
      estimates the regression parameters of a bounding box as a weighted
      mean between the overlapping predictions."
  
      The original MediaPipe code assigns the score of the most confident
      detection to the weighted detection, but we take the average score
      of the overlapping detections.
  
      The input detections should be a Tensor of shape (count, 17).
  
      Returns a list of PyTorch tensors, one for each detected face.
  
      This is based on the source code from:
      mediapipe/calculators/util/non_max_suppression_calculator.cc
      mediapipe/calculators/util/non_max_suppression_calculator.proto
      """
      if len(detections) == 0:
          return []
  
      output_detections = []
  
      # Sort the detections from highest to lowest score.
      remaining = torch.argsort(detections[:, 16], descending=True)
  
      while len(remaining) > 0:
          detection = detections[remaining[0]]
  
          # Compute the overlap between the first box and the other
          # remaining boxes. (Note that the other_boxes also include
          # the first_box.)
          first_box = detection[:4]
          other_boxes = detections[remaining, :4]
          ious = overlap_similarity(first_box, other_boxes)
  
          # If two detections don't overlap enough, they are considered
          # to be from different faces.
          mask = ious > self.min_suppression_threshold
          overlapping = remaining[mask]
          remaining = remaining[~mask]
  
          # Take an average of the coordinates from the overlapping
          # detections, weighted by their confidence scores.
          weighted_detection = detection.clone()
          if len(overlapping) > 1:
              coordinates = detections[overlapping, :16]
              scores = detections[overlapping, 16:17]
              total_score = scores.sum()
              weighted = (coordinates * scores).sum(dim=0) / total_score
              weighted_detection[:16] = weighted
              weighted_detection[16] = total_score / len(overlapping)
  
          output_detections.append(weighted_detection)
  
      return output_detections
  
imports: import numpy
  import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 15 for calling the BlazeFace obj's underlying member method code with example usage: obj._weighted_non_max_suppression(detections) and returns: output_detections, list