Open
Description
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
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
AryamanGurjar commentedon Oct 14, 2024
Hey Did you get any solution for it
Matteo-Frattaroli commentedon 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:
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.
finiteautomata commentedon Nov 10, 2024
Followed the instructions to install the library with detectron support
The error posted by @Matteo-Frattaroli disappears but gets replaced by yet another one
fails with
mgutierrezc commentedon Nov 21, 2024
Similar issue here. Couldn't install detectron unless
--no-build-isolation
is specified:pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu117/torch2.0/index.html--no-build-isolation
But this leads to an assertion error
The only two files I've inside are
natalienkhalil commentedon Jan 17, 2025
@mgutierrezc Were you able to find a solution to this? I'm having the same issue, where the model weights file (model_final.pth) is not correctly named in the directory. I'm only able to use EffDet, none of the Detectron2 models are working for me due to this filename issue.
I tried manually downloading the model weights file and making sure it is available in the directory mentioned in the checkpoint AssertionError, making sure it has the correct name there (model_final.pth). I also tried deleting the old dl=1 and .lock files manually, but they just show up again after running my code. (I also tried hardcoding the path to the model weights file on my local computer using the Detectron2LayoutModel(model_path="path-to-my-weights-file"), but nothing is working. This is my latest error message -
File "/Users/nkhalil/python_projects/research_paper_prez/.venv/lib/python3.9/site-packages/detectron2/checkpoint/detection_checkpoint.py", line 108, in _load_file
raise ValueError(
ValueError: Unsupported query remaining: f{'dl': ['1']}, orginal filename: /Users/nkhalil/.torch/iopath_cache/s/dgy9c10wykk4lq4/model_final.pth?dl=1
).
mgutierrezc commentedon Jan 20, 2025
I kinda did. There was another issue reporting the problem with the paths and pointing to a fork that didn’t have that problem. It’s been a while since I worked in this though, so I don’t remember exactly where was that solution.
pradhanhitesh commentedon Feb 6, 2025
I have finally solved the issue where the implementation of
Detectron2
inLayout Parser
seemed impossible. I have detailed the entire process here. In brief, I wanted to implement the tutorial and faced many issues such as these:PIL.Image.LINEAR
no longer existsDepending on your
OS
, you can skip a few steps. I have implemented all the fixes for Windows WSL2 (Ubuntu 20.04.6
) and it works!Bill-XU commentedon Apr 30, 2025
Another option for installation on Windows 10, "examples/Deep Layout Parsing.ipynb" worked properly.
python -m venv .venv .\.venv\Scripts\activate
(ref. PyTorch throws OSError on Detectron2LayoutModel)
9Mercury commentedon May 25, 2025
using lp.models will do the job