Layout-Parser / layout-parser

A Unified Toolkit for Deep Learning Based Document Image Analysis
https://layout-parser.github.io/
Apache License 2.0
4.75k stars 456 forks source link

AttributeError: module layoutparser has no attribute PaddleDetectionLayoutModel #107

Closed chiehpower closed 2 years ago

chiehpower commented 2 years ago

Describe the bug

Cannot pass the line of lp.PaddleDetectionLayoutModel

Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> import layoutparser as lp
>>>  model = lp.PaddleDetectionLayoutModel(config_path="lp://PubLayNet/ppyolov2_r50vd_dcn_365e_publaynet/config",
...                                 threshold=0.5,
...                                 label_map={0: "Text", 1: "Title", 2: "List", 3:"Table", 4:"Figure"},
...                                 enforce_cpu=False,
...                                 enable_mkldnn=True)
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/usr/local/lib/python3.6/dist-packages/layoutparser/file_utils.py", line 226, in __getattr__
    raise AttributeError(f"module {self.__name__} has no attribute {name}")
AttributeError: module layoutparser has no attribute PaddleDetectionLayoutModel

To Reproduce Steps to reproduce the behavior:

Follow the step from official sample https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.3/ppstructure/layout/README.md#2-quick-start

Environment

  1. Please describe your Platform [Windows/MacOS/Linux] Linux. AGX jetson device, JetPack4.6
  2. Please show the Layout Parser version : layoutparser 0.3.2
  3. You may add addition that may be helpful for locating the problem, such as
    • How you installed PyTorch [e.g., pip, conda, source] pip to install torch. Haven tried by Python3.8 and Python3.6
    • Other environment variables that may be related (such as $PATH, $LD_LIBRARY_PATH, $PYTHONPATH, etc.)
chiehpower commented 2 years ago

Fixed it by installing the layoutparser package below:

wget https://paddleocr.bj.bcebos.com/whl/layoutparser-0.0.0-py3-none-any.whl
pip install -U layoutparser-0.0.0-py3-none-any.whl