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

Detectron2 Installation issue #218

Open
bankyresearch opened this issue Oct 14, 2024 · 2 comments
Open

Detectron2 Installation issue #218

bankyresearch opened this issue Oct 14, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@bankyresearch
Copy link


AttributeError Traceback (most recent call last)
in <cell line: 2>()
1 import layoutparser as lp
----> 2 model = lp.Detectron2LayoutModel('lp://HJDataset/faster_rcnn_R_50_FPN_3x/config')
3 model.detect(image)

/usr/local/lib/python3.10/dist-packages/layoutparser/file_utils.py in getattr(self, name)

AttributeError: module layoutparser has no attribute Detectron2LayoutModel

on Google colab

@bankyresearch bankyresearch added the bug Something isn't working label Oct 14, 2024
@AryamanGurjar
Copy link

Hey Did you get any solution for it

@Matteo-Frattaroli
Copy link

Matteo-Frattaroli commented Nov 4, 2024

@bankyresearch @AryamanGurjar apparently they moved around the files or modified some init files.

This should work:
lp.models.detectron2.Detectron2LayoutModel

Unluckily even though I resolved the AttributeError, i ran into another issue:

----> 1 model = lp.models.detectron2.Detectron2LayoutModel('lp://PubLayNet/faster_rcnn_R_50_FPN_3x/config',
2 extra_config=["MODEL.ROI_HEADS.SCORE_THRESH_TEST", 0.8],
3 label_map={0: "text", 1: "title", 2: "list", 3:"table", 4:"figure"})

File /usr/local/lib/python3.10/dist-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 /usr/local/lib/python3.10/dist-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'

Of course i installed detectron both as suggested by the error message and as actually indicated in the repo's readme file but with no success. I keep getting the same error.

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

3 participants