layout-parser icon indicating copy to clipboard operation
layout-parser copied to clipboard

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

Open wshzd opened this issue 2 years ago • 3 comments

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/[email protected]#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/[email protected]#egg=detectron2'

but, the error always occures

wshzd avatar Feb 01 '23 11:02 wshzd

I'm facing the same issue.

Akash-Ram avatar Mar 17 '23 09:03 Akash-Ram

facing the same issue

yenicelik avatar Oct 31 '23 08:10 yenicelik

Please restart runtime with this command for installation: pip install layoutparser torchvision && pip install "detectron2@git+https://github.com/facebookresearch/[email protected]#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

prabhumane avatar Feb 29 '24 21:02 prabhumane