Skip to content
forked from kha-white/mokuro

Read Japanese manga inside browser with selectable text.

License

Notifications You must be signed in to change notification settings

KojoZero/mokuro

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mokuro

Read Japanese manga with selectable text inside a browser.

See demo: https://kha-white.github.io/manga-demo

mokuro_demo.mp4

Demo contains excerpt from Manga109-s dataset. うちの猫’ず日記 © がぁさん

mokuro is aimed towards Japanese learners, who want to read manga in Japanese with a pop-up dictionary like Yomitan. It works like this:

  1. Perform text detection and OCR for each page.
  2. After processing a whole volume, generate a .mokuro file, which contains OCR results and metadata. All processing is done offline (before reading).
  3. Load the .mokuro file together with manga images in web reader, which serves both as a manga reader and a catalog for processed series and volumes.

Alternatively, you can still use the old method from mokuro 0.1.*: Instead of a .mokuro file, generate an HTML file, which you can open in a browser. This method is still supported for backward compatibility, but it is recommended to use the new .mokuro format and the web reader. For details, see Legacy HTML vs. new .mokuro format.

mokuro uses comic-text-detector for text detection and manga-ocr for OCR.

Try running online with Colab: Open In Colab

See also:

  • mokuro-reader, a web reader for mokuro, developed by ZXY101
  • Mokuro2Pdf, cli Ruby script to generate pdf files with selectable text from Mokuro's html overlay
  • Xelieu's guide, a comprehensive guide on setting up a reading and mining workflow with manga-ocr/mokuro (and many other useful tips)

Installation

You need Python 3.6 or newer. Refer to PyTorch website for a list of supported Python versions.

To install:

Download the latest Mokuro release, extract it, open the command line in the extracted directory and then run in command line:

pip install .

If you want to run with GPU: Uninstall previously installed dependencies with the command below

pip uninstall torch torchvision torchaudio

Then: Install Pytorch here, choose a CUDA version, and run the command it gives you in the command line. Next, download the Cuda Toolkit version that matches the CUDA version you chose for PyTorch

Some users have reported problems with Python installed from Microsoft Store. If you see an error: ImportError: DLL load failed while importing fugashi: The specified module could not be found., try installing Python from the official site.

Usage

Run on individual volumes

mokuro "/path/to/manga/vol1"

This will generate /path/to/manga/vol1.mokuro file, which you can open in a browser.

You can also run mokuro multiple individual volumes like this:

mokuro "/path/to/manga/vol1" "/path/to/manga/vol2" "/path/to/manga/vol3"

For each volume, a separate mokuro file will be generated.

Run on a directory containing multiple volumes

If your directory structure looks somewhat like this:

manga/
├─vol1/
├─vol2/
├─vol3/
└─vol4/

You can process all volumes by running:

mokuro --parent_dir "/path/to/manga/"

Other options

--pretrained_model_name_or_path: Name or path of the manga-ocr model.
--force_cpu: Force the use of CPU even if CUDA is available.
--disable_confirmation: Disable confirmation prompt. If False, the user will be prompted to confirm the list of volumes to be processed.
--disable_ocr: Disable OCR processing. Generate mokuro/HTML files without OCR results.
--ignore_errors: Continue processing volumes even if an error occurs.
--no_cache: Do not use cached OCR results from previous runs (_ocr directories).
--unzip: Extract volumes in zip/cbz format in their original location.
--legacy_html: Enable legacy HTML output.
--as_one_file: Applies only to legacy HTML. If False, generate separate CSS and JS files instead of embedding them in the HTML file.
--version: Print the version of mokuro and exit.

Legacy HTML vs. new .mokuro format

Before version 0.2.0, mokuro generated a separate HTML file for each processed volume, which caused some usability issues:

  • HTML files contained both the OCR results and the whole web reader GUI, so in order to update the GUI, all volumes needed to be updated with a new mokuro version
  • images were stored separately and linked in HTML files, so any change in the directory structure could break the links
  • transferring the manga to another device required transferring both the HTML files and the images
  • there was no unified GUI for a whole catalog containing multiple volumes
  • on some mobile devices, some workarounds were needed to open HTML files

Starting from version 0.2.0, a new .mokuro format is introduced, which is generated for each volume and contains only the OCR results and metadata necessary for the web reader GUI. Web reader is now a separate web app, which can open manga volumes with their associated .mokuro files.

The old HTML format is still generated for backward compatibility, but it will not be developed further, and it is recommended to use the new .mokuro format and the web reader.

Contact

For any inquiries, please feel free to contact me at [email protected]

Acknowledgments

About

Read Japanese manga inside browser with selectable text.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 51.1%
  • Python 43.2%
  • JavaScript 3.1%
  • Jupyter Notebook 1.7%
  • CSS 0.9%