class_docstr: Implements an object able to localize and identify text elements in a set of documents
  
  Args:
  ----
      det_predictor: detection module
      reco_predictor: recognition module
      assume_straight_pages: if True, speeds up the inference by assuming you only pass straight pages
          without rotated textual elements.
      straighten_pages: if True, estimates the page general orientation based on the median line orientation.
          Then, rotates page before passing it to the deep learning modules. The final predictions will be remapped
          accordingly. Doing so will improve performances for documents with page-uniform rotations.
      detect_orientation: if True, the estimated general page orientation will be added to the predictions for each
          page. Doing so will slightly deteriorate the overall latency.
      detect_language: if True, the language prediction will be added to the predictions for each
          page. Doing so will slightly deteriorate the overall latency.
      **kwargs: keyword args of `DocumentBuilder`
class_docstr_tok: ["Implements","an","object","able","to","localize","and","identify","text","elements","in","a","set","of","documents","Args",":","--","--","det_predictor",":","detection","module","reco_predictor",":","recognition","module","assume_straight_pages",":","if","True",",","speeds","up","the","inference","by","assuming","you","only","pass","straight","pages","without","rotated","textual","elements",".","straighten_pages",":","if","True",",","estimates","the","page","general","orientation","based","on","the","median","line","orientation",".","Then",",","rotates","page","before","passing","it","to","the","deep","learning","modules",".","The","final","predictions","will","be","remapped","accordingly",".","Doing","so","will","improve","performances","for","documents","with","page-uniform","rotations",".","detect_orientation",":","if","True",",","the","estimated","general","page","orientation","will","be","added","to","the","predictions","for","each","page",".","Doing","so","will","slightly","deteriorate","the","overall","latency",".","detect_language",":","if","True",",","the","language","prediction","will","be","added","to","the","predictions","for","each","page",".","Doing","so","will","slightly","deteriorate","the","overall","latency",".","*","*","kwargs",":","keyword","args","of","`","DocumentBuilder","`"]
code: def __call__(
      self,
      pages: List[Union[np.ndarray, tf.Tensor]],
      **kwargs: Any,
  ) -> Document:
      # Dimension check
      if any(page.ndim != 3 for page in pages):
          raise ValueError(
              "incorrect input shape: all pages are expected to be multi-channel 2D images."
          )
  
      origin_page_shapes = [page.shape[:2] for page in pages]
  
      # Localize text elements
      loc_preds_dict, out_maps = self.det_predictor(
          pages, return_maps=True, **kwargs
      )
  
      # Detect document rotation and rotate pages
      seg_maps = [
          np.where(
              out_map
              > getattr(
                  self.det_predictor.model.postprocessor, "bin_thresh"
              ),
              255,
              0,
          ).astype(np.uint8)
          for out_map in out_maps
      ]
      if self.detect_orientation:
          origin_page_orientations = [
              estimate_orientation(seq_map) for seq_map in seg_maps
          ]
          orientations = [
              {"value": orientation_page, "confidence": None}
              for orientation_page in origin_page_orientations
          ]
      else:
          orientations = None
      if self.straighten_pages:
          origin_page_orientations = (
              origin_page_orientations
              if self.detect_orientation
              else [
                  estimate_orientation(seq_map) for seq_map in seg_maps
              ]
          )
          pages = [
              rotate_image(page, -angle, expand=False)
              for page, angle in zip(pages, origin_page_orientations)
          ]
          # forward again to get predictions on straight pages
          loc_preds_dict = self.det_predictor(pages, **kwargs)  # type: ignore[assignment]
  
      assert all(
          len(loc_pred) == 1 for loc_pred in loc_preds_dict
      ), "Detection Model in ocr_predictor should output only one class"
      loc_preds: List[np.ndarray] = [list(loc_pred.values())[0] for loc_pred in loc_preds_dict]  # type: ignore[union-attr]
  
      # Rectify crops if aspect ratio
      loc_preds = self._remove_padding(pages, loc_preds)
  
      # Crop images
      crops, loc_preds = self._prepare_crops(
          pages,
          loc_preds,
          channels_last=True,
          assume_straight_pages=self.assume_straight_pages,
      )
      # Rectify crop orientation
      if not self.assume_straight_pages:
          crops, loc_preds = self._rectify_crops(crops, loc_preds)
  
      # Identify character sequences
      word_preds = self.reco_predictor(
          [crop for page_crops in crops for crop in page_crops],
          **kwargs,
      )
  
      boxes, text_preds = self._process_predictions(
          loc_preds, word_preds
      )
  
      if self.detect_language:
          languages = [
              get_language(" ".join([item[0] for item in text_pred]))
              for text_pred in text_preds
          ]
          languages_dict = [
              {"value": lang[0], "confidence": lang[1]}
              for lang in languages
          ]
      else:
          languages_dict = None
  
      out = self.doc_builder(
          pages,
          boxes,
          text_preds,
          origin_page_shapes,  # type: ignore[arg-type]
          orientations,
          languages_dict,
      )
      return out
  
file_path: doctr/doctr/models/predictor/tensorflow.py
imports: from typing import Any, List, Union
  import numpy
  import tensorflow
  from doctr.io.elements import Document
  from doctr.models._utils import estimate_orientation, get_language
  from doctr.models.detection.predictor import DetectionPredictor
  from doctr.models.recognition.predictor import RecognitionPredictor
  from doctr.utils.geometry import rotate_image
  from doctr.utils.repr import NestedObject
  from .base import _OCRPredictor
label_desc: Use image node_id 2 for calling the OCRPredictor obj's underlying member method code with example usage: obj.__call__(pages) and returns: out