nougat: `predict.py` Unhandled Exception

I was trying the simplest example from GitHub documentation, just OCR the original academic paper for Nougat, and it fails.

My command:

nougat 2308.13418.pdf -o 'output' --no-skipping

I had just installed using Python 3.10 in Ubuntu on WSL2 on Windows. So a Linux VM on Windows.

Commands tried to install:

pip install nougat-ocr

pip install git+https://github.com/facebookresearch/nougat

but both versions of the library result in this at runtime:

> nougat 2308.13418.pdf -o 'output' --no-skipping
\WARNING:root:No GPU found. Conversion on CPU is very slow.
/home/wolf/venvs/nougattest/lib/python3.10/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3483.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
  0%|                                                                                                                                                                                                                   | 0/17 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/home/wolf/venvs/nougattest/bin/nougat", line 8, in <module>
    sys.exit(main())
  File "/home/wolf/venvs/nougattest/lib/python3.10/site-packages/predict.py", line 145, in main
    for i, (sample, is_last_page) in enumerate(tqdm(dataloader)):
TypeError: cannot unpack non-iterable NoneType object

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Comments: 21 (6 by maintainers)

Commits related to this issue

Most upvoted comments

This time I get Traceback (most recent call last): File “/usr/local/bin/nougat”, line 8, in <module> sys.exit(main()) File “/usr/local/lib/python3.10/dist-packages/predict.py”, line 148, in main for i, (sample, is_last_page) in enumerate(tqdm(dataloader)): File “/usr/local/lib/python3.10/dist-packages/tqdm/std.py”, line 1178, in iter for obj in iterable: File “/usr/local/lib/python3.10/dist-packages/torch/utils/data/dataloader.py”, line 633, in next data = self._next_data() File “/usr/local/lib/python3.10/dist-packages/torch/utils/data/dataloader.py”, line 677, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File “/usr/local/lib/python3.10/dist-packages/torch/utils/data/_utils/fetch.py”, line 51, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File “/usr/local/lib/python3.10/dist-packages/torch/utils/data/_utils/fetch.py”, line 51, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File “/usr/local/lib/python3.10/dist-packages/torch/utils/data/dataset.py”, line 302, in getitem return self.datasets[dataset_idx][sample_idx] File “/usr/local/lib/python3.10/dist-packages/nougat/utils/dataset.py”, line 97, in getitem return self.dataset[i], self.name if i == self.size - 1 else “” File “/usr/local/lib/python3.10/dist-packages/nougat/utils/dataset.py”, line 61, in getitem img = Image.open(self.img_list[idx]) IndexError: list index out of range

Tnx for the fix, I switch to GPU for the speedup.

Ok nice, I removed the logging now. Closing this issue now. Thanks everybody for the help!

@lukas-blecher Tested now again with version 0.1.9 - same error (working with 0.1.8) new python venv pip freeze file: pipfreeze.txt

can somebody give me a pdf? I just changed something in the rasterization so the error is from that. You can downgrade to 0.1.8 for now