lab9/text_recognizer/paragraph_text_recognizer.py
def predict(self, image: Union[str, Path, Image.Image]) -> str:
        """Predict/infer text in input image (which can be a file path)."""
        image_pil = image
        if not isinstance(image, Image.Image):
            image_pil = util.read_image_pil(image, grayscale=True)

        image_pil = resize_image(image_pil, IMAGE_SCALE_FACTOR)
        image_tensor = self.transform(image_pil)

        y_pred = self.scripted_model(image_tensor.unsqueeze(axis=0))[0]
        pred_str = convert_y_label_to_string(y=y_pred, mapping=self.mapping, ignore_tokens=self.ignore_tokens)

        return pred_str
Predict/infer text in input image (which can be a file path).
Predict/infer text in input image (which can be a file path).
Predict / infer text in input image ( which can be a file path ) .
def predict(self, image: Union[str, Path, Image.Image]) -> str:
        image_pil = image
        if not isinstance(image, Image.Image):
            image_pil = util.read_image_pil(image, grayscale=True)
        image_pil = resize_image(image_pil, IMAGE_SCALE_FACTOR)
        image_tensor = self.transform(image_pil)
        y_pred = self.scripted_model(image_tensor.unsqueeze(axis=0))[0]
        pred_str = convert_y_label_to_string(y=y_pred, mapping=self.mapping, ignore_tokens=self.ignore_tokens)
        return pred_str
def predict ( self , image : Union [ str , Path , Image . Image ] ) -> str : image_pil = image if not isinstance ( image , Image . Image ) : image_pil = util . read_image_pil ( image , grayscale = True ) image_pil = resize_image ( image_pil , IMAGE_SCALE_FACTOR ) image_tensor = self . transform ( image_pil ) y_pred = self . scripted_model ( image_tensor . unsqueeze ( axis = 0 ) ) [ 0 ] pred_str = convert_y_label_to_string ( y = y_pred , mapping = self . mapping , ignore_tokens = self . ignore_tokens ) return pred_str
Predict/infer text in input image (which can be a file path).
Predict / infer text in input image ( which can be a file path ) .
"""Predict/infer text in input image (which can be a file path)."""
self
image
Union[str, Path, Image.Image]