Skip to content

Problem running on an M2 Macbook Pro #138

@quopquai

Description

@quopquai

Can someone tell me what I did wrong and how to fix it? - I'm a novice at this! Thanks

Macintosh:~ julisco$ cd mokuro
Macintosh:mokuro julisco$ source venv/bin/activate
(venv) Macintosh:mokuro julisco$ mokuro /Users/julisco/Desktop/よつばと/よつばと\!\ 第01巻 
2025-09-10 14:28:39.314 | WARNING  | mokuro.run:run:55 - Legacy HTML output is deprecated and will not be further developed. It's recommended to use .mokuro format and web reader instead. Legacy HTML will be disabled by default in the future. To explicitly enable it, run with option --legacy-html.
2025-09-10 14:28:39.314 | INFO     | mokuro.run:run:63 - Scanning paths...

Found 1 volumes:

/Users/julisco/Desktop/よつばと/よつばと! 第01巻 (unprocessed)

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


Continue? [yes/no]yes
2025-09-10 14:28:48.049 | INFO     | mokuro.run:run:133 - Processing 1/1: /Users/julisco/Desktop/よつばと/よつばと! 第01巻
Processing pages...:   0%|                                                                        | 0/231 [00:00<?, ?it/s]2025-09-10 14:28:48.077 | INFO     | mokuro.manga_page_ocr:__init__:41 - Initializing text detector, using device cpu
2025-09-10 14:28:48.289 | INFO     | manga_ocr.ocr:__init__:16 - Loading OCR model from kha-white/manga-ocr-base
Fetching 1 files: 100%|███████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 9177.91it/s]
2025-09-10 14:28:50.395 | INFO     | manga_ocr.ocr:__init__:25 - Using MPS                          | 0/1 [00:00<?, ?it/s]
Processing pages...:   0%|                                                                        | 0/231 [00:02<?, ?it/s]
2025-09-10 14:28:50.680 | ERROR    | mokuro.run:run:142 - Error while processing /Users/julisco/Desktop/よつばと/よつばと! 第01巻
Traceback (most recent call last):

  File "/Users/julisco/mokuro/venv/bin/mokuro", line 8, in <module>
    sys.exit(main())
    │   │    └ <function main at 0x10313d630>
    │   └ <built-in function exit>
    └ <module 'sys' (built-in)>
  File "/Users/julisco/mokuro/venv/lib/python3.10/site-packages/mokuro/__main__.py", line 7, in main
    fire.Fire(run)
    │    │    └ <function run at 0x17f3f5e10>
    │    └ <function Fire at 0x17f31c940>
    └ <module 'fire' from '/Users/julisco/mokuro/venv/lib/python3.10/site-packages/fire/__init__.py'>
  File "/Users/julisco/mokuro/venv/lib/python3.10/site-packages/fire/core.py", line 135, 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)
                      │     │          └ ['/Users/julisco/Desktop/よつばと/よつばと! 第01巻']
                      │     └ <function run at 0x17f3f5e10>
                      └ <function _Fire at 0x17f3f5870>
  File "/Users/julisco/mokuro/venv/lib/python3.10/site-packages/fire/core.py", line 468, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
    │                           └ <function _CallAndUpdateTrace at 0x17f3f5990>
    └ <function run at 0x17f3f5e10>
  File "/Users/julisco/mokuro/venv/lib/python3.10/site-packages/fire/core.py", line 684, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
                │   │          └ {}
                │   └ ['/Users/julisco/Desktop/よつばと/よつばと! 第01巻']
                └ <function run at 0x17f3f5e10>
> File "/Users/julisco/mokuro/venv/lib/python3.10/site-packages/mokuro/run.py", line 137, in run
    mg.process_volume(volume, ignore_errors=ignore_errors, no_cache=no_cache)
    │  │              │                     │                       └ False
    │  │              │                     └ False
    │  │              └ <mokuro.volume.Volume object at 0x17f3f3610>
    │  └ <function MokuroGenerator.process_volume at 0x17f38dc60>
    └ <mokuro.mokuro_generator.MokuroGenerator object at 0x17f3f3670>
  File "/Users/julisco/mokuro/venv/lib/python3.10/site-packages/mokuro/mokuro_generator.py", line 65, in process_volume
    raise e
  File "/Users/julisco/mokuro/venv/lib/python3.10/site-packages/mokuro/mokuro_generator.py", line 57, in process_volume
    self.init_models()
    │    └ <function MokuroGenerator.init_models at 0x17f38dbd0>
    └ <mokuro.mokuro_generator.MokuroGenerator object at 0x17f3f3670>
  File "/Users/julisco/mokuro/venv/lib/python3.10/site-packages/mokuro/mokuro_generator.py", line 24, in init_models
    self.mpocr = MangaPageOcr(
    │    │       └ <class 'mokuro.manga_page_ocr.MangaPageOcr'>
    │    └ None
    └ <mokuro.mokuro_generator.MokuroGenerator object at 0x17f3f3670>
  File "/Users/julisco/mokuro/venv/lib/python3.10/site-packages/mokuro/manga_page_ocr.py", line 45, 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 0x17fd426b0>
  File "/Users/julisco/mokuro/venv/lib/python3.10/site-packages/manga_ocr/ocr.py", line 33, in __init__
    self(example_path)
    │    └ PosixPath('/Users/julisco/mokuro/venv/lib/python3.10/site-packages/manga_ocr/assets/example.jpg')
    └ <manga_ocr.ocr.MangaOcr object at 0x17fd76980>
  File "/Users/julisco/mokuro/venv/lib/python3.10/site-packages/manga_ocr/ocr.py", line 48, in __call__
    x = self.model.generate(x[None].to(self.model.device), max_length=300)[0].cpu()
        │    │     │        │          │    │     └ <property object at 0x17f12bbf0>
        │    │     │        │          │    └ MangaOcrModel(
        │    │     │        │          │        (encoder): ViTModel(
        │    │     │        │          │          (embeddings): ViTEmbeddings(
        │    │     │        │          │            (patch_embeddings): ViTPatchEmbeddings(
        │    │     │        │          │              ...
        │    │     │        │          └ <manga_ocr.ocr.MangaOcr object at 0x17fd76980>
        │    │     │        └ 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 0x17efb1360>
        │    └ MangaOcrModel(
        │        (encoder): ViTModel(
        │          (embeddings): ViTEmbeddings(
        │            (patch_embeddings): ViTPatchEmbeddings(
        │              ...
        └ <manga_ocr.ocr.MangaOcr object at 0x17fd76980>
  File "/Users/julisco/mokuro/venv/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 120, in decorate_context
    return func(*args, **kwargs)
           │     │       └ {'max_length': 300}
           │     └ (MangaOcrModel(
           │         (encoder): ViTModel(
           │           (embeddings): ViTEmbeddings(
           │             (patch_embeddings): ViTPatchEmbeddings(
           │              ...
           └ <function GenerationMixin.generate at 0x17efb12d0>
  File "/Users/julisco/mokuro/venv/lib/python3.10/site-packages/transformers/generation/utils.py", line 2303, in generate
    self._prepare_special_tokens(generation_config, kwargs_has_attention_mask, device=device)
    │    │                       │                  │                                 └ device(type='mps', index=0)
    │    │                       │                  └ False
    │    │                       └ GenerationConfig {
    │    │                           "decoder_start_token_id": 2,
    │    │                           "early_stopping": true,
    │    │                           "eos_token_id": 3,
    │    │                           "length_penalty": 2.0,
    │    │                           "...
    │    └ <function GenerationMixin._prepare_special_tokens at 0x17efb11b0>
    └ MangaOcrModel(
        (encoder): ViTModel(
          (embeddings): ViTEmbeddings(
            (patch_embeddings): ViTPatchEmbeddings(
              ...
  File "/Users/julisco/mokuro/venv/lib/python3.10/site-packages/transformers/generation/utils.py", line 2074, in _prepare_special_tokens
    and isin_mps_friendly(elements=eos_token_tensor, test_elements=pad_token_tensor).any()
        │                          │                               └ tensor(0, device='mps:0')
        │                          └ tensor([3], device='mps:0')
        └ <function isin_mps_friendly at 0x17eee6170>
  File "/Users/julisco/mokuro/venv/lib/python3.10/site-packages/transformers/pytorch_utils.py", line 345, in isin_mps_friendly
    return torch.isin(elements, test_elements)
           │     │    │         └ tensor(0, device='mps:0')
           │     │    └ tensor([3], device='mps:0')
           │     └ <built-in method isin of type object at 0x178b48a40>
           └ <module 'torch' from '/Users/julisco/mokuro/venv/lib/python3.10/site-packages/torch/__init__.py'>

RuntimeError: isin_Tensor_Tensor_out only works on floating types on MPS for pre MacOS_14_0. Received dtype: Long
2025-09-10 14:28:50.811 | INFO     | mokuro.run:run:146 - Processed successfully: 0/1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions