class_docstr: A text detector using the CRNN architecture.
  
  Args:
      alphabet: The alphabet the model should recognize.
      build_params: A dictionary of build parameters for the model.
          See `keras_ocr.recognition.build_model` for details.
      weights: The starting weight configuration for the model.
      include_top: Whether to include the final classification layer in the model (set
          to False to use a custom alphabet).
class_docstr_tok: ["A","text","detector","using","the","CRNN","architecture",".","Args",":","alphabet",":","The","alphabet","the","model","should","recognize",".","build_params",":","A","dictionary","of","build","parameters","for","the","model",".","See","`","keras_ocr.recognition.build_model","`","for","details",".","weights",":","The","starting","weight","configuration","for","the","model",".","include_top",":","Whether","to","include","the","final","classification","layer","in","the","model","(","set","to","False","to","use","a","custom","alphabet",")","."]
docstr: Recognize text from a single image.
  
  Args:
      image: A pre-cropped image containing characters
docstr_tok: ["Recognize","text","from","a","single","image",".","Args",":","image",":","A","pre-cropped","image","containing","characters"]
code: def recognize(self, image):
      """Recognize text from a single image.
  
      Args:
          image: A pre-cropped image containing characters
      """
      image = tools.read_and_fit(
          filepath_or_array=image,
          width=self.prediction_model.input_shape[2],
          height=self.prediction_model.input_shape[1],
          cval=0,
      )
      if (
          self.prediction_model.input_shape[-1] == 1
          and image.shape[-1] == 3
      ):
          # Convert color to grayscale
          image = cv2.cvtColor(image, code=cv2.COLOR_RGB2GRAY)[
              ..., np.newaxis
          ]
      image = image.astype("float32") / 255
      return "".join(
          [
              self.alphabet[idx]
              for idx in self.prediction_model.predict(
                  image[np.newaxis]
              )[0]
              if idx not in [self.blank_label_idx, -1]
          ]
      )
  
file_path: keras-ocr/keras_ocr/recognition.py
imports: import typing
  import string
  import tensorflow
  from tensorflow import keras
  import numpy
  import cv2
  from .None import tools
label_desc: Use image node_id 3 for calling the Recognizer obj's underlying member method code with example usage: obj.recognize(image) and returns: str