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

problem running on M1 Mac Book Pro #96

Open
ganqqwerty opened this issue May 11, 2024 · 0 comments
Open

problem running on M1 Mac Book Pro #96

ganqqwerty opened this issue May 11, 2024 · 0 comments

Comments

@ganqqwerty
Copy link

I loaded the web-reader branch of the mokuro and tried to run it against a directory:

$ virtualenv venv --python=python3.9
$ source ./venv/bin/activate     
$pip3 install -r requirements.txt
$ pip3 install . 
$ which mokuro    
/IdeaProjects/mokuro/venv/bin/mokuro
$ mokuro 彼女、お借りします(34)
 

I got the following ouput:

$ mokuro 彼女、お借りします(34)
2024-05-11 16:06:31.653 | WARNING  | mokuro.run:run:47 - Legacy HTML output is deprecated and will not be further developed. It's recommended to use .mokuro format and web reader instead.
2024-05-11 16:06:31.653 | INFO     | mokuro.run:run:53 - Scanning paths...

Found 1 volumes:

~/Downloads/_japanese/books/kanojo okarishimasu/彼女、お借りします(34) (unprocessed)

Each of the paths above will be treated as one volume.


Continue? [yes/no]yes
2024-05-11 16:06:32.846 | INFO     | mokuro.run:run:121 - Processing 1/1: ~/Downloads/_japanese/books/kanojo okarishimasu/彼女、お借りします(34)
Processing pages...:   0%|                                                                                                               | 0/204 [00:00<?, ?it/s]2024-05-11 16:06:32.896 | INFO     | mokuro.manga_page_ocr:__init__:38 - Initializing text detector
[W NNPACK.cpp:64] Could not initialize NNPACK! Reason: Unsupported hardware.
2024-05-11 16:06:33.376 | INFO     | manga_ocr.ocr:__init__:13 - Loading OCR model from kha-white/manga-ocr-base
2024-05-11 16:06:37.498 | INFO     | manga_ocr.ocr:__init__:22 - Using MPS
Processing pages...:   0%|                                                                                                               | 0/204 [00:07<?, ?it/s]
2024-05-11 16:06:40.505 | ERROR    | mokuro.run:run:130 - Error while processing ~/Downloads/_japanese/books/kanojo okarishimasu/彼女、お借りします(34)
Traceback (most recent call last):

  File "~/IdeaProjects/mokuro/venv/bin/mokuro", line 8, in <module>
    sys.exit(main())
    │   │    └ <function main at 0x10a942160>
    │   └ <built-in function exit>
    └ <module 'sys' (built-in)>
  File "~/IdeaProjects/mokuro/venv/lib/python3.9/site-packages/mokuro/__main__.py", line 7, in main
    fire.Fire(run)
    │    │    └ <function run at 0x166c32f70>
    │    └ <function Fire at 0x166c54040>
    └ <module 'fire' from '~/IdeaProjects/mokuro/venv/lib/python3.9/site-packages/fire/__init__.py'>
  File "~/IdeaProjects/mokuro/venv/lib/python3.9/site-packages/fire/core.py", line 143, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
                      │     │          │     │                 │        └ 'mokuro'
                      │     │          │     │                 └ {}
                      │     │          │     └ Namespace(verbose=False, interactive=False, separator='-', completion=None, help=False, trace=False)
                      │     │          └ ['彼女、お借りします(34)']
                      │     └ <function run at 0x166c32f70>
                      └ <function _Fire at 0x166ccde50>
  File "~/IdeaProjects/mokuro/venv/lib/python3.9/site-packages/fire/core.py", line 477, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
    │                           └ <function _CallAndUpdateTrace at 0x166ccdf70>
    └ <function run at 0x166c32f70>
  File "~/IdeaProjects/mokuro/venv/lib/python3.9/site-packages/fire/core.py", line 693, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
                │   │          └ {}
                │   └ ['彼女、お借りします(34)']
                └ <function run at 0x166c32f70>
> File "~/IdeaProjects/mokuro/venv/lib/python3.9/site-packages/mokuro/run.py", line 125, in run
    mg.process_volume(volume, ignore_errors=ignore_errors, no_cache=no_cache)
    │  │              │                     │                       └ False
    │  │              │                     └ False
    │  │              └ <mokuro.volume.Volume object at 0x166c48100>
    │  └ <function MokuroGenerator.process_volume at 0x166c32940>
    └ <mokuro.mokuro_generator.MokuroGenerator object at 0x166c482e0>
  File "~/IdeaProjects/mokuro/venv/lib/python3.9/site-packages/mokuro/mokuro_generator.py", line 63, in process_volume
    raise e
  File "~/IdeaProjects/mokuro/venv/lib/python3.9/site-packages/mokuro/mokuro_generator.py", line 55, in process_volume
    self.init_models()
    │    └ <function MokuroGenerator.init_models at 0x166c328b0>
    └ <mokuro.mokuro_generator.MokuroGenerator object at 0x166c482e0>
  File "~/IdeaProjects/mokuro/venv/lib/python3.9/site-packages/mokuro/mokuro_generator.py", line 26, in init_models
    self.mpocr = MangaPageOcr(self.pretrained_model_name_or_path, force_cpu=self.force_cpu,
    │    │       │            │    │                                        │    └ False
    │    │       │            │    │                                        └ <mokuro.mokuro_generator.MokuroGenerator object at 0x166c482e0>
    │    │       │            │    └ 'kha-white/manga-ocr-base'
    │    │       │            └ <mokuro.mokuro_generator.MokuroGenerator object at 0x166c482e0>
    │    │       └ <class 'mokuro.manga_page_ocr.MangaPageOcr'>
    │    └ None
    └ <mokuro.mokuro_generator.MokuroGenerator object at 0x166c482e0>
  File "~/IdeaProjects/mokuro/venv/lib/python3.9/site-packages/mokuro/manga_page_ocr.py", line 41, in __init__
    self.mocr = MangaOcr(pretrained_model_name_or_path, force_cpu)
    │           │        │                              └ False
    │           │        └ 'kha-white/manga-ocr-base'
    │           └ <class 'manga_ocr.ocr.MangaOcr'>
    └ <mokuro.manga_page_ocr.MangaPageOcr object at 0x166d06460>
  File "~/IdeaProjects/mokuro/venv/lib/python3.9/site-packages/manga_ocr/ocr.py", line 30, in __init__
    self(example_path)
    │    └ PosixPath('~/IdeaProjects/mokuro/venv/lib/python3.9/site-packages/manga_ocr/assets/example.jpg')
    └ <manga_ocr.ocr.MangaOcr object at 0x166d7f820>
  File "~/IdeaProjects/mokuro/venv/lib/python3.9/site-packages/manga_ocr/ocr.py", line 45, in __call__
    x = self.model.generate(x[None].to(self.model.device), max_length=300)[0].cpu()
        │    │     │        │          │    │     └ <property object at 0x166b9f770>
        │    │     │        │          │    └ VisionEncoderDecoderModel(
        │    │     │        │          │        (encoder): ViTModel(
        │    │     │        │          │          (embeddings): ViTEmbeddings(
        │    │     │        │          │            (patch_embeddings): ViTPatchEmbeddin...
        │    │     │        │          └ <manga_ocr.ocr.MangaOcr object at 0x166d7f820>
        │    │     │        └ tensor([[[-0.6471, -0.9373, -0.8824,  ...,  0.1059,  0.1059,  0.0980],
        │    │     │                   [-0.8431, -0.8745, -0.1373,  ...,  0.1059,  0...
        │    │     └ <function GenerationMixin.generate at 0x166b624c0>
        │    └ VisionEncoderDecoderModel(
        │        (encoder): ViTModel(
        │          (embeddings): ViTEmbeddings(
        │            (patch_embeddings): ViTPatchEmbeddin...
        └ <manga_ocr.ocr.MangaOcr object at 0x166d7f820>
  File "~/IdeaProjects/mokuro/venv/lib/python3.9/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
           │     │       └ {'max_length': 300}
           │     └ (VisionEncoderDecoderModel(
           │         (encoder): ViTModel(
           │           (embeddings): ViTEmbeddings(
           │             (patch_embeddings): ViTPatchEmbeddi...
           └ <function GenerationMixin.generate at 0x166b62430>
  File "~/IdeaProjects/mokuro/venv/lib/python3.9/site-packages/transformers/generation/utils.py", line 1655, in generate
    result = self._beam_search(
             │    └ <function GenerationMixin._beam_search at 0x166b62af0>
             └ VisionEncoderDecoderModel(
                 (encoder): ViTModel(
                   (embeddings): ViTEmbeddings(
                     (patch_embeddings): ViTPatchEmbeddin...
  File "~/IdeaProjects/mokuro/venv/lib/python3.9/site-packages/transformers/generation/utils.py", line 3261, in _beam_search
    sequence_outputs = beam_scorer.finalize(
                       │           └ <function BeamSearchScorer.finalize at 0x166b23f70>
                       └ <transformers.generation.beam_search.BeamSearchScorer object at 0x178eb0340>
  File "~/IdeaProjects/mokuro/venv/lib/python3.9/site-packages/transformers/generation/beam_search.py", line 397, in finalize
    decoded[i, : sent_lengths[i]] = hypo
    │       │    │            │     └ tensor([   2,    2, 2312, 4080, 5063, 4885, 3600, 5764, 5554, 4798, 1074, 3386,
    │       │    │            │               2865, 2166, 1524, 1858, 2872, 4014, 5...
    │       │    │            └ 0
    │       │    └ tensor([3122421267], device='mps:0')
    │       └ 0
    └ tensor([[                   2,                    2,                 2312,
                               4080,                 506...

RuntimeError: The expanded size of the tensor (300) must match the existing size (26) at non-singleton dimension 0.  Target sizes: [300].  Tensor sizes: [26]
2024-05-11 16:06:40.770 | INFO     | mokuro.run:run:134 - Processed successfully: 0/1

~/Downloads/_japanese/books/kanojo okarishimasu ⌚ 16:06:41
$ pip3 install -r requirements.txt
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'

any ideas about how to fix it? I removed the _ocr directory before running the mokuro

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

1 participant