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

MangaOcr tries to load an example for some reason #43

Open
timothee-haudebourg opened this issue Jul 18, 2023 · 2 comments · May be fixed by #58
Open

MangaOcr tries to load an example for some reason #43

timothee-haudebourg opened this issue Jul 18, 2023 · 2 comments · May be fixed by #58
Labels
bug Something isn't working

Comments

@timothee-haudebourg
Copy link

I've installed manga-ocr from the sources using python setup.py install --local. Now running manga_ocr I get the following error:

2023-07-18 22:51:12.411 | INFO     | manga_ocr.ocr:__init__:13 - Loading OCR model from kha-white/manga-ocr-base
/home/user/.local/lib/python3.11/site-packages/transformers-4.31.0-py3.11.egg/transformers/models/vit/feature_extraction_vit.py:28: FutureWarning: The class ViTFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please use ViTImageProcessor instead.
  warnings.warn(
2023-07-18 22:51:20.711 | INFO     | manga_ocr.ocr:__init__:25 - Using CPU
Traceback (most recent call last):
  File "/home/user/.local/bin/manga_ocr", line 33, in <module>
    sys.exit(load_entry_point('manga-ocr==0.1.10', 'console_scripts', 'manga_ocr')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/manga_ocr-0.1.10-py3.11.egg/manga_ocr/__main__.py", line 7, in main
    fire.Fire(run)
  File "/home/user/.local/lib/python3.11/site-packages/fire-0.5.0-py3.11.egg/fire/core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/fire-0.5.0-py3.11.egg/fire/core.py", line 475, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
                                ^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/fire-0.5.0-py3.11.egg/fire/core.py", line 691, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/manga_ocr-0.1.10-py3.11.egg/manga_ocr/run.py", line 64, in run
    mocr = MangaOcr(pretrained_model_name_or_path, force_cpu)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/manga_ocr-0.1.10-py3.11.egg/manga_ocr/ocr.py", line 30, in __init__
    self(example_path)
  File "/home/user/.local/lib/python3.11/site-packages/manga_ocr-0.1.10-py3.11.egg/manga_ocr/ocr.py", line 36, in __call__
    img = Image.open(img_or_path)
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/Pillow-10.0.0-py3.11-linux-x86_64.egg/PIL/Image.py", line 3218, in open
    fp = builtins.open(filename, "rb")
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/.local/lib/python3.11/site-packages/manga_ocr-0.1.10-py3.11.egg/assets/example.jpg'

It seems like some missing example.jpg is causing a problem, I don't understand why.

@timothee-haudebourg
Copy link
Author

My guess is the example is used to test that the model has correctly been downloaded on the first run. But its not installed correctly.

@kha-white
Copy link
Owner

That's correct, the example.jpg is just for verification that it'w working fine on startup. Seems like it's not copied properly when installing from source. As a temporary fix, you can either copy the example.jpg to the expected location manually or comment out lines 27-30 in ocr.py

example_path = Path(__file__).parent / 'assets/example.jpg'
if not example_path.is_file():
example_path = Path(__file__).parent.parent / 'assets/example.jpg'
self(example_path)

@kha-white kha-white added the bug Something isn't working label Jul 20, 2023
@vaxr vaxr linked a pull request Jan 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants