class_docstr: Implements common confusion metrics and mean IoU for localization evaluation.
  
  The aggregated metrics are computed as follows:
  
  .. math::
      \forall Y \in \mathcal{B}^N, \forall X \in \mathcal{B}^M, \\
      Recall(X, Y) = \frac{1}{N} \sum\limits_{i=1}^N g_{X}(Y_i) \\
      Precision(X, Y) = \frac{1}{M} \sum\limits_{i=1}^M g_{X}(Y_i) \\
      meanIoU(X, Y) = \frac{1}{M} \sum\limits_{i=1}^M \max\limits_{j \in [1, N]}  IoU(X_i, Y_j)
  
  with the function :math:`IoU(x, y)` being the Intersection over Union between bounding boxes :math:`x` and
  :math:`y`, and the function :math:`g_{X}` defined as:
  
  .. math::
      \forall y \in \mathcal{B},
      g_X(y) = \left\{
          \begin{array}{ll}
              1 & \mbox{if } y\mbox{ has been assigned to any }(X_i)_i\mbox{ with an }IoU \geq 0.5 \\
              0 & \mbox{otherwise.}
          \end{array}
      \right.
  
  where :math:`\mathcal{B}` is the set of possible bounding boxes,
  :math:`N` (number of ground truths) and :math:`M` (number of predictions) are strictly positive integers.
  
  >>> import numpy as np
  >>> from doctr.utils import LocalizationConfusion
  >>> metric = LocalizationConfusion(iou_thresh=0.5)
  >>> metric.update(np.asarray([[0, 0, 100, 100]]), np.asarray([[0, 0, 70, 70], [110, 95, 200, 150]]))
  >>> metric.summary()
  
  Args:
  ----
      iou_thresh: minimum IoU to consider a pair of prediction and ground truth as a match
      use_polygons: if set to True, predictions and targets will be expected to have rotated format
      mask_shape: if use_polygons is True, describes the spatial shape of the image used
      use_broadcasting: if use_polygons is True, use broadcasting for IoU computation by consuming more memory
class_docstr_tok: ["Implements","common","confusion","metrics","and","mean","IoU","for","localization","evaluation",".","The","aggregated","metrics","are","computed","as","follows",":","..","math",":",":","\\forall","Y","\\in","\\mathcal","{","B","}","^N",",","\\forall","X","\\in","\\mathcal","{","B","}","^M",",","\\\\","Recall","(","X",",","Y",")","=","\\frac","{","1","}","{","N","}","\\sum\\limits_","{","i=1","}","^N","g_","{","X","}","(","Y_i",")","\\\\","Precision","(","X",",","Y",")","=","\\frac","{","1","}","{","M","}","\\sum\\limits_","{","i=1","}","^M","g_","{","X","}","(","Y_i",")","\\\\","meanIoU","(","X",",","Y",")","=","\\frac","{","1","}","{","M","}","\\sum\\limits_","{","i=1","}","^M","\\max\\limits_","{","j","\\in","[","1",",","N","]","}","IoU","(","X_i",",","Y_j",")","with","the","function",":","math",":","`","IoU","(","x",",","y",")","`","being","the","Intersection","over","Union","between","bounding","boxes",":","math",":","`","x","`","and",":","math",":","`","y","`",",","and","the","function",":","math",":","`","g_","{","X","}","`","defined","as",":","..","math",":",":","\\forall","y","\\in","\\mathcal","{","B","}",",","g_X","(","y",")","=","\\left\\","{","\\begin","{","array","}","{","ll","}","1","&","\\mbox","{","if","}","y\\mbox","{","has","been","assigned","to","any","}","(","X_i",")","_i\\mbox","{","with","an","}","IoU","\\geq","0.5","\\\\","0","&","\\mbox","{","otherwise",".","}","\\end","{","array","}","\\right",".","where",":","math",":","`","\\mathcal","{","B","}","`","is","the","set","of","possible","bounding","boxes",",",":","math",":","`","N","`","(","number","of","ground","truths",")","and",":","math",":","`","M","`","(","number","of","predictions",")","are","strictly","positive","integers",".",">",">",">","import","numpy","as","np",">",">",">","from","doctr.utils","import","LocalizationConfusion",">",">",">","metric","=","LocalizationConfusion","(","iou_thresh=0.5",")",">",">",">","metric.update","(","np.asarray","(","[","[","0",",","0",",","100",",","100","]","]",")",",","np.asarray","(","[","[","0",",","0",",","70",",","70","]",",","[","110",",","95",",","200",",","150","]","]",")",")",">",">",">","metric.summary","(",")","Args",":","--","--","iou_thresh",":","minimum","IoU","to","consider","a","pair","of","prediction","and","ground","truth","as","a","match","use_polygons",":","if","set","to","True",",","predictions","and","targets","will","be","expected","to","have","rotated","format","mask_shape",":","if","use_polygons","is","True",",","describes","the","spatial","shape","of","the","image","used","use_broadcasting",":","if","use_polygons","is","True",",","use","broadcasting","for","IoU","computation","by","consuming","more","memory"]
docstr: Computes the aggregated metrics
  
  Returns
  -------
      a tuple with the recall, precision and meanIoU scores
docstr_tok: ["Computes","the","aggregated","metrics","Returns","--","--","--","-","a","tuple","with","the","recall",",","precision","and","meanIoU","scores"]
code: def summary(
      self,
  ) -> Tuple[Optional[float], Optional[float], Optional[float]]:
      """Computes the aggregated metrics
  
      Returns
      -------
          a tuple with the recall, precision and meanIoU scores
      """
      # Recall
      recall = self.matches / self.num_gts if self.num_gts > 0 else None
  
      # Precision
      precision = (
          self.matches / self.num_preds if self.num_preds > 0 else None
      )
  
      # mean IoU
      mean_iou = (
          self.tot_iou / self.num_preds if self.num_preds > 0 else None
      )
  
      return recall, precision, mean_iou
  
imports: from typing import Dict, List, Optional, Tuple
  import cv2
  import numpy
  from scipy.optimize import linear_sum_assignment
  from unidecode import unidecode
label_desc: Use image node_id 3 for calling the LocalizationConfusion obj's underlying member method code with example usage: obj.summary() and returns: recall,  precision,  mean_iou