facebookresearch / nougat

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

How to run in windows. #107

Open sjanapro opened 1 year ago

sjanapro commented 1 year ago

nougat is not recognised in the cmd after installing..

lukas-blecher commented 1 year ago

It should be. How did you install it? Make sure you activate the environment before calling nougat.

sjanapro commented 1 year ago

Using pip and I am not using any environment.

sjanapro commented 1 year ago

There is no virtual environment. I just installed the package and it's dependencies then tried to run it from cmd but it is showing the error as I mentioned earlier.

lukas-blecher commented 1 year ago

show me some logs. did the installation work? without problems?

gelprec commented 1 year ago

I didn't manage to make nougat work either (on windows 11). When installing with pip everything went ok. Maybe it's just a stupid mistake on my part. I found a nougat.exe file inside some python folder and ran it here using a powershell console getting the message below

PS C:\Users\geo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts> .\nougat -h
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\geo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\nougat.exe\__main__.py", line 4, in <module>
  File "C:\Users\geo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\predict.py", line 17, in <module>
    from nougat import NougatModel
  File "C:\Users\geo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nougat\__init__.py", line 8, in <module>
    from .utils.dataset import NougatDataset
  File "C:\Users\geo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nougat\utils\dataset.py", line 21, in <module>
    from nougat.dataset.rasterize import rasterize_paper
  File "C:\Users\geo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nougat\dataset\rasterize.py", line 18, in <module>
    pdf: Path | bytes,
TypeError: unsupported operand type(s) for |: 'type' and 'type'
lukas-blecher commented 1 year ago

@gelprec sorry, that is a bug for python 3.9. It's fixed in main but I didn't push to pypi yet

gelprec commented 1 year ago

Thanks. I uninstalled python 3.9 and installed the newer version 3.11.5. I reinstalled nougat and it works, but the default CPU version is very slow (about 3 minutes for two pages pdf), hence it's necessary to install a gpu/cuda aware torch version. I followed these steps

Now the process is much speedier and the resulted ocr seems very accurate, better than I expected.

zf0x00 commented 8 months ago

I am still getting this on python 3.11

soul667 commented 1 month ago

you should better use docker

FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/pytorch/pytorch:2.4.1-cuda12.4-cudnn9-runtime
RUN apt-get update
RUN mkdir workspace
WORKDIR /workspace
# RUN pipx ensurepath
RUN pip3 install nougat-ocr -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip3 install fastapi -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip3 install transformers==4.38.2  -i https://pypi.tuna.tsinghua.edu.cn/simple