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

[AutoLayoutModel] Outdated docs and silent error #136

Closed
falcaopetri opened this issue Apr 30, 2022 · 2 comments · Fixed by #146
Closed

[AutoLayoutModel] Outdated docs and silent error #136

falcaopetri opened this issue Apr 30, 2022 · 2 comments · Fixed by #146
Labels
bug Something isn't working

Comments

@falcaopetri
Copy link

Describe the bug
README contains the following (since #73):

Perform DL layout detection in 4 lines of code

import layoutparser as lp
model = lp.AutoLayoutModel('lp://EfficientDete/PubLayNet')
# image = Image.open("path/to/image")
layout = model.detect(image) 

This fails to instantiate a valid model because AutoLayoutModel runs

for backend_name in ALL_AVAILABLE_BACKENDS:
if backend_name in config_path:

and

>>> import layoutparser as lp
>>> list(lp.models.auto_layoutmodel.ALL_AVAILABLE_BACKENDS)
['detectron2', 'paddledetection', 'efficientdet']

i.e., 'efficientdet' is not in 'lp://EfficientDete/PubLayNet'.

When AutoLayoutModel cannot find a model to instantiate, it silently returns None (because it returns nothing).
This means that we get AttributeError: 'NoneType' object has no attribute 'detect' during layout = model.detect(image)

My suggestions are:

  • update the README with a proper model, perhaps from:
    "lp://efficientdet/PubLayNet/tf_efficientdet_d0/config",
  • AutoLayoutModel should complain if it fails auto detecting the model.
  • add # from PIL import Image along README's # image = Image.open("path/to/image")
@falcaopetri falcaopetri added the bug Something isn't working label Apr 30, 2022
@lolipopshock
Copy link
Member

Thanks -- Good catch! Will fix it later

@lolipopshock
Copy link
Member

Also see #86

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

Successfully merging a pull request may close this issue.

2 participants