Skip to content

Commit

Permalink
v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dmMaze committed Aug 17, 2022
1 parent 509f624 commit e25c82a
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 46 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelogs

### 2022-08-17
[v1.3.0](https://github.com/dmMaze/BallonsTranslator/releases/tag/v1.3.0)发布

1. 修复DeepL翻译器的bug, 感谢[@Snowad14](https://github.com/Snowad14)
2. 修复部分字体偏小+轮廓导致看不清的问题
3. 支持**全局字体格式**(一键机翻字体格式): 在控制面板->嵌字菜单里将相应项从"由程序决定"改为"使用全局设置"后启用. 注意全局设置就是未编辑任何文本块时右侧字体格式面板的那些设置.
4. 添加**新的修复模型**: lama-mpe (默认启用)
5. 文本块支持多选和**批量调整格式** (ctrl+鼠标左键或者按下右键拉框框选)
6. 支持日译英, 英译中的**自动排版**, 基于提取出的背景气泡, 目标语言为中文时会自动断句(基于pkuseg). 勾选设置面板->常规->嵌字->自动排版后将对一键机翻生效(默认启用).

<img src="doc/src/multisel_autolayout.gif" div align=center>
<p align=center>
批量格式调整, 英译中自动断句分行
</p>

### 2022-05-19
[v1.2.0](https://github.com/dmMaze/BallonsTranslator/releases/tag/v1.2.0)发布

Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG_EN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelogs

### 2022-08-17
[v1.3.0](https://github.com/dmMaze/BallonsTranslator/releases/tag/v1.3.0) released


1. Fix deepl translator, thanks to [@Snowad14](https://github.com/Snowad14)
2. Fix font size & stroke bug which makes text unreadable
3. Support **global font format** (determine the font format settings used by auto-translation mode): in config panel->Lettering, change the corresponding option from "decide by the program" to "use global setting" to enable. Note global settings are those formats shown by the right font format panel when you are not editing any textblock in the scene.
4. Add **new inpainting model**: lama-mpe and set it as default.
5. Support multiple textblocks selection & formatting.
6. Improved manga->English, English->Chinese typesetting (**Auto-layout** in Config panel->Lettering, enabled by default), it can also be applied to selected text blocks use the option in the right-click menu.

<img src="doc/src/multisel_autolayout.gif" div align=center>
<p align=center>
batch text formatting & auto layout
</p>

### 2022-05-19
[v1.2.0](https://github.com/dmMaze/BallonsTranslator/releases/tag/v1.2.0) released

Expand Down
66 changes: 47 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
简体中文 | [English](README_EN.md)

深度学习辅助漫画翻译工具, 支持一键机翻和简单的图像/文本编辑
## 下载
[国内网盘](https://cowtransfer.com/s/b336741eec834b) | [Google Drive](https://drive.google.com/drive/folders/1uElIYRLNakJj-YS0Kd3r3HE-wzeEvrWd?usp=sharing)

<img src="doc/src/ui0.jpg" div align=center>

Expand All @@ -16,30 +14,51 @@
- 译文回填参考对原文排版的估计, 包括颜色, 轮廓, 角度, 朝向, 对齐方式等
- 最后效果取决于文本检测, 识别, 抹字, 机翻四个模块的整体表现
- 支持日漫和美漫
- 英译中, 日译英排版已优化, 文本布局以提取到的背景泡为参考, 中文基于pkuseg进行断句, 日译中竖排待改善

* 图像编辑
支持掩膜编辑和修复画笔

* 文本编辑
支持富文本编辑和一些基础排版格式调整


# 说明
# 使用说明

## 一键翻译
**建议在命令行终端下运行程序**, 首次运行请先配置好源语言/目标语言, 打开一个带图片的文件夹, 点击Run等待翻译完成
<img src="doc/src/run.gif">
### 发布版

Windows用户可从[腾讯云](https://share.weiyun.com/xoRhz9i4)[Google Drive](https://drive.google.com/drive/folders/1uElIYRLNakJj-YS0Kd3r3HE-wzeEvrWd?usp=sharing)下载发布包Ballonstranslator-x.x.x-core.7z, 如果分享文件夹内存在更高版本的Ballonstranslator-x.x.x-patch.7z, 下载patch并覆盖core即可.

### 运行源码

```bash
# 确保python<=3.9
$ python --version

# 克隆仓库
$ git clone https://github.com/dmMaze/BallonsTranslator.git

# 安装依赖
$ pip install -r requirements.txt
```

### 一键翻译结果预览
| Original | Translated |
| :-----------------------------------------------------------------------------------------: | :-------------------------: |
| ![Original](ballontranslator/data/testpacks/manga/original2.jpg 'https://twitter.com/mmd_96yuki/status/1320122899005460481') | ![Output](doc/src/result2.png) |
| ![Original](ballontranslator/data/testpacks/manga/original4.jpg 'https://amagi.fanbox.cc/posts/1904941') | ![Output](doc/src/result4.png) |
| ![Original](ballontranslator/data/testpacks/manga/AisazuNihaIrarenai-003.jpg) | ![Output](doc/src/AisazuNihaIrarenai-003.png) |
| ![Original](ballontranslator/data/testpacks/comics/006049.jpg) | ![Output](doc/src/006049.png) |
| ![Original](ballontranslator/data/testpacks/comics/006058.jpg) | ![Output](doc/src/006058.png) |
如果有N卡可以安装torch-cuda启用GPU加速:

```bash
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116
```

https://drive.google.com/drive/folders/1uElIYRLNakJj-YS0Kd3r3HE-wzeEvrWd?usp=sharing 下载**data**文件夹并移动到 ```BallonsTranslator/ballontranslator```目录, 最后运行
```bash
python ballontranslator/__main__.py
```

## 一键翻译
**建议在命令行终端下运行程序**, 首次运行请先配置好源语言/目标语言, 打开一个带图片的文件夹, 点击Run等待翻译完成
<img src="doc/src/run.gif">

一键机翻嵌字格式如大小、颜色等默认是由程序决定的, 可以在设置面板->嵌字菜单中改用全局设置. 全局字体格式就是未编辑任何文本块时右侧字体面板显示的格式:
<img src="doc/src/global_font_format.png">

## 画板

Expand Down Expand Up @@ -67,6 +86,11 @@
文本编辑
</p>

<img src="doc/src/multisel_autolayout.gif" div align=center>
<p align=center>
批量文本格式调整及自动排版
</p>

## 界面说明及快捷键
* Ctrl+Z, Ctrl+Y可以撤销重做大部分操作,注意翻页后撤消重做栈会清空
* A/D翻页, 如果当前页面未保存会自动保存
Expand All @@ -75,10 +99,11 @@
* 底部左侧"OCR"和"A"按钮控制启用/禁用OCR翻译功能, 禁用后再Run程序就只做文本检测和抹字
* 设置面板配置各自动化模块参数
* Ctrl++/-或滚轮缩放画布
* Ctrl+A可选中界面中所有文本块

<img src="doc/src/configpanel.png">

## 自动化模块
# 自动化模块
本项目重度依赖[manga-image-translator](https://github.com/zyddnys/manga-image-translator), 在线服务器和模型训练需要费用, 有条件请考虑支持一下
- Ko-fi: <https://ko-fi.com/voilelabs>
- Patreon: <https://www.patreon.com/voilelabs>
Expand All @@ -105,9 +130,12 @@
如需添加新的翻译器请参考[加别的翻译器](doc/加别的翻译器.md), 本程序添加新翻译器只需要继承基类实现两个接口即可不需要理会代码其他部分, 欢迎大佬提pr

##
* 发布包包含pytorch和cuda所以那么大. 以后更新如果依赖库不做变动, 就只发布本体二进制/新配置文件/新模型, 下载后覆盖旧版本
* 如果电脑带N卡, 程序默认对所有模型启用GPU加速, 默认配置下显存占用在6G左右. 4G显存调小修复器inpaint_size即可.

# TODO
- 支持更多语言的OCR模型
- ...
## 一键翻译结果预览
| Original | Translated (CHS) | Translated (ENG) |
| :-----------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------: |
|![Original](ballontranslator/data/testpacks/manga/original2.jpg 'https://twitter.com/mmd_96yuki/status/1320122899005460481')| ![Translated (CHS)](doc/src/result2.png) | ![Translated (ENG)](doc/src/original2_eng.png) |
|![Original](ballontranslator/data/testpacks/manga/original3.jpg 'https://twitter.com/_taroshin_/status/1231099378779082754')| ![Translated (CHS)](doc/src/original3.png) | ![Translated (ENG)](doc/src/original3_eng.png) |
| ![Original](ballontranslator/data//testpacks/manga/AisazuNihaIrarenai-003.jpg) | ![Translated (CHS)](doc/src/AisazuNihaIrarenai-003.png) | ![Translated (ENG)](doc/src/AisazuNihaIrarenai-003_eng.png) |
| ![Original](ballontranslator/data//testpacks/comics/006049.jpg) | ![Translated (CHS)](doc/src/006049.png) | |
73 changes: 48 additions & 25 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
[简体中文](README.md) | English

Yet another computer-aided comic/manga translation tool powered by deep learning.
## Download
[国内网盘](https://cowtransfer.com/s/b336741eec834b) | [Google Drive](https://drive.google.com/drive/folders/1uElIYRLNakJj-YS0Kd3r3HE-wzeEvrWd?usp=sharing)

<img src="doc/src/ui0.jpg" div align=center>

Expand All @@ -16,31 +14,47 @@ preview
- Support automatic text-detection, recognition, removal, and translation, overall performance is dependent upon these modules.
- lettering is based on the formatting estimation of the original text.
- Works decently with manga and comics.
- Improved manga->English, English->Chinese typesetting (based on the extraction of balloon regions.).

* Image editing
Support mask editing & inpainting (something like spot healing brush tool in PS)

* Text editing
Support rich text formatting.

Support rich text formatting, translated texts can be edited interactively.

# Usage

## Fully automated translation
**It is recommended to run the program in a terminal in case it crashed and left no information, see the following gif.**, Please select the desired translator and set the source and target languages the first time you run the application. Open a folder containing images that need translation, click the "Run" button and wait for the process to complete.
<img src="doc/src/run.gif">
Windows users can download Ballonstranslator-x.x.x-core.7z from [腾讯云](https://share.weiyun.com/xoRhz9i4) or [Google Drive](https://drive.google.com/drive/folders/1uElIYRLNakJj-YS0Kd3r3HE-wzeEvrWd?usp=sharing) and extract it to a folder named BallonTranslator, also download Ballonstranslator-x.x.x-patch.7z if there is any and extract it to the same folder.

## Run the source code

```bash
# First, you need to have Python(<=3.9 ) installed on your system.
$ python --version

### Previews of fully automated translation results
| Original | Translated |
| :-----------------------------------------------------------------------------------------: | :-------------------------: |
| ![Original](ballontranslator/data//testpacks/manga/original2.jpg 'https://twitter.com/mmd_96yuki/status/1320122899005460481') | ![Output](doc/src/result2.png) |
| ![Original](ballontranslator/data//testpacks/manga/original4.jpg 'https://amagi.fanbox.cc/posts/1904941') | ![Output](doc/src/result4.png) |
| ![Original](ballontranslator/data//testpacks/manga/AisazuNihaIrarenai-003.jpg) | ![Output](doc/src/AisazuNihaIrarenai-003.png) |
| ![Original](ballontranslator/data//testpacks/comics/006049.jpg) | ![Output](doc/src/006049.png) |
| ![Original](ballontranslator/data//testpacks/comics/006058.jpg) | ![Output](doc/src/006058.png) |
# Clone this repo
$ git clone https://github.com/dmMaze/BallonsTranslator.git

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

Install pytorch-cuda to enable GPU acceleration if you have a NVIDIA GPU.

```bash
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116
```

Download the **data** folder from https://drive.google.com/drive/folders/1uElIYRLNakJj-YS0Kd3r3HE-wzeEvrWd?usp=sharing and move it into BallonsTranslator/ballontranslator, finally run
```bash
python ballontranslator/__main__.py
```

## Fully automated translation
**It is recommended to run the program in a terminal in case it crashed and left no information, see the following gif.**, Please select the desired translator and set the source and target languages the first time you run the application. Open a folder containing images that need translation, click the "Run" button and wait for the process to complete.
<img src="doc/src/run.gif">

The font formats such as font size, color are determined by the program automatically in this process, you can predetermine those formats by change corresponding options from "decide by program" to "use global setting" in the config panel->Lettering.(global settings are those formats shown by the right font format panel when you are not editing any textblock in the scene)

## Image editing

Expand All @@ -65,6 +79,11 @@ The result depends on how accurately the algorithm ("method 1" and "method 2" in
Text editing mode
</p>

<img src="doc/src/multisel_autolayout.gif" div align=center>
<p align=center>
batch text formatting & auto layout
</p>

## Shortcuts
* A/D to turn the page
* Ctrl+Z, Ctrl+Y to undo/redo most operations, note the undo stack will be cleared after you turn the page.
Expand All @@ -77,37 +96,41 @@ Text editing mode

<img src="doc/src/configpanel.png">

## Automation modules

# Automation modules
This project is heavily dependent upon [manga-image-translator](https://github.com/zyddnys/manga-image-translator), online service and model training is not cheap, please consider to donate the project:
- Ko-fi: <https://ko-fi.com/voilelabs>
- Patreon: <https://www.patreon.com/voilelabs>
- 爱发电: <https://afdian.net/@voilelabs>

### Text detection
## Text detection
Support English and Japanese text detection, training code and more details can be found at [comic-text-detector](https://github.com/dmMaze/comic-text-detector)

### OCR
## OCR
* mit_32px text recognition model is from manga-image-translator, support English and Japanese recognition and text color extraction.
* mit_48px text recognition model is from manga-image-translator, support English, Japanese and Korean recognition and text color extraction.
* [manga_ocr](https://github.com/kha-white/manga-ocr) is from [kha-white](https://github.com/kha-white),

### Inpainting
## Inpainting
* AOT is from manga-image-translator
* patchmatch is a non-dl algrithom from [PyPatchMatch](https://github.com/vacancy/PyPatchMatch), this program use a [modified version](https://github.com/dmMaze/PyPatchMatchInpaint) by me.


### Translators
## Translators

* Please change the goolge translator url from *.cn to *.com if you are not blocked by GFW.
* Caiyun translator need to require a [token](https://dashboard.caiyunapp.com/)
* papago
To add a new translator, please reference [加别的翻译器](doc/加别的翻译器.md), it is simple as subclass a BaseClass and implementing two interfaces, then you can use it in the application, you are welcome to contribute to the project.


## Misc
* The release package contains PyTorch and cuda. For future updates, if no changes are made to the dependencies, only the new exe and models will be released, copy them to the program folder to get the grogram updated.
* If your computer has an Nvidia GPU, the program will enable cuda acceleration for all models by default, which requires around 6G GPU memory, you can turn down the inpaint_size in the config panel to avoid OOM.

# TODO
- Optimize for cpu
- New models to support more languages
- ...
## Previews of fully automated translation results
| Original | Translated (CHS) | Translated (ENG) |
| :-----------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------: |
|![Original](ballontranslator/data/testpacks/manga/original2.jpg 'https://twitter.com/mmd_96yuki/status/1320122899005460481')| ![Translated (CHS)](doc/src/result2.png) | ![Translated (ENG)](doc/src/original2_eng.png) |
|![Original](ballontranslator/data/testpacks/manga/original3.jpg 'https://twitter.com/_taroshin_/status/1231099378779082754')| ![Translated (CHS)](doc/src/original3.png) | ![Translated (ENG)](doc/src/original3_eng.png) |
| ![Original](ballontranslator/data//testpacks/manga/AisazuNihaIrarenai-003.jpg) | ![Translated (CHS)](doc/src/AisazuNihaIrarenai-003.png) | ![Translated (ENG)](doc/src/AisazuNihaIrarenai-003_eng.png) |
| ![Original](ballontranslator/data//testpacks/comics/006049.jpg) | ![Translated (CHS)](doc/src/006049.png) | |
2 changes: 1 addition & 1 deletion ballontranslator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# 1. MAJOR version when you make incompatible API changes;
# 2. MINOR version when you add functionality in a backwards-compatible manner;
# 3. PATCH version when you make backwards-compatible bug fixes.
__version__ = "1.1.3"
__version__ = "1.3.0"
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
nuitka --standalone --mingw64 --nofollow-imports --show-memory --show-progress ^
--enable-plugin=pyqt5 --include-qt-plugins=sensible,styles ^
--follow-import-to=dl,utils,ui --include-plugin-directory=ballontranslator/dl,ballontranslator/ui,ballontranslator/utils ^
--windows-product-version=1.2.0.0 --windows-company-name=DUMMY_WINDOWS_COMPANY_NAME --windows-product-name=BallonTranslator ^
--windows-product-version=1.3.0.0 --windows-company-name=DUMMY_WINDOWS_COMPANY_NAME --windows-product-name=BallonTranslator ^
--output-dir=release BallonTranslator

0 comments on commit e25c82a

Please sign in to comment.