Skip to content

Latest commit

 

History

History
70 lines (46 loc) · 5.43 KB

installation.md

File metadata and controls

70 lines (46 loc) · 5.43 KB

Installation

Install Python

LayoutParser is a Python package that requires Python >= 3.6. If you do not have Python installed on your computer, you might want to turn to the official instruction to download and install the appropriate version of Python.

Install the LayoutParser library

After several major updates, LayoutParser provides various functionalities and deep learning models from different backends. However, you might only need a fraction of the functions, and it would be redundant for you to install all the dependencies when they are not required. Therefore, we design highly customizable ways for installing the LayoutParser library:

Command Description
pip install layoutparser Install the base LayoutParser Library
It will support all key functions in LayoutParser, including:
1. Layout Data Structure and operations
2. Layout Visualization
3. Load/export the layout data
pip install "layoutparser[effdet]" Install LayoutParser with Layout Detection Model Support
It will install the LayoutParser base library as well as
supporting dependencies for the EfficientDet-based layout detection models.
pip install layoutparser torchvision && pip install "git+https://github.com/facebookresearch/detectron2.git@v0.5#egg=detectron2" Install LayoutParser with Layout Detection Model Support
It will install the LayoutParser base library as well as
supporting dependencies for the Detectron2-based layout detection models. See details in Additional Instruction: Install Detectron2 Layout Model Backend.
pip install "layoutparser[paddledetection]" Install LayoutParser with Layout Detection Model Support
It will install the LayoutParser base library as well as
supporting dependencies for the PaddleDetection-based layout detection models.
pip install "layoutparser[ocr]" Install LayoutParser with OCR Support
It will install the LayoutParser base library as well as
supporting dependencies for performing OCRs. See details in Additional Instruction: Install OCR utils.

Additional Instruction: Install Detectron2 Layout Model Backend

For Mac OS and Linux Users

If you would like to use the Detectron2 models for layout detection, you might need to run the following command:

pip install layoutparser torchvision && pip install "detectron2@git+https://github.com/facebookresearch/detectron2.git@v0.5#egg=detectron2"

This might take some time as the command will compile the library. If you also want to install a Detectron2 version with GPU support or encounter some issues during the installation process, please refer to the official Detectron2 installation instruction for detailed information.

For Windows users

As reported by many users, the installation of Detectron2 can be rather tricky on Windows platforms. In our extensive tests, we find that it is nearly impossible to provide a one-line installation command for Windows users. As a workaround solution, for now we list the possible challenges for installing Detectron2 on Windows, and attach helpful resources for solving them. We are also investigating other possibilities to avoid installing Detectron2 to use pre-trained models. If you have any suggestions or ideas, please feel free to submit an issue in our repo.

  1. Challenges for installing pycocotools
  2. Challenges for installing Detectron2
    • @ivanpp curates a detailed description for installing Detectron2 on Windows: Detectron2 walkthrough (Windows)
    • Detectron2 maintainers claim that they won't provide official support for Windows (see 1 and 2), but Detectron2 is continuously built on windows with CircleCI (see 3). Hopefully this situation will be improved in the future.

Additional Instructions: Install OCR utils

Layout Parser also comes with supports for OCR functions. In order to use them, you need to install the OCR utils via:

pip install "layoutparser[ocr]"

Additionally, if you want to use the Tesseract-OCR engine, you also need to install it on your computer. Please check the official documentation for detailed installation instructions.

Known issues

Error: instantiating `lp.GCVAgent.with_credential` returns module 'google.cloud.vision' has no attribute 'types'.

In this case, you have a newer version of the google-cloud-vision. Please consider downgrading the API using:

pip install -U layoutparser[ocr]