facebookresearch / nougat

Implementation of Nougat Neural Optical Understanding for Academic Documents
https://facebookresearch.github.io/nougat/
MIT License
8.78k stars 561 forks source link

TypeError: BARTDecoder #234

Open breisfeld opened 1 month ago

breisfeld commented 1 month ago

Hi, After running the command

$ nougat.exe .\pharmaceutics-16-00226.pdf -o .\output -m 0.1.0-base

I get successful downloads, but then an error. I get this same error on Windows and Linux in a fresh conda virtual environment.

WARNING:root:No GPU found. Conversion on CPU is very slow.
downloading nougat checkpoint version 0.1.0-base to path C:\Users\breisfel\.cache\torch\hub\nougat-0.1.0-base
config.json: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████| 560/560 [00:00<?, ?b/s]
pytorch_model.bin: 100%|██████████████████████████████████████████████████████████████████████████████████| 1.31G/1.31G [02:23<00:00, 9.79Mb/s]
special_tokens_map.json: 100%|██████████████████████████████████████████████████████████████████████████████████████| 96.0/96.0 [00:00<?, ?b/s]
tokenizer.json: 100%|█████████████████████████████████████████████████████████████████████████████████████| 2.04M/2.04M [00:00<00:00, 7.45Mb/s]
tokenizer_config.json: 100%|██████████████████████████████████████████████████████████████████████████████████████████| 106/106 [00:00<?, ?b/s]
C:\Users\XXXXX\anaconda3\envs\extract_pdf_tables\Lib\site-packages\torch\functional.py:513: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\aten\src\ATen\native\TensorShape.cpp:3610.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
  0%|      bre                                                                                                             | 0/21 [02:38<?, ?it/s]
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\XXXXX\anaconda3\envs\extract_pdf_tables\Scripts\nougat.exe\__main__.py", line 7, in <module>
  File "C:\Users\XXXXX\anaconda3\envs\extract_pdf_tables\Lib\site-packages\predict.py", line 167, in main
    model_output = model.inference(
                   ^^^^^^^^^^^^^^^^
  File "C:\Users\XXXXX\anaconda3\envs\extract_pdf_tables\Lib\site-packages\nougat\model.py", line 592, in inference
    decoder_output = self.decoder.model.generate(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\XXXXX\anaconda3\envs\extract_pdf_tables\Lib\site-packages\torch\utils\_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\XXXXX\anaconda3\envs\extract_pdf_tables\Lib\site-packages\transformers\generation\utils.py", line 1989, in generate
    result = self._sample(
             ^^^^^^^^^^^^^
  File "C:\Users\XXXXX\anaconda3\envs\extract_pdf_tables\Lib\site-packages\transformers\generation\utils.py", line 2925, in _sample
    model_inputs = self.prepare_inputs_for_generation(input_ids, **model_kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BARTDecoder.prepare_inputs_for_inference() got an unexpected keyword argument 'cache_position'
-> Cannot close object, library is destroyed. This may cause a memory leak!
-> Cannot close object, library is destroyed. This may cause a memory leak!
-> Cannot close object, library is destroyed. This may cause a memory leak!
-> Cannot close object, library is destroyed. This may cause a memory leak!
-> Cannot close object, library is destroyed. This may cause a memory leak!
-> Cannot close object, library is destroyed. This may cause a memory leak!
MaksimMrvica-plus commented 1 month ago

you need install transformers==4.38.2

breisfeld commented 1 month ago

Thanks, I'll give it a try. I just followed the README instructions and installed nougat and dependencies via pip.

anshumankmr commented 1 week ago

Sad there are so many bugs in this repo. Seems to work for me. Tested. (using nougat_api and the git version of this repo on Windows 11)