`use_angle_cls` and `cls` arguments in PaddleOCR

4.5k Views Asked by At

I want to use PaddleOCR for my text detection and recognition task. But I couldn't find enough documentation about why they have used the arguments use_angle_cls and cls. The following code illustrates the text image inference in PaddleOCR.

from paddleocr import PaddleOCR
ocr = PaddleOCR(use_angle_cls=True, lang='en')
img_path = './imgs_en/img_12.jpg'
result = ocr.ocr(img_path, cls=True)

In line 2 they used use_angle_cls=True argument while initializing the OCR engine and cls=True argument in line 4 while detection and recognition. So what is the meaning behind these arguments? Thank you!

1

There are 1 best solutions below

0
On

From the python file docs (https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.6/paddleocr.py#L505, thanks to the comment from 219CID):

cls: use angle classifier or not. Default is True. If true, the text with rotation of 180 degrees can be recognized. If no text is rotated by 180 degrees, use cls=False to get better performance. Text with rotation of 90 or 270 degrees can be recognized even if cls=False.

So it appears setting it to true allows you to recognize upside down text, and that even with cls being false it can recognize sideways text.