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

Why can't I run nougat-ocr on pdfs? #226

Open
emilyhanyf opened this issue Jun 8, 2024 · 5 comments
Open

Why can't I run nougat-ocr on pdfs? #226

emilyhanyf opened this issue Jun 8, 2024 · 5 comments

Comments

@emilyhanyf
Copy link

ImportError: cannot import name 'cached_property' from 'nougat.utils' (/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/utils/__init__.py) OCRing with base model failed on /lfs/skampere1/0/emilyhyf/massive-evaporation-4-math/data/debug_pdfs/dummy_folder1/The_IMO_Compendium.pdf... trying small model Traceback (most recent call last): File "/lfs/skampere1/0/emilyhyf/miniconda/bin/nougat", line 5, in <module> from predict import main File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/predict.py", line 18, in <module> from nougat import NougatModel File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/__init__.py", line 1, in <module> from nougat.app import Nougat File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/app.py", line 5, in <module> from nougat.asgi import serve File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/asgi.py", line 6, in <module> from nougat.context.request import Request File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/context/__init__.py", line 1, in <module> from nougat.context.request import Request File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/context/request.py", line 8, in <module> from nougat.utils import cached_property, File ImportError: cannot import name 'cached_property' from 'nougat.utils' (/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/utils/__init__.py) OCRing with small model failed on /lfs/skampere1/0/emilyhyf/massive-evaporation-4-math/data/debug_pdfs/dummy_folder1/The_IMO_Compendium.pdf The following files failed OCRing and need manual review: /lfs/skampere1/0/emilyhyf/massive-evaporation-4-math/data/debug_pdfs/putnam_and_beyond.pdf /lfs/skampere1/0/emilyhyf/massive-evaporation-4-math/data/debug_pdfs/dummy_folder1/The_IMO_Compendium.pdf Time taken: 8.497612476348877 seconds, 0.1416268746058146 minutes, 0.00236044791009691 hours

@ivanmladek
Copy link

same error

1 similar comment
@hqy479
Copy link

hqy479 commented Sep 13, 2024

same error

@hqy479
Copy link

hqy479 commented Sep 13, 2024

nougat.utils init file is empty, i don‘t know why

@Jawwadabd
Copy link

anyone found solution to this? @ivanmladek @hqy479 @emilyhanyf @Celebio @nlutsenko

@lemorage
Copy link

ImportError: cannot import name 'cached_property' from 'nougat.utils' (/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/utils/__init__.py) OCRing with base model failed on /lfs/skampere1/0/emilyhyf/massive-evaporation-4-math/data/debug_pdfs/dummy_folder1/The_IMO_Compendium.pdf... trying small model Traceback (most recent call last): File "/lfs/skampere1/0/emilyhyf/miniconda/bin/nougat", line 5, in <module> from predict import main File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/predict.py", line 18, in <module> from nougat import NougatModel File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/__init__.py", line 1, in <module> from nougat.app import Nougat File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/app.py", line 5, in <module> from nougat.asgi import serve File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/asgi.py", line 6, in <module> from nougat.context.request import Request File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/context/__init__.py", line 1, in <module> from nougat.context.request import Request File "/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/context/request.py", line 8, in <module> from nougat.utils import cached_property, File ImportError: cannot import name 'cached_property' from 'nougat.utils' (/lfs/skampere1/0/emilyhyf/miniconda/lib/python3.12/site-packages/nougat/utils/__init__.py) OCRing with small model failed on /lfs/skampere1/0/emilyhyf/massive-evaporation-4-math/data/debug_pdfs/dummy_folder1/The_IMO_Compendium.pdf The following files failed OCRing and need manual review: /lfs/skampere1/0/emilyhyf/massive-evaporation-4-math/data/debug_pdfs/putnam_and_beyond.pdf /lfs/skampere1/0/emilyhyf/massive-evaporation-4-math/data/debug_pdfs/dummy_folder1/The_IMO_Compendium.pdf Time taken: 8.497612476348877 seconds, 0.1416268746058146 minutes, 0.00236044791009691 hours

From the above error msg, I could see the attempt to import something from the path nougat/context/, however, in this Nougat package, there is no context directory at all. So I am very suspicious you're importing the wrong package. Based on this thread of thought, I found this package (https://github.com/Riparo/nougat), with the same name "Nougat". Likely, you're actually using this package behind the scenes, since I could see the usage of "cached_property" > here.

So my end solution is to do pip uninstall nougat and pip install nougat-ocr to specify the correct package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants