layout-parser
layout-parser copied to clipboard
Detectron2LayoutModel requires the detectron2 library but it was not found in your environment.
Describe the bug A clear and concise description of what the bug is.
Checklist
- I have searched related issues but cannot get the expected help.
- The bug has not been fixed in the latest version, see the Layout Parser Releases
To Reproduce Steps to reproduce the behavior:
- What command or script did you run?
A placeholder for the command.
Environment
- Please describe your Platform [Windows/MacOS/Linux]
- Please show the Layout Parser version
- 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
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
I'm facing the same issue.
facing the same issue
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