Layout-Parser / layout-parser

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

Detectron2LayoutModel requires the detectron2 library but it was not found in your environment. #169

Open wshzd opened 1 year ago

wshzd commented 1 year ago

Describe the bug A clear and concise description of what the bug is.

Checklist

  1. I have searched related issues but cannot get the expected help.
  2. The bug has not been fixed in the latest version, see the Layout Parser Releases

To Reproduce Steps to reproduce the behavior:

  1. What command or script did you run?
    A placeholder for the command.

Environment

  1. Please describe your Platform [Windows/MacOS/Linux]
  2. Please show the Layout Parser version
  3. You may add addition that may be helpful for locating the problem, such as
    • How you installed PyTorch [e.g., pip, conda, source]
    • Other environment variables that may be related (such as $PATH, $LD_LIBRARY_PATH, $PYTHONPATH, etc.)

Error traceback If applicable, paste the error traceback here. l run the code as follows: model = lp.models.Detectron2LayoutModel('lp://PubLayNet/faster_rcnn_R_50_FPN_3x/config', extra_config=["MODEL.ROI_HEADS.SCORE_THRESH_TEST", 0.8],label_map={0: "Text", 1: "Title", 2: "List", 3:"Table", 4:"Figure"})

the error as follows:

ImportError Traceback (most recent call last) /tmp/ipykernel_17039/2299831570.py in ----> 1 model = lp.models.Detectron2LayoutModel('lp://PubLayNet/faster_rcnn_R_50_FPN_3x/config', extra_config=["MODEL.ROI_HEADS.SCORE_THRESH_TEST", 0.8],label_map={0: "Text", 1: "Title", 2: "List", 3:"Table", 4:"Figure"})

xxx/layoutparser/models/base_layoutmodel.py in new(cls, *args, *kwargs) 85 def new(cls, args, **kwargs): 86 ---> 87 requires_backends(cls, cls.DEPENDENCIES) 88 return super().new(cls)

xxx/layoutparser/file_utils.py in requires_backends(obj, backends) 173 name = obj.name if hasattr(obj, "name") else obj.class.name 174 if not all(BACKENDS_MAPPING[backend][0]() for backend in backends): --> 175 raise ImportError( 176 "".join([BACKENDS_MAPPING[backend][1].format(name) for backend in backends]) 177 ) ImportError: Detectron2LayoutModel requires the detectron2 library but it was not found in your environment. Checkout the instructions on the installation page: https://github.com/facebookresearch/detectron2/blob/master/INSTALL.md and follow the ones that match your environment. Typically the following would work for MacOS or Linux CPU machines: pip install 'git+https://github.com/facebookresearch/detectron2.git@v0.4#egg=detectron2'

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

l have installed the detectron2 refer to the code of pip install 'git+https://github.com/facebookresearch/detectron2.git@v0.4#egg=detectron2'

but, the error always occures

Akash-Ram commented 1 year ago

I'm facing the same issue.

yenicelik commented 11 months ago

facing the same issue

prabhumane commented 7 months ago

Please restart runtime with this command for installation: pip install layoutparser torchvision && pip install "detectron2@git+https://github.com/facebookresearch/detectron2.git@v0.5#egg=detectron2"

for more details go to: https://github.com/Layout-Parser/layout-parser/blob/main/installation.md#additional-instruction-install-detectron2-layout-model-backend