Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pilipentseva opened this issue Jun 8, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@pilipentseva
Copy link

pilipentseva commented Jun 8, 2023

I have Windows and went through installation as suggested by @ivanpp for installing Detectron2 on Windows: Detectron2 walkthrough (Windows).

I write a code in jupyter notebook. If I change directory to where I installed detectron2 as mentioned above, import detectron2 and import layoutparser runs. However, I still get an error. Why so?

import detectron2
import layoutparser

model = lp.Detectron2LayoutModel('lp://PubLayNet/mask_rcnn_X_101_32x8d_FPN_3x/config',
                                 extra_config=["MODEL.ROI_HEADS.SCORE_THRESH_TEST", 0.5],
                                 label_map={0: "Text", 1: "Title", 2: "List", 3:"Table", 4:"Figure"})

or

model = lp.models.Detectron2LayoutModel('lp://PubLayNet/mask_rcnn_X_101_32x8d_FPN_3x/config',
                                 extra_config=["MODEL.ROI_HEADS.SCORE_THRESH_TEST", 0.5],
                                 label_map={0: "Text", 1: "Title", 2: "List", 3:"Table", 4:"Figure"})

ImportError Traceback (most recent call last)
Cell In[53], line 1
----> 1 model = lp.models.Detectron2LayoutModel(config_path ='lp://PubLayNet/faster_rcnn_R_50_FPN_3x/config')

File C:\anaconda\lib\site-packages\layoutparser\models\base_layoutmodel.py:87, in BaseLayoutModel.new(cls, *args, **kwargs)
85 def new(cls, *args, **kwargs):
---> 87 requires_backends(cls, cls.DEPENDENCIES)
88 return super().new(cls)

File C:\anaconda\lib\site-packages\layoutparser\file_utils.py:175, 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'

P.S. I also tried on Colab and same issue

@pilipentseva pilipentseva added the bug Something isn't working label Jun 8, 2023
@mmervecerit
Copy link

having the same issue.

@biographie
Copy link

having the same issues as well, any potential of fixing this?

@PatrickGold555
Copy link

Having the same issue, however i installed detectron2 differently as described in the LayoutParser documentation. i would not get detectron installed the default way. when i try install detectron i get the following error:

ERROR: Failed building wheel for detectron2
Running setup.py clean for detectron2
Failed to build detectron2
ERROR: Could not build wheels for detectron2, which is required to install pyproject.toml-based projects

@maxycn
Copy link

maxycn commented May 7, 2024

I'm using MacOS M3 and able to successfully install detectron2 through Anaconda.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants