@@ -146,4 +146,31 @@ When you run this for the first time, it will download the pretrained model weig
146146Alternatively you can download or use your own pretrained model weights as well.
147147For more info on this see Huggingface `transformers <https://huggingface.co/docs/transformers/index >`_ library documentation.
148148
149- For more information on the default model and the categories it classifies to, please refer `ocrpy.experimental.document_classifier `.
149+ For more information on the default model and the categories it classifies to, please refer `ocrpy.experimental.document_classifier `.
150+
151+ Parse layout with ``ocrpy.experimental.layout_parser ``
152+ ---------------------------------------------------
153+
154+ In this example let's look at how you can use ``ocrpy `` to parse layout from a document using the
155+ ``ocrpy.experimental.layout_parser `` API.
156+
157+ .. code-block :: python
158+
159+ from ocrpy import DocumentReader, TextParser
160+ from ocrpy.experimental import LayoutParser
161+
162+ DOC_PATH = ' ../documents/document.img' # path to an image or pdf file on s3 bucket, gcs bucket or local directory.
163+
164+ reader = DocumentReader(file = DOC_PATH )
165+ text_parser = TextParser()
166+ layout_parser = LayoutParser()
167+
168+ parsed_layout = layout_parser.parse(reader, text_parser)
169+
170+ .. note :: ``ocrpy`` uses Microsoft's LayoutParser library in the backend to perform the layout parsing.
171+ as such, please make sure you have the ``layoutparser `` library installed, if not please install it from
172+ `LayoutParser <https://github.com/Layout-Parser/layout-parser >`_.
173+
174+ When you run this for the first time, it will download the pretrained model weights and store them in a local directory.
175+ Alternatively you can download or use your own pretrained model weights as well. The model weights can be downloaded from
176+ `LayoutParser Model Catalog <https://layout-parser.readthedocs.io/en/latest/notes/modelzoo.html#model-catalog >`_.
0 commit comments