0
stars
4
commits
Python
primary language
Jun 10, 2026
updated
MangaTranslator là công cụ dịch và render chữ cho manga/comic. Ứng dụng hỗ trợ xử lý từng ảnh, batch nhiều ảnh, xuất script để dịch thủ công bằng LLM, import lại script đã dịch để render, xử lý chữ ngoài bubble, upscale và decensor/inpaint.
Khuyến nghị Python 3.10, 3.11 hoặc 3.12. Trên Windows nên tạo virtual environment riêng.
cd F:\tool\MangaTranslator
py -3.12 -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
pip install -r requirements.txt
Nếu dùng GPU NVIDIA, cài PyTorch CUDA phù hợp với máy. Ví dụ CUDA 12.1:
pip install --index-url https://download.pytorch.org/whl/cu121 torch torchvision
Kiểm tra GPU:
nvidia-smi
python -c "import torch; print(torch.cuda.is_available()); print(torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'CPU')"
cd F:\tool\MangaTranslator
.\.venv\Scripts\Activate.ps1
python app.py --open-browser
Mặc định UI chạy tại:
http://127.0.0.1:7676
Đổi port:
python app.py --port 7860 --open-browser
Chạy CPU:
python app.py --cpu --open-browser
Nếu gặp lỗi thiếu font pack, tạo thư mục font theo cấu trúc:
fonts/
Arial/
arial.ttf
arialbd.ttf
ariali.ttf
arialbi.ttf
Trong UI, chọn font pack trong phần font/rendering. Nếu dịch tiếng Việt, nên dùng font hỗ trợ dấu tiếng Việt như Arial, Noto Sans, Roboto, Inter hoặc font Việt hóa bạn tự thêm.
Trong UI, vào phần provider/API:
Google, OpenAI, Anthropic, OpenRouter, hoặc provider bạn dùng.gemini-2.5-flash nếu dùng Google.Nếu dùng Google-compatible proxy, nhập đủ 2 field:
Google Proxy API Key = <proxy-api-key>
Google Proxy Base URL = <proxy-base-url>
Khi có đủ proxy key và proxy base URL, project sẽ gọi Gemini qua proxy thay vì gọi trực tiếp Google.
Có thể dùng biến môi trường:
$env:GOOGLE_API_KEY="AIzaSy..."
$env:GOOGLE_PROXY_API_KEY="<proxy-api-key>"
$env:GOOGLE_PROXY_BASE_URL="<proxy-base-url>"
Các biến môi trường khác:
OPENAI_API_KEY
ANTHROPIC_API_KEY
XAI_API_KEY
DEEPSEEK_API_KEY
ZAI_API_KEY
MOONSHOT_API_KEY
OPENROUTER_API_KEY
OPENAI_COMPATIBLE_API_KEY
Không commit API key, token, config cá nhân, output ảnh, model cache hoặc venv lên git.
UI lưu config cá nhân ngoài repo:
C:\Users\<TenUser>\AppData\Local\MangaTranslator\config.json
Trước khi push code:
git status --short
Với manga nhiều trang, nên dùng Advanced Mode để tách OCR/script và render.
Trong Web UI:
Advanced Mode (export untranslated script only).Sau khi xong, output thường có:
output/batch_output/manga_script.json
output/batch_output/manga_script_original.txt
output/batch_output/manga_script_translated.txt
Ý nghĩa:
manga_script.json: dữ liệu bubble, bbox, orientation. Không sửa nếu không biết rõ.manga_script_original.txt: script OCR gốc.manga_script_translated.txt: file bạn sửa/dịch rồi import để render.Chỉ sửa manga_script_translated.txt.
Giữ format:
=== PAGE: 03_02.png ===
1: Câu dịch tiếng Việt[direction:horizontal]
2: Câu tiếp theo[direction:horizontal]
3: [OCR FAILED]
Quy tắc:
=== PAGE: file ===.1:, 2:, 3:.[Bubble], [OSB] nếu có.[direction:horizontal] để tránh chữ bị xếp dọc.Trong Web UI:
Advanced Mode (import translated script and render).manga_script_translated.txt.manga_script.json.Có thể thêm tag ở cuối dòng:
[font:TenFont,size:80,direction:horizontal]
Ví dụ:
=== PAGE: 40_038.jpg ===
1: Rầm![font:Arial,size:100,direction:horizontal]
2: A...[size:60,direction:horizontal]
3: Đợi đã[direction:horizontal]
Thuộc tính:
font: tên thư mục font trong fonts/.size: cỡ chữ mong muốn.direction: horizontal hoặc vertical.Với tiếng Việt, gần như luôn dùng:
direction:horizontal
Tab Decensor dùng để detect vùng censor, sửa mask, rồi restore/inpaint.
Luồng khuyến nghị:
auto hoặc hybrid.Detect Mask Preview.Detect Mask Preview lại để kiểm tra mask sau khi sửa.Gợi ý mask:
Flux gợi ý:
Flux Klein 4B, bật Low VRAM/CPU Offload, steps 6-8.Flux Klein 9B nặng hơn, chỉ nên thử với mask nhỏ.Flux Kontext nên ưu tiên backend SDNQ nếu máy ít VRAM.Web UI là cách dễ dùng nhất. CLI phù hợp khi cần script hóa.
Dịch một ảnh:
python main.py --input "input\page.png" --output "output\page.png" --provider Google --google-api-key "AIzaSy..." --model-name "gemini-2.5-flash" --output-language Vietnamese --font-dir ".\fonts"
Dùng Google-compatible proxy:
python main.py --input "input\page.png" --output "output\page.png" --provider Google --google-proxy-api-key "<proxy-api-key>" --google-proxy-base-url "<proxy-base-url>" --model-name "gemini-2.5-flash" --output-language Vietnamese --font-dir ".\fonts"
Batch thư mục:
python main.py --input "input\chapter" --output "output\chapter" --batch --provider Google --google-api-key "AIzaSy..." --model-name "gemini-2.5-flash" --output-language Vietnamese --font-dir ".\fonts"
Khuyến nghị dùng biến môi trường thay vì ghi API key trực tiếp trong terminal nếu bạn quay màn hình hoặc chia sẻ log.
Nếu log có dạng:
OpenAI-Compatible API request to http://...
và bạn đang muốn dùng Google, vào UI chọn lại:
Provider = Google
Model = gemini-2.5-flash
Sau đó lưu config.
File TXT chỉ sinh ra khi dùng Advanced Mode export script. Kiểm tra:
output/batch_output/manga_script_original.txt
output/batch_output/manga_script_translated.txt
output/batch_output/manga_script.json
Kiểm tra:
=== PAGE: ... ===.manga_script.json nếu chỉ muốn dịch text.Thử:
Nếu console báo:
WebGL: CONTEXT_LOST_WEBGL
thường do canvas ImageEditor quá nặng khi ảnh lớn và dùng eraser lâu. Có thể:
MangaTranslator/
app.py
main.py
requirements.txt
README.md
fonts/
models/
output/
ui/
core/
utils/
Không push:
.venv/.Nên kiểm tra trước khi commit:
git status --short
git diff --check
4 commits
Python
99.6%
0
stars
4
commits
Python
primary language
Jun 10, 2026
updated
MangaTranslator là công cụ dịch và render chữ cho manga/comic. Ứng dụng hỗ trợ xử lý từng ảnh, batch nhiều ảnh, xuất script để dịch thủ công bằng LLM, import lại script đã dịch để render, xử lý chữ ngoài bubble, upscale và decensor/inpaint.
Khuyến nghị Python 3.10, 3.11 hoặc 3.12. Trên Windows nên tạo virtual environment riêng.
cd F:\tool\MangaTranslator
py -3.12 -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
pip install -r requirements.txt
Nếu dùng GPU NVIDIA, cài PyTorch CUDA phù hợp với máy. Ví dụ CUDA 12.1:
pip install --index-url https://download.pytorch.org/whl/cu121 torch torchvision
Kiểm tra GPU:
nvidia-smi
python -c "import torch; print(torch.cuda.is_available()); print(torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'CPU')"
cd F:\tool\MangaTranslator
.\.venv\Scripts\Activate.ps1
python app.py --open-browser
Mặc định UI chạy tại:
http://127.0.0.1:7676
Đổi port:
python app.py --port 7860 --open-browser
Chạy CPU:
python app.py --cpu --open-browser
Nếu gặp lỗi thiếu font pack, tạo thư mục font theo cấu trúc:
fonts/
Arial/
arial.ttf
arialbd.ttf
ariali.ttf
arialbi.ttf
Trong UI, chọn font pack trong phần font/rendering. Nếu dịch tiếng Việt, nên dùng font hỗ trợ dấu tiếng Việt như Arial, Noto Sans, Roboto, Inter hoặc font Việt hóa bạn tự thêm.
Trong UI, vào phần provider/API:
Google, OpenAI, Anthropic, OpenRouter, hoặc provider bạn dùng.gemini-2.5-flash nếu dùng Google.Nếu dùng Google-compatible proxy, nhập đủ 2 field:
Google Proxy API Key = <proxy-api-key>
Google Proxy Base URL = <proxy-base-url>
Khi có đủ proxy key và proxy base URL, project sẽ gọi Gemini qua proxy thay vì gọi trực tiếp Google.
Có thể dùng biến môi trường:
$env:GOOGLE_API_KEY="AIzaSy..."
$env:GOOGLE_PROXY_API_KEY="<proxy-api-key>"
$env:GOOGLE_PROXY_BASE_URL="<proxy-base-url>"
Các biến môi trường khác:
OPENAI_API_KEY
ANTHROPIC_API_KEY
XAI_API_KEY
DEEPSEEK_API_KEY
ZAI_API_KEY
MOONSHOT_API_KEY
OPENROUTER_API_KEY
OPENAI_COMPATIBLE_API_KEY
Không commit API key, token, config cá nhân, output ảnh, model cache hoặc venv lên git.
UI lưu config cá nhân ngoài repo:
C:\Users\<TenUser>\AppData\Local\MangaTranslator\config.json
Trước khi push code:
git status --short
Với manga nhiều trang, nên dùng Advanced Mode để tách OCR/script và render.
Trong Web UI:
Advanced Mode (export untranslated script only).Sau khi xong, output thường có:
output/batch_output/manga_script.json
output/batch_output/manga_script_original.txt
output/batch_output/manga_script_translated.txt
Ý nghĩa:
manga_script.json: dữ liệu bubble, bbox, orientation. Không sửa nếu không biết rõ.manga_script_original.txt: script OCR gốc.manga_script_translated.txt: file bạn sửa/dịch rồi import để render.Chỉ sửa manga_script_translated.txt.
Giữ format:
=== PAGE: 03_02.png ===
1: Câu dịch tiếng Việt[direction:horizontal]
2: Câu tiếp theo[direction:horizontal]
3: [OCR FAILED]
Quy tắc:
=== PAGE: file ===.1:, 2:, 3:.[Bubble], [OSB] nếu có.[direction:horizontal] để tránh chữ bị xếp dọc.Trong Web UI:
Advanced Mode (import translated script and render).manga_script_translated.txt.manga_script.json.Có thể thêm tag ở cuối dòng:
[font:TenFont,size:80,direction:horizontal]
Ví dụ:
=== PAGE: 40_038.jpg ===
1: Rầm![font:Arial,size:100,direction:horizontal]
2: A...[size:60,direction:horizontal]
3: Đợi đã[direction:horizontal]
Thuộc tính:
font: tên thư mục font trong fonts/.size: cỡ chữ mong muốn.direction: horizontal hoặc vertical.Với tiếng Việt, gần như luôn dùng:
direction:horizontal
Tab Decensor dùng để detect vùng censor, sửa mask, rồi restore/inpaint.
Luồng khuyến nghị:
auto hoặc hybrid.Detect Mask Preview.Detect Mask Preview lại để kiểm tra mask sau khi sửa.Gợi ý mask:
Flux gợi ý:
Flux Klein 4B, bật Low VRAM/CPU Offload, steps 6-8.Flux Klein 9B nặng hơn, chỉ nên thử với mask nhỏ.Flux Kontext nên ưu tiên backend SDNQ nếu máy ít VRAM.Web UI là cách dễ dùng nhất. CLI phù hợp khi cần script hóa.
Dịch một ảnh:
python main.py --input "input\page.png" --output "output\page.png" --provider Google --google-api-key "AIzaSy..." --model-name "gemini-2.5-flash" --output-language Vietnamese --font-dir ".\fonts"
Dùng Google-compatible proxy:
python main.py --input "input\page.png" --output "output\page.png" --provider Google --google-proxy-api-key "<proxy-api-key>" --google-proxy-base-url "<proxy-base-url>" --model-name "gemini-2.5-flash" --output-language Vietnamese --font-dir ".\fonts"
Batch thư mục:
python main.py --input "input\chapter" --output "output\chapter" --batch --provider Google --google-api-key "AIzaSy..." --model-name "gemini-2.5-flash" --output-language Vietnamese --font-dir ".\fonts"
Khuyến nghị dùng biến môi trường thay vì ghi API key trực tiếp trong terminal nếu bạn quay màn hình hoặc chia sẻ log.
Nếu log có dạng:
OpenAI-Compatible API request to http://...
và bạn đang muốn dùng Google, vào UI chọn lại:
Provider = Google
Model = gemini-2.5-flash
Sau đó lưu config.
File TXT chỉ sinh ra khi dùng Advanced Mode export script. Kiểm tra:
output/batch_output/manga_script_original.txt
output/batch_output/manga_script_translated.txt
output/batch_output/manga_script.json
Kiểm tra:
=== PAGE: ... ===.manga_script.json nếu chỉ muốn dịch text.Thử:
Nếu console báo:
WebGL: CONTEXT_LOST_WEBGL
thường do canvas ImageEditor quá nặng khi ảnh lớn và dùng eraser lâu. Có thể:
MangaTranslator/
app.py
main.py
requirements.txt
README.md
fonts/
models/
output/
ui/
core/
utils/
Không push:
.venv/.Nên kiểm tra trước khi commit:
git status --short
git diff --check
4 commits
Python
99.6%