Layout Parser 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.
Installing the Layout Parser library is very straightforward: you just need to run the following command:
pip3 install -U layoutparserIf you would like to use deep learning models for layout detection, you also need to install Detectron2 on your computer. This could be done by running the following command:
pip3 install 'git+https://github.com/facebookresearch/detectron2.git@v0.4#egg=detectron2' This might take some time as the command will compile the library. You might 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.
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.
- Challenges for installing
pycocotools- You can find detailed instructions on this post from Chang Hsin Lee.
- Another solution is try to install
pycocotools-windows, see cocodataset/cocoapi#415.
- Challenges for installing
Detectron2- @ivanpp curates a detailed description for installing
Detectron2on Windows: Detectron2 walkthrough (Windows) Detectron2maintainers 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.
- @ivanpp curates a detailed description for installing
If you would like to use PaddleDetection deep learning models for layout detection, you also need to install paddle on your computer. This could be done by running the following command:
# CPU version
python -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simpleIf you would like to use PaddlePaddle GPU version to predict, you need to uninstall paddlepaddle first, and running the following conmand:
# If you already have installed the CPU version paddle
pip uninstall paddlepaddle
# GPU version
python -m pip install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simpleThis could be done by running the following command:
python -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple- For more CUDA version or environment to quick install, please refer to the PaddlePaddle Quick Installation document
- For more installation methods such as conda or compile with source code, please refer to the installation document
Please make sure that your PaddlePaddle is installed successfully and the version is not lower than the required version. Use the following command to verify.
# check
>>> import paddle
>>> paddle.utils.run_check()
# confirm the paddle's version
python -c "import paddle; print(paddle.__version__)"Layout Parser also comes with supports for OCR functions. In order to use them, you need to install the OCR utils via:
pip3 install -U 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.
Layout Parser also comes with supports for PaddleOCR functions. In order to use them, you need to install the PaddleOCR utils via:
pip3 install -U layoutparser[paddleocr]. Please check the official documentation for detailed installation instructions.
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 layoutparser[ocr]