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

pydantic error #232

Open
breisfeld opened this issue Jul 30, 2024 · 17 comments
Open

pydantic error #232

breisfeld opened this issue Jul 30, 2024 · 17 comments

Comments

@breisfeld
Copy link

Hi, When running nougat on a test pdf file

$ nougat /Users/XXXXX/Downloads/pharmaceutics-16-00226.pdf -o output

I get the following traceback:

Traceback (most recent call last):
  File "/Users/XXXXX/miniconda3/envs/extract_pdf_tables/bin/nougat", line 5, in <module>
    from predict import main
  File "/Users/XXXXX/miniconda3/envs/extract_pdf_tables/lib/python3.12/site-packages/predict.py", line 18, in <module>
    from nougat import NougatModel
  File "/Users/XXXXX/miniconda3/envs/extract_pdf_tables/lib/python3.12/site-packages/nougat/__init__.py", line 7, in <module>
    from .model import NougatConfig, NougatModel
  File "/Users/XXXXX/miniconda3/envs/extract_pdf_tables/lib/python3.12/site-packages/nougat/model.py", line 34, in <module>
    from nougat.transforms import train_transform, test_transform
  File "/Users/XXXXX/miniconda3/envs/extract_pdf_tables/lib/python3.12/site-packages/nougat/transforms.py", line 146, in <module>
    alb.ElasticTransform(
  File "/Users/XXXXX/miniconda3/envs/extract_pdf_tables/lib/python3.12/site-packages/albumentations/core/validation.py", line 35, in custom_init
    config = dct["InitSchema"](**full_kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/XXXXX/miniconda3/envs/extract_pdf_tables/lib/python3.12/site-packages/pydantic/main.py", line 193, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for InitSchema
alpha_affine
  Input should be None [type=none_required, input_value=1.2, input_type=float]
    For further information visit https://errors.pydantic.dev/2.8/v/none_required

I get the same traceback when running nougat with no arguments.

I have tried running this same command under MacOS, Linux, and Windows.
On all platforms, nougat was installed into a fresh conda virtual environment using pip.

Any advice on solving the problem?

Thanks.

@YuCheng-Qi
Copy link

Modify alb.ElasticTransform( p=1, alpha=50, sigma=120 * 0.1, alpha_affine=120 * 0.01, border_mode=0, value=(255, 255, 255), ), to alb.ElasticTransform in transforms.py (p=1, alpha=50, sigma=120 * 0.1, alpha_affine=None, border_mode=0, value=(255, 255, 255), ),

@YuCheng-Qi
Copy link

@breisfeld

@eesyfep
Copy link

eesyfep commented Jul 31, 2024

mode
Even I changed the parameters, it shows the same warning

@shenxianovo
Copy link

same issue

@breisfeld
Copy link
Author

Modify alb.ElasticTransform( p=1, alpha=50, sigma=120 * 0.1, alpha_affine=120 * 0.01, border_mode=0, value=(255, 255, 255), ), to alb.ElasticTransform in transforms.py (p=1, alpha=50, sigma=120 * 0.1, alpha_affine=None, border_mode=0, value=(255, 255, 255), ),

That seemed to take care of the issue for me. Thanks!

@YodaGitMaster
Copy link

Thanks

@e-hossam96
Copy link

e-hossam96 commented Aug 6, 2024

Modify alb.ElasticTransform( p=1, alpha=50, sigma=120 * 0.1, alpha_affine=120 * 0.01, border_mode=0, value=(255, 255, 255), ), to alb.ElasticTransform in transforms.py (p=1, alpha=50, sigma=120 * 0.1, alpha_affine=None, border_mode=0, value=(255, 255, 255), ),

It worked and the model started downloading. However, after downloading the model checkpoint, it immediately throws a connection error. (WSL2)

@SichangHe
Copy link

Can't even make a PR to fix this lol. They locked it down to collaborator-only.

tracyqwerty added a commit to tracyqwerty/nougat that referenced this issue Aug 30, 2024
@samiahhassan
Copy link

I am having the same issues with nougat. I am new to OCR. Please assist me with where I should make the change for the ElasticTransform function or any other way. Thanks for any advice.

Modify alb.ElasticTransform( p=1, alpha=50, sigma=120 * 0.1, alpha_affine=120 * 0.01, border_mode=0, value=(255, 255, 255), ), to alb.ElasticTransform in transforms.py (p=1, alpha=50, sigma=120 * 0.1, alpha_affine=None, border_mode=0, value=(255, 255, 255), ),

@anshumankmr
Copy link

Getting some strange error after making that edit,

No module named nougat.main; 'nougat' is a package and cannot be directly executed

Windows 11

@snimavat
Copy link

Same error, Macbook pro Python 3.11.2

@dimazig
Copy link

dimazig commented Sep 13, 2024

same issue

Traceback (most recent call last):
  File "/home/dima/nougat/bin/nougat", line 5, in <module>
    from predict import main
  File "/home/dima/nougat/lib/python3.12/site-packages/predict.py", line 18, in <module>
    from nougat import NougatModel
  File "/home/dima/nougat/lib/python3.12/site-packages/nougat/__init__.py", line 7, in <module>
    from .model import NougatConfig, NougatModel
  File "/home/dima/nougat/lib/python3.12/site-packages/nougat/model.py", line 34, in <module>
    from nougat.transforms import train_transform, test_transform
  File "/home/dima/nougat/lib/python3.12/site-packages/nougat/transforms.py", line 146, in <module>
    alb.ElasticTransform(
  File "/home/dima/nougat/lib/python3.12/site-packages/albumentations/core/validation.py", line 35, in custom_init
    config = dct["InitSchema"](**full_kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dima/nougat/lib/python3.12/site-packages/pydantic/main.py", line 209, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for InitSchema
alpha_affine
  Input should be None [type=none_required, input_value=1.2, input_type=float]
    For further information visit https://errors.pydantic.dev/2.9/v/none_required

@SichangHe
Copy link

Try my fork for now, I merged the corresponding PRs:

python3 -m pip install git+https://github.com/SichangHe/facebookresearch--nougat.git
# Or, using Pipx:
pipx install git+https://github.com/SichangHe/facebookresearch--nougat.git
# Or, if you are using Rye:
rye add --git https://github.com/SichangHe/facebookresearch--nougat.git nougat-ocr

@Fireblossom
Copy link

pip install albumentations==1.4.8

@breisfeld
Copy link
Author

breisfeld commented Sep 14, 2024

pip install albumentations==1.4.8

@SichangHe , should the existing line in setup.py in your fork be replaced by this if it is the true dependency?

@SichangHe
Copy link

pip install albumentations==1.4.8

@SichangHe , should the existing line in setup.py in your fork be replaced by this if it is the true dependency?

I doublechecked, I have 1.4.14 in my environment and it still works.

Also, I am moving away to marker-pdf because it seems to give fewer spurious errors, although their header detection and math decoding really suck.

@anshumankmr
Copy link

Instead of calling the nougat thing via the CLI, I chose to install nougat_api and it worked for me. That was sufficient for my use case.

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