class_docstr: Abstract class to postprocess the raw output of the model
  
  Args:
  ----
      box_thresh (float): minimal objectness score to consider a box
      bin_thresh (float): threshold to apply to segmentation raw heatmap
      assume straight_pages (bool): if True, fit straight boxes only
class_docstr_tok: ["Abstract","class","to","postprocess","the","raw","output","of","the","model","Args",":","--","--","box_thresh","(","float",")",":","minimal","objectness","score","to","consider","a","box","bin_thresh","(","float",")",":","threshold","to","apply","to","segmentation","raw","heatmap","assume","straight_pages","(","bool",")",":","if","True",",","fit","straight","boxes","only"]
docstr: Compute the confidence score for a polygon : mean of the p values on the polygon
  
  Args:
  ----
      pred (np.ndarray): p map returned by the model
      points: coordinates of the polygon
      assume_straight_pages: if True, fit straight boxes only
  
  Returns:
  -------
      polygon objectness
docstr_tok: ["Compute","the","confidence","score","for","a","polygon",":","mean","of","the","p","values","on","the","polygon","Args",":","--","--","pred","(","np.ndarray",")",":","p","map","returned","by","the","model","points",":","coordinates","of","the","polygon","assume_straight_pages",":","if","True",",","fit","straight","boxes","only","Returns",":","--","--","--","-","polygon","objectness"]
code: def box_score(
      pred: np.ndarray,
      points: np.ndarray,
      assume_straight_pages: bool = True,
  ) -> float:
      """Compute the confidence score for a polygon : mean of the p values on the polygon
  
      Args:
      ----
          pred (np.ndarray): p map returned by the model
          points: coordinates of the polygon
          assume_straight_pages: if True, fit straight boxes only
  
      Returns:
      -------
          polygon objectness
      """
      h, w = pred.shape[:2]
  
      if assume_straight_pages:
          xmin = np.clip(
              np.floor(points[:, 0].min()).astype(np.int32), 0, w - 1
          )
          xmax = np.clip(
              np.ceil(points[:, 0].max()).astype(np.int32), 0, w - 1
          )
          ymin = np.clip(
              np.floor(points[:, 1].min()).astype(np.int32), 0, h - 1
          )
          ymax = np.clip(
              np.ceil(points[:, 1].max()).astype(np.int32), 0, h - 1
          )
          return pred[ymin : ymax + 1, xmin : xmax + 1].mean()
  
      else:
          mask: np.ndarray = np.zeros((h, w), np.int32)
          cv2.fillPoly(mask, [points.astype(np.int32)], 1.0)  # type: ignore[call-overload]
          product = pred * mask
          return np.sum(product) / np.count_nonzero(product)
  
file_path: doctr/doctr/models/detection/core.py
imports: from typing import List
  import cv2
  import numpy
  from doctr.utils.repr import NestedObject
label_desc: Use image node_id 3 for calling the DetectionPostProcessor obj's underlying member method code with example usage: obj.box_score(pred, points, assume_straight_pages) and returns: pred, unknown