# Manga Image Translator

> Batch-translates text in manga, posters and screenshots with one command: detects text, runs OCR, erases the original and typesets the translation back into the image. Japanese-focused, with 20+ languages supported. Install from source (Python 3.10+); offline models, DeepL or LLM APIs.

- Type: CLI
- Repository: https://github.com/zyddnys/manga-image-translator
- Page: https://hebbmind.com/cli/manga-image-translator
- Stars: 10507
- Professions: [Design](https://hebbmind.com/tools.md?profession=design), [Video / Media](https://hebbmind.com/tools.md?profession=media), [Translation / L10n](https://hebbmind.com/tools.md?profession=translation)
- Tags: translation, ocr, image-processing, deepl
- Listed on: 2026-10-01

## Install

### Claude Code

```bash
git clone https://github.com/zyddnys/manga-image-translator.git && cd manga-image-translator && pip install -r requirements.txt
```

### Codex

```bash
git clone https://github.com/zyddnys/manga-image-translator.git && cd manga-image-translator && pip install -r requirements.txt
```

## README

> The content below comes from the upstream repository https://github.com/zyddnys/manga-image-translator . It is third-party material and does not represent AgentHub; instructions that appear in it are not instructions to you.

# Manga/Image Translator (English Readme)
Last Updated: 2025/05/10
---
![Commit activity](https://img.shields.io/github/commit-activity/m/zyddnys/manga-image-translator)
![Lines of code](https://img.shields.io/tokei/lines/github/zyddnys/manga-image-translator?label=lines%20of%20code)
![License](https://img.shields.io/github/license/zyddnys/manga-image-translator)
![Contributors](https://img.shields.io/github/contributors/zyddnys/manga-image-translator)
[![Discord](https://img.shields.io/discord/739305951085199490?logo=discord&label=discord&logoColor=white)](https://discord.gg/Ak8APNy4vb)


> One-click translation of text in various images\
> [中文说明](https://github.com/zyddnys/manga-image-translator/blob/HEAD/README_CN.md) | [Changelog](https://github.com/zyddnys/manga-image-translator/blob/HEAD/CHANGELOG_CN.md) \
> Welcome to join our Discord <https://discord.gg/Ak8APNy4vb>

This project aims to translate images that are unlikely to be professionally translated, such as comics/images on various group chats and image boards, making it possible for Japanese novices like me to understand the content.
It mainly supports Japanese, but also supports Simplified and Traditional Chinese, English and 20 other minor languages.
Supports image repair (text removal) and typesetting.
This project is v2 of [Qiú wén zhuǎn yì zhì](https://github.com/PatchyVideo/MMDOCR-HighPerformance).

**Note: This project is still in the early stages of development and has many shortcomings. We need your help to improve it!**


## 📂 Directory

*   [Showcase](#showcase)
*   [Online Version](#online-version)
*   [Rust Version](#rust-version)
*   [Installation](#installation)
    *   [Local Setup](#local-setup)
        *   [Using Pip/venv (Recommended)](#using-pipvenv-recommended)
        *   [Notes for Windows Users](#notes-for-windows-users)
    *   [Docker](#docker)
        *   [Run Web Server](#run-web-server)
            *   [Using Nvidia GPU](#using-nvidia-gpu)
        *   [Use as CLI](#use-as-cli)
        *   [Build Locally](#build-locally)
*   [Usage](#usage)
    *   [Local (Batch) Mode](#local-batch-mode)
    *   [Web Mode](#web-mode)
        *   [Old UI](#old-ui)
        *   [New UI](#new-ui)
    *   [API Mode](#api-mode)
        *   [API Documentation](#api-documentation)
    *   [Config-help Mode](#config-help-mode)
*   [Option and Configuration](#option-and-configuration)
    *   [Recommended Options](#recommended-options)
        *   [Tips to Improve Translation Quality](#tips-to-improve-translation-quality)
    *   [Command Line Options](#command-line-options)
        *   [Basic Options](#basic-options)
        *   [Additional Options](#additional-options)
            *   [Local Mode Options](#local-mode-options)
            *   [WebSocket Mode Options](#websocket-mode-options)
            *   [API Mode Options](#api-mode-options)
            *   [Web Mode Options](#web-mode-options-missing-some-basic-options-still-needs-to-be-added)
    *   [Configuration File](#configuration-file)
        *   [Render Options](#render-options)
        *   [Upscale Options](#upscale-options)
        *   [Translator Options](#translator-options)
        *   [Detector Options](#detector-options)
        *   [Inpainter Options](#inpainter-options)
        *   [Colorizer Options](#colorizer-options)
        *   [OCR Options](#ocr-options)
        *   [Other Options](#other-options)
    *   [Language Code Reference](#language-code-reference)
    *   [Translator Reference](#translator-reference)
    *   [Glossary](#glossary)
    *   [Replacement Dictionary](#replacement-dictionary)
    *   [Environment Variables Summary](#environment-variables-summary)
    *   [GPT Configuration Reference](#gpt-configuration-reference)
    *   [Rendering with Gimp](#rendering-with-gimp)
*   [Future Plans](#future-plans)
*   [Support Us](#support-us)
    *   [Thanks to all contributors](#thanks-to-all-contributors)
*   [Star Growth Curve](#star-growth-curve)

## Showcase

The following examples may not be frequently updated and may not represent the effect of the current main branch version.

<table>
  <thead>
    <tr>
      <th align="center" width="50%">Original Image</th>
      <th align="center" width="50%">Translated Image</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td align="center" width="50%">
        <a href="https://user-images.githubusercontent.com/31543482/232265329-6a560438-e887-4f7f-b6a1-a61b8648f781.png">
          <img alt="佐藤さんは知っていた - 猫麦" src="https://user-images.githubusercontent.com/31543482/232265329-6a560438-e887-4f7f-b6a1-a61b8648f781.png" />
        </a>
        <br />
        <a href="https://twitter.com/09ra_19ra/status/1647079591109103617/photo/1">(Source @09ra_19ra)</a>
      </td>
      <td align="center" width="50%">
        <a href="https://user-images.githubusercontent.com/31543482/232265339-514c843a-0541-4a24-b3bc-1efa6915f757.png">
          <img alt="Output" src="https://user-images.githubusercontent.com/31543482/232265339-514c843a-0541-4a24-b3bc-1efa6915f757.png" />
        </a>
        <br />
        <a href="https://user-images.githubusercontent.com/31543482/232265376-01a4557d-8120-4b6b-b062-f271df177770.png">(Mask)</a>
      </td>
    </tr>
    <tr>
      <td align="center" width="50%">
        <a href="https://user-images.githubusercontent.com/31543482/232265479-a15c43b5-0f00-489c-9b04-5dfbcd48c432.png">
          <img alt="Gris finds out she's of royal blood - VERTI" src="https://user-images.githubusercontent.com/31543482/232265479-a15c43b5-0f00-489c-9b04-5dfbcd48c432.png" />
        </a>
        <br />
        <a href="https://twitter.com/VERTIGRIS_ART/status/1644365184142647300/photo/1">(Source @VERTIGRIS_ART)</a>
      </td>
      <td align="center" width="50%">
        <a href="https://user-images.githubusercontent.com/31543482/232265480-f8ba7a28-846f-46e7-8041-3dcb1afe3f67.png">
          <img alt="Output" src="https://user-images.githubusercontent.com/31543482/232265480-f8ba7a28-846f-46e7-8041-3dcb1afe3f67.png" />
        </a>
        <br />
        <code>--detector ctd</code>
        <a href="https://user-images.githubusercontent.com/31543482/232265483-99ad20af-dca8-4b78-90f9-a6599eb0e70b.png">(Mask)</a>
      </td>
    </tr>
    <tr>
      <td align="center" width="50%">
        <a href="https://user-images.githubusercontent.com/31543482/232264684-5a7bcf8e-707b-4925-86b0-4212382f1680.png">
          <img alt="陰キャお嬢様の新学期🏫📔🌸 (#3) - ひづき夜宵🎀💜" src="https://user-images.githubusercontent.com/31543482/232264684-5a7bcf8e-707b-4925-86b0-4212382f1680.png" />
        </a>
        <br />
        <a href="https://twitter.com/hiduki_yayoi/status/1645186427712573440/photo/2">(Source @hiduki_yayoi)</a>
      </td>
      <td align="center" width="50%">
        <a href="https://user-images.githubusercontent.com/31543482/232264644-39db36c8-a8d9-4009-823d-bf85ca0609bf.png">
          <img alt="Output" src="https://user-images.githubusercontent.com/31543482/232264644-39db36c8-a8d9-4009-823d-bf85ca0609bf.png" />
        </a>
        <br />
        <code>--translator none</code>
        <a href="https://user-images.githubusercontent.com/31543482/232264671-bc8dd9d0-8675-4c6d-8f86-0d5b7a342233.png">(Mask)</a>
      </td>
    </tr>
    <tr>
      <td align="center" width="50%">
        <a href="https://user-images.githubusercontent.com/31543482/232265794-5ea8a0cb-42fe-4438-80b7-3bf7eaf0ff2c.png">
          <img alt="幼なじみの高校デビューの癖がすごい (#1) - 神吉李花☪️🐧" src="https://user-images.githubusercontent.com/31543482/232265794-5ea8a0cb-42fe-4438-80b7-3bf7eaf0ff2c.png" />
        </a>
        <br />
        <a href="https://twitter.com/rikak/status/1642727617886556160/photo/1">(Source @rikak)</a>
      </td>
      <td align="center" width="50%">
        <a href="https://user-images.githubusercontent.com/31543482/232265795-4bc47589-fd97-4073-8cf4-82ae216a88bc.png">
          <img alt="Output" src="https://user-images.githubusercontent.com/31543482/232265795-4bc47589-fd97-4073-8cf4-82ae216a88bc.png" />
        </a>
        <br />
        <a href="https://user-images.githubusercontent.com/31543482/232265800-6bdc7973-41fe-4d7e-a554-98ea7ca7a137.png">(Mask)</a>
      </td>
    </tr>
  </tbody>
</table>

## Online Version

Official demo site (maintained by zyddnys): <https://touhou.ai/imgtrans/>\
Browser script (maintained by QiroNT): <https://greasyfork.org/scripts/437569>

- Note: If the online version is inaccessible, it might be due to Google GCP restarting the server. Please wait a moment for the service to restart.
- The online version uses the latest version from the main branch.

## Rust Version

[Manga Image Translator Rust](https://github.com/frederik-uni/manga-image-translator-rust) may be easier to setup as its a compiled binary

- Note: stable diffusion is not rewritten yet & only a cli version is available

## Installation

### Local Setup

#### Using Pip/venv (Recommended)

```bash
# First, ensure you have Python 3.12 or later installed on your machine
# The very latest version of Python might not be compatible with some PyTorch libraries yet
$ python --version
Python 3.13.16

# Clone this repository
$ git clone https://github.com/zyddnys/manga-image-translator.git

# Create a venv (optional, but recommended)
$ python -m venv venv

# Activate the venv
$ source venv/bin/activate

# If you want to use the --use-gpu option, please visit https://pytorch.org/get-started/locally/ to install PyTorch, which needs to correspond to your CUDA version.
# If you did not use venv to create a virtual environment, you need to add --upgrade --force-reinstall to the pip command to overwrite the currently installed PyTorch version.

# Install dependencies
$ pip install -r requirements.txt
```

Dependencies are pinned to current releases. `websockets` stays on the latest 16.x release because `google-genai` requires `<17`. `pydensecrf` is built from the [Python 3.13 / Cython 3 source branch](https://github.com/zyddnys/pydensecrf/tree/fix/python313-cython3); install Git and a C++ compiler before running pip (for example, `sudo apt install git build-essential` on Ubuntu). Pip installs its Cython build dependency automatically.

Models will be automatically downloaded to the `./models` directory at runtime.

#### Notes for Windows Users:

Please install Microsoft C++ Build Tools ([Download](https://visualstudio.microsoft.com/vs/), [Instructions](https://stackoverflow.com/questions/40504552/how-to-install-visual-c-build-tools)) before performing the pip install, as some pip dependencies need it to compile. (See [#114](https://github.com/zyddnys/manga-image-translator/issues/114)).

To use [CUDA](https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64) on Windows, install the correct PyTorch version as described on <https://pytorch.org/get-started/locally/>.

### Docker

Requirements:

- Docker (19.03+ for CUDA / GPU acceleration)
- Docker Compose (Optional, if you want to use the files in `demo/doc` folder)
- Nvidia Container Runtime (Optional, if you want to use CUDA)

This project supports Docker, with the image being `zyddnys/manga-image-translator:main`.
This Docker image contains all the dependencies and models required for the project.
Please note that this image is quite large (~15GB).

#### Run Web Server

You can start the Web Server (CPU) using the following command:
> Note that you need to add the required environment variables using `-e` or `--env`

```bash
docker run \
  --name manga_image_translator_cpu \
  -p 5003:5003 \
  --ipc=host \
  --entrypoint python \
  --rm \
  -v /demo/doc/../../result:/app/result \
  -v /demo/doc/../../server/main.py:/app/server/main.py \
  -v /demo/doc/../../server/instance.py:/app/server/instance.py \
  -e OPENAI_API_KEY='' \
  -e OPENAI_API_BASE='' \
  zyddnys/manga-image-translator:main \
  server/main.py --verbose --start-instance --host=0.0.0.0 --port=5003
```

Or use the compose file
> Note that you need to add the required environment variables in the file first

```bash
docker-compose -f demo/doc/docker-compose-web-with-cpu.yml up
```

The Web Server starts on port [8000](http://localhost:8000) by default, and the translation results will be saved in the `/result` folder.

##### Using Nvidia GPU

> To use a supported GPU, please read the `Docker` section above first. You will need some special dependencies.

You can start the Web Server (GPU) using the following command:
> Note that you need to add the required environment variables using `-e` or `--env`

```bash
docker run \
  --name manga_image_translator_gpu \
  -p 5003:5003 \
  --ipc=host \
  --gpus all \
  --entrypoint python \
  --rm \
  -v /demo/doc/../../result:/app/result \
  -v /demo/doc/../../server/main.py:/app/server/main.py \
  -v /demo/doc/../../server/instance.py:/app/server/instance.py \
  -e OPENAI_API_KEY='' \
  -e OPENAI_API_BASE='' \
  -e OPENAI_HTTP_PROXY='' \
  zyddnys/manga-image-translator:main \
  server/main.py --verbose --start-instance --host=0.0.0.0 --port=5003 --use-gpu
```

Or use the compose file (for Web Server + GPU):
> Note that you need to add the required environment variables in the file first

```bash
docker-compose -f demo/doc/docker-compose-web-with-gpu.yml up
```

#### Use as CLI

To use Docker via CLI (i.e., Batch Mode):
> Some translation services require API keys to run, pass them to your docker container as environment variables.

```bash
docker run --env="DEEPL_AUTH_KEY=xxx" -v <targetFolder>:/app/<targetFolder> -v <targetFolder>-translated:/app/<targetFolder>-translated  --ipc=host --rm zyddnys/manga-image-translator:main local -i=/app/<targetFolder> <cli flags>
```

**Note:** If you need to reference files on your host, you will need to mount the relevant files as volumes into the `/app` folder inside the container. The CLI paths will need to be the internal Docker path `/app/...` and not the path on your host.

#### Build Locally

To build the docker image locally, you can run the following command (you need to have make tool installed on your machine):

```bash
make build-image
```

Then test the built image, run:
> Some translation services require API keys to run, pass them to your docker container as environment variables. Add environment variables in the Dockerfile.
```bash
make run-web-server
```

## Usage

### Local (Batch) Mode
```bash
# Replace <path> with the path to your image folder or file.
$ python -m manga_translator local -v -i <path>
# The results can be found in `<path_to_image_folder>-translated`.
```
### Web Mode
#### Old UI
```bash
# Start a web server.
$ cd server
$ python main.py --use-gpu
# The web demo service address is http://127.0.0.1:8000
```
#### New UI
[Documentation](https://github.com/zyddnys/manga-image-translator/blob/HEAD/main/front/README.md)

### API Mode
```bash
# Start a web server.
$ cd server
$ python main.py --use-gpu
# The API service address is http://127.0.0.1:8001
```
#### API Documentation

Read the openapi documentation at: `127.0.0.1:8000/docs`

[FastAPI-html](https://cfbed.1314883.xyz/file/1741386061808_FastAPI%20-%20Swagger%20UI.html)

### Config-help Mode
```bash
python -m manga_translator config-help
```

## Options and Configuration Description
### Recommended Options

Detector:

- English: ??
- Japanese: ??
- Chinese (Simplified): ??
- Korean: ??
- Using `{"detector":{"detector": "ctd"}}` can increase the number of text lines detected
Update: Actual testing shows that default works better with related parameter adjustments in black and white comics.

OCR:

- English: ??
- Japanese: 48px
- Chinese (Simplified): ??
- Korean: 48px

Translator:

- Japanese -> English: **Sugoi**
- Chinese (Simplified) -> English: ??
- Chinese (Simplified) -> Japanese: ??
- Japanese -> Chinese (Simplified): sakura or opanai
- English -> Japanese: ??
- English -> Chinese (Simplified): ??

Inpainter: lama_large

Colorizer: **mc2**

#### Tips to Improve Translation Quality

-   Small resolutions can sometimes trip up the detector, which is not so good at picking up irregular text sizes. To		
  circumvent this you can use an upscaler by specifying `upscale_ratio 2` or any other value
-   If the rendered text is too small to read, specify `font_size_offset` or use the `--manga2eng` renderer, which will try to fit the detected text bubble rather than detected textline area.
-   Specify a font with `--font-path fonts/anime_ace_3.ttf` for example	
-   Set `mask_dilation_offset` to 10~30 to increase the mask coverage and better wrap the source text
-   change inpainter.
-   Increasing the `box_threshold` can help filter out gibberish from OCR error detection to some extent.
-   Use `OpenaiTranslator` to load the glossary file (`custom_openai` cannot load it)
-   When the image resolution is low, lower `detection_size`, otherwise it may cause some sentences to be missed. The opposite is true when the image resolution is high.
-   When the image resolution is high, increase `inpainting_size`, otherwise it may not completely cover the mask, resulting in source text leakage. In other cases, you can increase `kernel_size` to reduce the accuracy of text removal so that the model gets a larger field of view (Note: Judge whether the text leakage is caused by inpainting based on the consistency between the source text and the translated text. If consistent, it is caused by inpainting, otherwise it is caused by text detection and OCR)

### Command Line Options

#### Basic Options

```text
-h, --help                     show this help message and exit
-v, --verbose                  print debug messages and save intermediate images in results folder
--attempts ATTEMPTS            Number of attempts when an error occurs. -1 for infinite attempts.
--ignore-errors                Skip images when an error occurs.
--model-dir MODEL_DIR          Model directory (defaults to ./models in the project root)
--use-gpu                      Turns on/off GPU (automatically switches between mps and cuda)
--use-gpu-limited              Turns on/off GPU (excluding offline translators)
--font-path FONT_PATH          Path to the font file
--pre-dict PRE_DICT            Path to the pre-translation replacement dictionary file
--post-dict POST_DICT          Path to the post-translation replacement dictionary file
--kernel-size KERNEL_SIZE      Set the kernel size for the convolution of text erasure area to completely clear residual text
--context-size                 Pages of context are needed for translating the current page. currently, this only applies to openaitranslator. 
```
#### Additional Options
##### Local Mode Options

```text
local                         run in batch translation mode
-i, --input INPUT [INPUT ...] Image folder path (required)
-o, --dest DEST               Destination folder path for translated images (default: '')
-f, --format FORMAT           Output format for the translation. Options: [List OUTPUT_FORMATS here, png,webp,jpg,jpeg,xcf,psd,pdf]
--overwrite                   Overwrite already translated images
--skip-no-text                Skip images with no text (won't be saved).
--use-mtpe                    Turn on/off Machine Translation Post-Editing (MTPE) on the command line (currently Linux only)
--save-text                   Save extracted text and translations to a text file.
--load-text                   Load extracted text and translations from a text file.
--save-text-file SAVE_TEXT_FILE  Similar to --save-text, but with a specified file path. (default: '')
--prep-manual                 Prepare for manual typesetting by outputting blanked, inpainted images, and copies of the original image for reference
--save-quality SAVE_QUALITY   Quality of saved JPEG images, from 0 to 100 where 100 is best (default: 100)
--config-file CONFIG_FILE     Path to a configuration file (default: None)
```

##### WebSocket Mode Options

```text
ws                  run in WebSocket mode
--host HOST         Host of the WebSocket service (default: 127.0.0.1)
--port PORT         Port of the WebSocket service (default: 5003)
--nonce NONCE       Nonce used to secure internal WebSocket communication
--ws-url WS_URL     Server URL for WebSocket mode (default: ws://localhost:5000)
--models-ttl MODELS_TTL  Time in seconds to keep models in memory after last use (0 means forever)
```

##### API Mode Options

```text
shared              run in API mode
--host HOST         Host of the API service (default: 127.0.0.1)
--port PORT         Port of the API service (default: 5003)
--nonce NONCE       Nonce used to secure internal API server communication, set to "None" to disable
--report REPORT     Report to server to register instance (default: None)
--models-ttl MODELS_TTL  TTL of models in memory in seconds (0 means forever)
```

##### Web Mode Options (missing some basic options, still needs to be added)

```text
--host HOST           Host address (default: 127.0.0.1)
--port PORT           Port number (default: 8000)
--start-instance      Whether an instance of the translator should be started automatically
--nonce NONCE         Nonce used to secure internal Web Server communication, set to "None" to disable
--models-ttl MODELS_TTL  Time in seconds to keep models in memory after last use (0 means forever)
```


### Configuration File

Run `python -m manga_translator config-help >> config-info.json` to see the documentation for the JSON schema
An example config file can be found in example/config-example.json

<details>
  <summary>Expand the full config JSON</summary>
  <pre><code class="language-json">{
  "$defs": {
    "Alignment": {
      "enum": [
        "auto",
        "left",
        "center",
        "right"
      ],
      "title": "Alignment",
      "type": "string"
    },
    "Colorizer": {
      "enum": [
        "none",
        "mc2"
      ],
      "title": "Colorizer",
      "type": "string"
    },
    "ColorizerConfig": {
      "properties": {
        "colorization_size": {
          "default": 576,
          "title": "Colorization Size",
          "type": "integer"
        },
        "denoise_sigma": {
          "default": 30,
          "title": "Denoise Sigma",
          "type": "integer"
        },
        "colorizer": {
          "$ref": "#/$defs/Colorizer",
          "default": "none"
        }
      },
      "title": "ColorizerConfig",
      "type": "object"
    },
    "Detector": {
      "enum": [
        "default",
        "dbconvnext",
        "ctd",
        "craft",
        "paddle",
        "none"
      ],
      "title": "Detector",
      "type": "string"
    },
    "DetectorConfig": {
      "properties": {
        "detector": {
          "$ref": "#/$defs/Detector",
          "default": "default"
        },
        "detection_size": {
          "default": 2048,
          "title": "Detection Size",
          "type": "integer"
        },
        "text_threshold": {
          "default": 0.5,
          "title": "Text Threshold",
          "type": "number"
        },
        "det_rotate": {
          "default": false,
          "title": "Det Rotate",
          "type": "boolean"
        },
        "det_auto_rotate": {
          "default": false,
          "title": "Det Auto Rotate",
          "type": "boolean"
        },
        "det_invert": {
          "default": false,
          "title": "Det Invert",
          "type": "boolean"
        },
        "det_gamma_correct": {
          "default": false,
          "title": "Det Gamma Correct",
          "type": "boolean"
        },
        "box_threshold": {
          "default": 0.75,
          "title": "Box Threshold",
          "type": "number"
        },
        "unclip_ratio": {
          "default": 2.3,
          "title": "Unclip Ratio",
          "type": "number"
        }
      },
      "title": "DetectorConfig",
      "type": "object"
    },
    "Direction": {
      "enum": [
        "auto",
        "horizontal",
        "vertical"
      ],
      "title": "Direction",
      "type": "string"
    },
    "InpaintPrecision": {
      "enum": [
        "fp32",
        "fp16",
        "bf16"
      ],
      "title": "InpaintPrecision",
      "type": "string"
    },
    "Inpainter": {
      "enum": [
        "default",
        "lama_large",
        "lama_mpe",
        "sd",
        "none",
        "original"
      ],
      "title": "Inpainter",
      "type": "string"
    },
    "InpainterConfig": {
      "properties": {
        "inpainter": {
          "$ref": "#/$defs/Inpainter",
          "default": "lama_large"
        },
        "inpainting_size": {
          "default": 2048,
          "title": "Inpainting Size",
          "type": "integer"
        },
        "inpainting_precision": {
          "$ref": "#/$defs/InpaintPrecision",
          "default": "bf16"
        }
      },
      "title": "InpainterConfig",
      "type": "object"
    },
    "Ocr": {
      "enum": [
        "32px",
        "48px",
        "48px_ctc",
        "mocr"
      ],
      "title": "Ocr",
      "type": "string"
    },
    "OcrConfig": {
      "properties": {
        "use_mocr_merge": {
          "default": false,
          "title": "Use Mocr Merge",
          "type": "boolean"
        },
        "ocr": {
          "$ref": "#/$defs/Ocr",
          "default": "48px"
        },
        "min_text_length": {
          "default": 0,
          "title": "Min Text Length",
          "type": "integer"
        },
        "ignore_bubble": {
          "default": 0,
          "title": "Ignore Bubble",
          "type": "integer"
        }
      },
      "title": "OcrConfig",
      "type": "object"
    },
    "RenderConfig": {
      "properties": {
        "renderer": {
          "$ref": "#/$defs/Renderer",
          "default": "default"
        },
        "alignment": {
          "$ref": "#/$defs/Alignment",
          "default": "auto"
        },
        "disable_font_border": {
          "default": false,
          "title": "Disable Font Border",
          "type": "boolean"
        },
        "font_size_offset": {
          "default": 0,
          "title": "Font Size Offset",
          "type": "integer"
        },
        "font_size_minimum": {
          "default": -1,
          "title": "Font Size Minimum",
          "type": "integer"
        },
        "direction": {
          "$ref": "#/$defs/Direction",
          "default": "auto"
        },
        "uppercase": {
          "default": false,
          "title": "Uppercase",
          "type": "boolean"
        },
        "lowercase": {
          "default": false,
          "title": "Lowercase",
          "type": "boolean"
        },
        "gimp_font": {
          "default": "Sans-serif",
          "title": "Gimp Font",
          "type": "string"
        },
        "no_hyphenation": {
          "default": false,
          "title": "No Hyphenation",
          "type": "boolean"
        },
        "font_color": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Font Color"
        },
        "line_spacing": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Line Spacing"
        },
        "font_size": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Font Size"
        },
        "rtl": {
          "default": false,
          "title": "Rtl",
          "type": "boolean"
        }
      },
      "title": "RenderConfig",
      "type": "object"
    },
    "Renderer": {
      "enum": [
        "default",
        "manga2eng",
        "none"
      ],
      "title": "Renderer",
      "type": "string"
    },
    "Translator": {
      "enum": [
        "youdao",
        "baidu",
        "deepl",
        "papago",
        "caiyun",
        "chatgpt",
        "none",
        "original",
        "sakura",
        "deepseek",
        "groq",
        "atlascloud",
        "custom_openai",
        "offline",
        "nllb",
        "nllb_big",
        "sugoi",
        "jparacrawl",
        "jparacrawl_big",
        "m2m100",
        "m2m100_big",
        "m2m100_hf",
        "m2m100_hf_big",
        "mbart50",
        "qwen2",
        "qwen2_big"
      ],
      "title": "Translator",
      "type": "string"
    },
    "TranslatorConfig": {
      "properties": {
        "translator": {
          "$ref": "#/$defs/Translator",
          "default": "sugoi"
        },
        "target_lang": {
          "default": "CHS",
          "title": "Target Lang",
          "type": "string"
        },
        "no_text_lang_skip": {
          "default": false,
          "title": "No Text Lang Skip",
          "type": "boolean"
        },
        "skip_lang": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Skip Lang"
        },
        "gpt_config": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Gpt Config"
        },
        "translator_chain": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Translator Chain"
        },
        "selective_translation": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Selective Translation"
        }
      },
      "title": "TranslatorConfig",
      "type": "object"
    },
    "UpscaleConfig": {
      "properties": {
        "upscaler": {
          "$ref": "#/$defs/Upscaler",
          "default": "esrgan"
        },
        "revert_upscaling": {
          "default": false,
          "title": "Revert Upscaling",
          "type": "boolean"
        },
        "upscale_ratio": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Upscale Ratio"
        }
      },
      "title": "UpscaleConfig",
      "type": "object"
    },
    "Upscaler": {
      "enum": [
        "waifu2x",
        "esrgan",
        "4xultrasharp"
      ],
      "title": "Upscaler",
      "type": "string"
    }
  },
  "properties": {
    "filter_text": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Filter Text"
    },
    "render": {
      "$ref": "#/$defs/RenderConfig",
      "default": {
        "renderer": "default",
        "alignment": "auto",
        "disable_font_border": false,
        "font_size_offset": 0,
        "font_size_minimum": -1,
        "direction": "auto",
        "uppercase": false,
        "lowercase": false,
        "gimp_font": "Sans-serif",
        "no_hyphenation": false,
        "font_color": null,
        "line_spacing": null,
        "font_size": null,
        "rtl": true
      }
    },
    "upscale": {
      "$ref": "#/$defs/UpscaleConfig",
      "default": {
        "upscaler": "esrgan",
        "revert_upscaling": false,
        "upscale_ratio": null
      }
    },
    "translator": {
      "$ref": "#/$defs/TranslatorConfig",
      "default": {
        "translator": "sugoi",
        "target_lang": "CHS",
        "no_text_lang_skip": false,
        "skip_lang": null,
        "gpt_config": null,
        "translator_chain": null,
        "selective_translation": null
      }
    },
    "detector": {
      "$ref": "#/$defs/DetectorConfig",
      "default": {
        "detector": "default",
        "detection_size": 2048,
        "text_threshold": 0.5,
        "det_rotate": false,
        "det_auto_rotate": false,
        "det_invert": false,
        "det_gamma_correct": false,
        "box_threshold": 0.75,
        "unclip_ratio": 2.3
      }
    },
    "colorizer": {
      "$ref": "#/$defs/ColorizerConfig",
      "default": {
        "colorization_size": 576,
        "denoise_sigma": 30,
        "colorizer": "none"
      }
    },
    "inpainter": {
      "$ref": "#/$defs/InpainterConfig",
      "default": {
        "inpainter": "lama_large",
        "inpainting_size": 2048,
      }
    },
    "ocr": {
      "$ref": "#/$defs/OcrConfig",
      "default": {
        "use_mocr_merge": false,
        "ocr": "48px",
        "min_text_length": 0,
        "ignore_bubble": 0
      }
    },
    "kernel_size": {
      "default": 3,
      "title": "Kernel Size",
      "type": "integer"
    },
    "mask_dilation_offset": {
      "default": 30,
      "title": "Mask Dilation Offset",
      "type": "integer"
    }
  },
  "title": "Config",
  "type": "object"
}</code></pre>
</details>

#### Render Options
```
renderer          Renders translated text from manga and does additional typesetting. Will override some other param options
alignment         Align rendered text
disable_font_border Disable font border
font_size_offset  Offset for font size, positive increases font size, negative decreases
font_size_minimum Minimum output font size. Defaults to image longer side / 200
direction         Force horizontal/vertical text rendering or not specify
uppercase         Converts text to uppercase
lowercase         Converts text to lowercase
gimp_font         Font family used for GIMP rendering
no_hyphenation    Whether to disable hyphenation by the renderer
font_color        Overrides the text foreground/background color detected by the OCR model. Use a hex string without "#", e.g., FFFFFF: for white foreground, :000000 for black background, FFFFFF:000000 to set both.
line_spacing      Line spacing is font size * this value. Default is 0.01 for horizontal, 0.2 for vertical text
font_size         Use a fixed font size for rendering
rtl               Right-to-left reading order for panel and text_region sorting. Defalt is true
```

#### Upscale Options
```
upscaler          The upscaler to use. Requires --upscale-ratio to be set to be active
revert_upscaling  Scale the image back down to original size after translating if upscaled before (works with --upscale-ratio)
upscale_ratio     Image upscale ratio to apply before detection. Can improve text detection performance
```

#### Translator Options
```
translator        The language translator to use
target_lang       The target language
no_text_lang_skip Do not skip text that appears to be the target language
skip_lang         Skip translation if the source image is one of the specified languages, comma-separated for multiple languages. Example: JPN,ENG
gpt_config        Path to GPT config file, see README for more info
translator_chain  Output of one translator is input to another until translated to target language. Example: --translator-chain "google:JPN;sugoi:ENG"
selective_translation Select translator based on language detected in image. Note that if a language isn't defined, the first translation service will be used as a default. Example: --translator-chain "google:JPN;sugoi:ENG"
```

#### Detector Options
```
detector          The text detector to use to create a text mask from the image, don't use craft for manga, it's not designed for that
detection_size    The size of the image to use for detection
text_threshold    Text detection threshold
det_rotate        Rotate image for detection. Can improve detection
det_auto_rotate   Rotate image to prioritize detection of vertical text lines. Can improve detection
det_invert        Invert image colors for detection. Can improve detection
det_gamma_correct Apply gamma correction for detection. Can improve detection
box_threshold     Threshold for bounding box generation
unclip_ratio      How much to expand the text skeleton to form a bounding box
```

#### Inpainter Options
```
inpainter         The inpainting model to use
inpainting_size   The size of the image to use for inpainting (too large can cause out of memory)
inpainting_precision Precision for lama inpainting, bf16 is an option
```

#### Colorizer Options
```
colorization_size The size of the image to use for colorization. Set to -1 to use the full image size
denoise_sigma     Used for colorizer and affects color intensity, ranging from 0 to 255 (default 30). -1 to disable
colorizer         The colorization model to use
```

#### OCR Options
```
use_mocr_merge    Use bounding box merging during Manga OCR inference
ocr               The Optical Character Recognition (OCR) model to use
min_text_length   Minimum text length for a text area
ignore_bubble     Threshold for ignoring non-bubble area text, valid values range from 1-50. Recommended 5 to 10. If too low, normal bubble areas might be ignored, if too large, non-bubble areas might be treated as normal bubbles
```

#### Other Options
```
filter_text       Filter text areas using a regular expression. Example usage: '.*badtext.*'
kernel_size       Set the kernel size for the convolution of text erasure area to completely clear residual text
mask_dilation_offset Amount to expand the text mask to remove remaining text pixels in the original image
```


#### Language Code Reference

Used by `translator/language` in config

```yaml
CHS: Simplified Chinese
CHT: Traditional Chinese
CSY: Czech
NLD: Dutch
ENG: English
FRA: French
DEU: German
HUN: Hungarian
ITA: Italian
JPN: Japanese
KOR: Korean
POL: Polish
PTB: Portuguese (Brazilian)
ROM: Romanian
RUS: Russian
ESP: Spanish
TRK: Turkish
UKR: Ukrainian
VIN: Vietnamese
ARA: Arabic
SRP: Serbian
HRV: Croatian
THA: Thai
IND: Indonesian
FIL: Filipino (Tagalog)
```

#### Translator Reference
| Name | API Key | Offline | Note |
|---------------|---------|---------|----------------------------------------------------------|
| <s>google</s> | | | Temporarily disabled |
| youdao | ✔️ | | Requires `YOUDAO_APP_KEY` and `YOUDAO_SECRET_KEY` |
| baidu | ✔️ | | Requires `BAIDU_APP_ID` and `BAIDU_SECRET_KEY` |
| deepl | ✔️ | | Requires `DEEPL_AUTH_KEY` |
| caiyun | ✔️ | | Requires `CAIYUN_TOKEN` |
| chatgpt | ✔️ | | GPT-6 Luna only; requires `OPENAI_API_KEY`. Aliases: `openai`, `gpt-6-luna` |
| chatgpt_2stage | ✔️ | | GPT-6 Luna for both OCR correction and translation; requires `OPENAI_API_KEY` |
| deepseek | ✔️ | | Requires `DEEPSEEK_API_KEY` |
| groq | ✔️ | | Requires `GROQ_API_KEY` |
| atlascloud | ✔️ | | Requires `ATLASCLOUD_API_KEY` |
| gemini | ✔️ | | Requires `GEMINI_API_KEY` |
| papago | | | |
| sakura | | | Requires `SAKURA_API_BASE` |
| custom_openai | | | Requires `CUSTOM_OPENAI_API_BASE` `CUSTOM_OPENAI_MODEL` |
| offline | | ✔️ | Use the most suitable offline translator for the language|
| nllb | | ✔️ | Offline translation model |
| nllb_big | | ✔️ | Larger NLLB model |
| sugoi | | ✔️ | Sugoi V4.0 model |
| jparacrawl | | ✔️ | Japanese translation model |
| jparacrawl_big| | ✔️ | Larger Japanese translation model |
| m2m100 | | ✔️ | Supports multilingual translation (requires NVIDIA/ctranslate2) |
| m2m100_big | | ✔️ | Larger M2M100 model (requires NVIDIA/ctranslate2) |
| m2m100_hf | | ✔️ | M2M100 418M via HuggingFace — works on PyTorch (Nvidia CUDA / AMD ROCm) |
| m2m100_hf_big | | ✔️ | M2M100 1.2B via HuggingFace — works on PyTorch (Nvidia CUDA / AMD ROCm) |
| mbart50 | | ✔️ | Multilingual translation model |
| qwen2 | | ✔️ | Qwen2 model |
| qwen2_big | | ✔️ | Larger Qwen2 model |
| none | | ✔️ | Translate to empty text |
| original | | ✔️ | Keep original text |

-   API Key: Indicates whether the translator requires API keys to be set as environment variables.

> The README is long; the above is its first 40000 characters. Full content: https://github.com/zyddnys/manga-image-translator
