Optical Character Recognition

OCR related modeling class

class pororo.tasks.optical_character_recognition.PororoOcrFactory(task: str, lang: str, model: Optional[str])[source]

Bases: pororo.tasks.utils.base.PororoFactoryBase

Recognize optical characters in image file Currently support Korean language

English + Korean (brainocr)

Examples

>>> ocr = Pororo(task="ocr", lang="ko")
>>> ocr(IMAGE_PATH)
["사이렌'(' 신마'", "내가 말했잖아 속지열라고 이 손을 잡는 너는 위협해질 거라고"]
>>> ocr = Pororo(task="ocr", lang="ko")
>>> ocr(IMAGE_PATH, detail=True)
{
    'description': ["사이렌'(' 신마', "내가 말했잖아 속지열라고 이 손을 잡는 너는 위협해질 거라고"],
    'bounding_poly': [
        {
            'description': "사이렌'(' 신마'",
            'vertices': [
                {'x': 93, 'y': 7},
                {'x': 164, 'y': 7},
                {'x': 164, 'y': 21},
                {'x': 93, 'y': 21}
            ]
        },
        {
            'description': "내가 말했잖아 속지열라고 이 손을 잡는 너는 위협해질 거라고",
            'vertices': [
                {'x': 0, 'y': 30},
                {'x': 259, 'y': 30},
                {'x': 259, 'y': 194},
                {'x': 0, 'y': 194}]}
            ]
        }
}
static get_available_langs()[source]
static get_available_models()[source]
load(device: str)[source]

Load user-selected task-specific model

Parameters

device (str) – device information

Returns

User-selected task-specific model

Return type

object

class pororo.tasks.optical_character_recognition.PororoOCR(model, config)[source]

Bases: pororo.tasks.utils.base.PororoSimpleBase

predict(image_path: str, **kwargs)[source]

Conduct Optical Character Recognition (OCR)

Parameters
  • image_path (str) – the image file path

  • detail (bool) – if True, returned to include details. (bounding poly, vertices, etc)