Ikomia HUB
infer_document_orientation

infer_document_orientation

About

1.0.0
Apache-2.0

Classify document image orientation as 0, 90, 180, or 270 degrees

Task: Classification
PaddleOCR
document
orientation
rotation
classification
OCR

This Ikomia plugin uses PaddleOCR's PP-LCNet_x1_0_doc_ori model to classify a document image into one of four clockwise orientation classes: 0, 90, 180, or 270 degrees.

Use with Ikomia API

Install Ikomia API

We recommend using a virtual environment.

pip install ikomia

Create a workflow

from ikomia.dataprocess.workflow import Workflow

wf = Workflow()
orientation = wf.add_task(
name="infer_document_orientation",
auto_connect=True,
)

wf.run_on(
url=(
"https://paddle-model-ecology.bj.bcebos.com/paddlex/"
"imgs/demo_image/img_rot180_demo.jpg"
)
)

display(orientation.get_image_with_graphics())
display(orientation.get_output(4).get_image())

Parameters

  • model_name: PaddleOCR model name. Defaults to PP-LCNet_x1_0_doc_ori.
  • cuda: use GPU 0 when enabled and the installed PaddlePaddle build supports CUDA. Defaults to False.
  • enable_mkldnn: enable PaddlePaddle MKL-DNN CPU acceleration.
  • cpu_threads: number of inference threads used on CPU. Defaults to 10.
  • auto_rotate: rotate the second image output to an upright orientation using the predicted class. Defaults to False.
orientation.set_parameters(
{
"model_name": "PP-LCNet_x1_0_doc_ori",
"cuda": "False",
"enable_mkldnn": "True",
"cpu_threads": "10",
"auto_rotate": "True",
}
)

Note: for GPU inference, replace the CPU paddlepaddle package with the appropriate paddlepaddle-gpu build for your CUDA environment, following PaddlePaddle's installation guide.

Output

Output 0 contains the predicted orientation label and its confidence score. The labels match PaddleOCR's four model categories:

Class IDLabel
0
190°
2180°
3270°

Output 4 contains an image. When auto_rotate is enabled for whole-image classification, it is rotated to an upright orientation using PaddleX's counter-clockwise correction convention. Otherwise, it is an unchanged pass-through image.

References

  • PaddleOCR document image orientation classification module
  • PaddleOCR repository

Developer

  • Ikomia
    Ikomia

License

Apache License 2.0
Read license full text

A permissive license whose main conditions require preservation of copyright and license notices. Contributors provide an express grant of patent rights. Licensed works, modifications, and larger works may be distributed under different terms and without source code.

PermissionsConditionsLimitations

Commercial use

License and copyright notice

Trademark use

Modification

State changes

Liability

Distribution

Warranty

Patent use

Private use

This is not legal advice: this description is for informational purposes only and does not constitute the license itself. Provided by choosealicense.com.