Skip to content

Commit 32ce2bc

Browse files
committed
feat: Update config example, add v1.7.5 changelog, and apply various fixes/improvements
1 parent 02d9a1d commit 32ce2bc

12 files changed

Lines changed: 256 additions & 44 deletions

File tree

desktop_qt_ui/app_logic.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,14 @@ def get_display_mapping(self, key: str) -> Optional[Dict[str, str]]:
361361
"merge_gamma": "合并-距离容忍度", "merge_sigma": "合并-离群容忍度", "merge_edge_ratio_threshold": "合并-边缘距离比例阈值", "detector": "文本检测器",
362362
"detection_size": "检测大小", "text_threshold": "文本阈值", "det_rotate": "旋转图像进行检测",
363363
"det_auto_rotate": "旋转图像以优先检测垂直文本行", "det_invert": "反转图像颜色进行检测",
364-
"det_gamma_correct": "应用伽马校正进行检测", "use_yolo_obb": "启用YOLO辅助检测", "yolo_obb_conf": "YOLO置信度阈值", "yolo_obb_iou": "YOLO交叉比(IoU)", "box_threshold": "边界框生成阈值", "unclip_ratio": "Unclip比例",
364+
"det_gamma_correct": "应用伽马校正进行检测", "use_yolo_obb": "启用YOLO辅助检测", "yolo_obb_conf": "YOLO置信度阈值", "yolo_obb_iou": "YOLO交叉比(IoU)", "yolo_obb_overlap_threshold": "YOLO辅助检测重叠率删除阈值", "box_threshold": "边界框生成阈值", "unclip_ratio": "Unclip比例",
365365
"inpainter": "修复模型", "inpainting_size": "修复大小", "inpainting_precision": "修复精度",
366366
"renderer": "渲染器", "alignment": "对齐方式", "disable_font_border": "禁用字体边框",
367367
"disable_auto_wrap": "AI断句", "font_size_offset": "字体大小偏移量", "font_size_minimum": "最小字体大小",
368368
"max_font_size": "最大字体大小", "font_scale_ratio": "字体缩放比例",
369369
"center_text_in_bubble": "AI断句时文本居中",
370370
"optimize_line_breaks": "AI断句自动扩大文字",
371+
"strict_smart_scaling": "AI断句自动扩大文字下不扩大文本框",
371372
"direction": "文本方向", "uppercase": "大写", "lowercase": "小写", "gimp_font": "GIMP字体",
372373
"font_path": "字体路径", "no_hyphenation": "禁用连字符", "font_color": "字体颜色",
373374
"auto_rotate_symbols": "竖排内横排", "rtl": "从右到左", "layout_mode": "排版模式",

desktop_qt_ui/core/config_models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class DetectorSettings(BaseModel):
5555
use_yolo_obb: bool = False
5656
yolo_obb_conf: float = 0.4
5757
yolo_obb_iou: float = 0.6
58+
yolo_obb_overlap_threshold: float = 0.1
5859

5960
class InpainterSettings(BaseModel):
6061
inpainter: str = "lama_mpe"
@@ -84,6 +85,7 @@ class RenderSettings(BaseModel):
8485
font_scale_ratio: float = 1.0
8586
center_text_in_bubble: bool = False
8687
optimize_line_breaks: bool = False
88+
strict_smart_scaling: bool = False
8789

8890
class UpscaleSettings(BaseModel):
8991
upscaler: str = "esrgan"

desktop_qt_ui/services/render_parameter_service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class RenderParameters:
5353
font_scale_ratio: float = 1.0 # 字体缩放比例
5454
center_text_in_bubble: bool = False # AI断句时文本居中
5555
optimize_line_breaks: bool = False # 自动优化断句
56+
strict_smart_scaling: bool = False # AI断句自动扩大文字下不扩大文本框
5657

5758
# 效果参数
5859
stroke_width: float = 0.2 # 描边宽度

dict/system_prompt_line_break.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"line_break_prompt": "As a professional manga translator, you also need to handle line breaks intelligently. Your task is to insert `[BR]` markers into the translated text for optimal layout and readability. For each text, you will receive a hint: `[Original regions: X]`, which tells you how many regions the original text had. Use this number and your visual understanding of the image to make the best decision.\n\n**RULES:**\n\n1. **For single-region text (`[Original regions: 1]`):** DO NOT insert any `[BR]` markers. Keep the translation as a single line without any line breaks.\n\n2. **For two-region text (`[Original regions: 2]`):** You **must** insert exactly one `[BR]` marker to split the translation into two lines. This rule is strict.\n\n3. **For text with three or more regions (`[Original regions: X]` where X is 3 or more):** You may insert between `X-2` and `X` markers, **prioritizing readability and natural flow**. Use your judgment based on the actual length and structure of your translation, but you must NOT use more than `X` markers.\n\n**EXAMPLES:**\n\n**Example 1 - Four Regions:**\nOriginal: `[Original regions: 4]` \"まずは / のトイレを / 済ませるぞ!! / 走れるかイ!\"\n✅ CORRECT (3 BR markers): \"首先 [BR] 解决上厕所 [BR] 的问题!! [BR] 跑得动吗!\"\n❌ WRONG (1 BR marker): \"首先解决上厕所的问题!! [BR] 跑得动吗!\"\n\n**Example 2 - Two Regions:**\nOriginal: `[Original regions: 2]` \"こんにちは / 元気?\"\n✅ CORRECT (1 BR marker): \"你好 [BR] 还好吗?\"\n❌ WRONG (0 BR markers): \"你好 还好吗?\"\n\n**Example 3 - Five Regions:**\nOriginal: `[Original regions: 5]` \"私は / 学校に / 行く / ことが / 好きです\"\n✅ CORRECT (4 BR markers): \"I [BR] really like [BR] going [BR] to [BR] school\"\n❌ WRONG (2 BR markers): \"I really like [BR] going [BR] to school\"\n\n**LINE BREAK QUALITY RULES:**\n\n1. **CONTEXT-BASED DECISIONS**: Use the visual image context to make smart breaking decisions. Some words CAN stand alone when it makes visual and emotional sense:\n - **ALLOWED ALONE**: Strong emotional expressions (\"Ah!\" \"Yes!\" \"Well...\"), emphatic responses, dramatic exclamations that need visual impact\n - **AVOID ALONE**: Weak particles (like prepositions \"of\", \"to\"), ordinary pronouns (\"I\", \"you\"), casual connectors (\"and\", \"so\") unless they serve special dramatic purpose\n - **AVOID SINGLE-CHARACTER FINAL SEGMENTS**: Do not let the last line break result in a single character standing alone\n\n2. **BREAK AT NATURAL POINTS**: Insert `[BR]` at grammatically natural positions:\n - After complete phrases or clauses\n - Before conjunctions like \"but,\" \"and,\" or \"so\"\n - At punctuation marks when appropriate\n - Between semantically complete units\n\n**CRITICAL:** \n- Only use the `[BR]` symbol for line breaks. Do not use `\\n` or actual newlines in your output.\n- DO NOT include the `[Original regions: X]` marker in your translation output. This is only a hint for you to understand the structure; it should NOT appear in the final translation."
2+
"line_break_prompt": "As a professional manga translator, you also need to handle line breaks intelligently. Your task is to insert `[BR]` markers into the translated text for optimal layout and readability. For each text, you will receive a hint: `[Original regions: X]`, which tells you how many regions the original text had. Use this number and your visual understanding of the image to make the best decision.\n\n**🚨 CRITICAL - OUTPUT MUST BE REAL TRANSLATION 🚨**\n\n**STRICTLY FORBIDDEN:**\n- ❌ DO NOT output placeholder text like \"【占位符文本】\", \"placeholder text\", \"[translation here]\", or any template text\n- ❌ DO NOT output example text, dummy text, or generic descriptions\n- ❌ DO NOT output meta-text explaining what you're doing\n- ❌ DO NOT skip translation - you MUST translate the actual source text\n- ✅ YOU MUST output the REAL, COMPLETE translation of the original Japanese/source text\n- ✅ Line breaks (`[BR]`) should be inserted WITHIN your actual translation, not as placeholders\n\n**EXAMPLE OF FORBIDDEN OUTPUT:**\n❌ WRONG: \"【占位符文本】[BR]【占位符文本】\" (This is placeholder text, NOT a real translation!)\n❌ WRONG: \"[translation] [BR] [translation]\" (This is a template, NOT a real translation!)\n✅ CORRECT: \"今天是星期日。[BR]是这样吗?那也不错。\" (This is an actual translation with line breaks)\n\n---\n\n**RULES:**\n\n1. **For single-region text (`[Original regions: 1]`):** DO NOT insert any `[BR]` markers. Keep the translation as a single line without any line breaks.\n\n2. **For two-region text (`[Original regions: 2]`):** You **must** insert exactly one `[BR]` marker to split the translation into two lines. This rule is strict.\n\n3. **For text with three or more regions (`[Original regions: X]` where X is 3 or more):** You may insert between `X-2` and `X` markers, **prioritizing readability and natural flow**. Use your judgment based on the actual length and structure of your translation, but you must NOT use more than `X` markers.\n\n**EXAMPLES:**\n\n**Example 1 - Four Regions:**\nOriginal: `[Original regions: 4]` \"まずは / のトイレを / 済ませるぞ!! / 走れるかイ!\"\n✅ CORRECT (3 BR markers): \"首先 [BR] 解决上厕所 [BR] 的问题!! [BR] 跑得动吗!\"\n❌ WRONG (1 BR marker): \"首先解决上厕所的问题!! [BR] 跑得动吗!\"\n\n**Example 2 - Two Regions:**\nOriginal: `[Original regions: 2]` \"こんにちは / 元気?\"\n✅ CORRECT (1 BR marker): \"你好 [BR] 还好吗?\"\n❌ WRONG (0 BR markers): \"你好 还好吗?\"\n\n**Example 3 - Five Regions:**\nOriginal: `[Original regions: 5]` \"私は / 学校に / 行く / ことが / 好きです\"\n✅ CORRECT (4 BR markers): \"I [BR] really like [BR] going [BR] to [BR] school\"\n❌ WRONG (2 BR markers): \"I really like [BR] going [BR] to school\"\n\n**LINE BREAK QUALITY RULES:**\n\n1. **CONTEXT-BASED DECISIONS**: Use the visual image context to make smart breaking decisions. Some words CAN stand alone when it makes visual and emotional sense:\n - **ALLOWED ALONE**: Strong emotional expressions (\"Ah!\" \"Yes!\" \"Well...\"), emphatic responses, dramatic exclamations that need visual impact\n - **AVOID ALONE**: Weak particles (like prepositions \"of\", \"to\"), ordinary pronouns (\"I\", \"you\"), casual connectors (\"and\", \"so\") unless they serve special dramatic purpose\n - **AVOID SINGLE-CHARACTER FINAL SEGMENTS**: Do not let the last line break result in a single character standing alone\n\n2. **BREAK AT NATURAL POINTS**: Insert `[BR]` at grammatically natural positions:\n - After complete phrases or clauses\n - Before conjunctions like \"but,\" \"and,\" or \"so\"\n - At punctuation marks when appropriate\n - Between semantically complete units\n\n3. **BALANCED LINE LENGTHS (Recommended)**: While not mandatory, it's generally better to maintain relatively similar lengths across lines:\n - Try to avoid creating one very long line and several very short lines\n - Consider distributing text more evenly when possible\n - Exception: Emotional expressions, emphasis, or dramatic effect may intentionally use shorter lines\n - This is a soft guideline—readability and natural flow take priority\n\n**CRITICAL:** \n- Only use the `[BR]` symbol for line breaks. Do not use `\\n` or actual newlines in your output.\n- DO NOT include the `[Original regions: X]` marker in your translation output. This is only a hint for you to understand the structure; it should NOT appear in the final translation."
33
}

doc/CHANGELOG_v1.7.5.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Changelog v1.7.5
2+
3+
## 修复与改进
4+
5+
- **YOLO OBB 检测**:
6+
- 修复了 `letterbox` 尺寸计算错误 (640x639 → 640x640),提升了模型处理图像的准确性。
7+
- 增加了图像格式检查,确保输入图像为灰度、RGB或RGBA格式。
8+
- 添加了详细的调试日志,方便问题排查。
9+
- 新增 `yolo_obb_overlap_threshold` 配置项,允许用户自定义重叠框的删除阈值。
10+
11+
- **混合检测调试**:
12+
- 生成并保存 `hybrid_detection_boxes.png` 调试图片,通过不同颜色的框(主检测器、保留的YOLO框、删除的YOLO框)直观展示混合检测结果。
13+
14+
- **AI 断句与文本处理**:
15+
- 新增 `strict_smart_scaling` 配置,在智能缩放模式下防止文本框不必要的扩大。
16+
- 优化了竖排文本中的横排英文词组(如 "Tek Tok")处理,避免其被错误地竖排显示。
17+
- 修复了对英文词组中空格的错误处理,现在只删除标点符号后的多余空格。
18+
- 增强了断句提示词,加入了段落长度平衡的建议,以生成更自然的断句结果。

examples/config-example.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"app": {
3-
"last_open_dir": ".",
3+
"last_open_dir": "",
44
"last_output_path": ""
55
},
66
"filter_text": null,
@@ -37,10 +37,11 @@
3737
"unclip_ratio": 2.5,
3838
"use_yolo_obb": true,
3939
"yolo_obb_conf": 0.4,
40-
"yolo_obb_iou": 0.6
40+
"yolo_obb_iou": 0.6,
41+
"yolo_obb_overlap_threshold": 0.1
4142
},
4243
"inpainter": {
43-
"inpainter": "lama_large",
44+
"inpainter": "lama_mpe",
4445
"inpainting_size": 2048,
4546
"inpainting_precision": "bf16"
4647
},
@@ -66,7 +67,8 @@
6667
"max_font_size": 0,
6768
"font_scale_ratio": 1.0,
6869
"center_text_in_bubble": false,
69-
"optimize_line_breaks": true
70+
"optimize_line_breaks": true,
71+
"strict_smart_scaling": true
7072
},
7173
"upscale": {
7274
"upscaler": "waifu2x",
@@ -78,7 +80,7 @@
7880
"colorizer": "none"
7981
},
8082
"cli": {
81-
"verbose": false,
83+
"verbose": true,
8284
"attempts": 2,
8385
"ignore_errors": false,
8486
"use_gpu": true,

manga_translator/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ class RenderConfig(BaseModel):
174174
"""Center the entire text block in the bubble when AI line breaking is enabled"""
175175
optimize_line_breaks: bool = False
176176
"""Automatically optimize line breaks by testing all combinations to find the best font size"""
177+
strict_smart_scaling: bool = False
178+
"""In smart_scaling mode, prevent text box expansion by skipping combinations without line breaks"""
177179
direction: Direction = Direction.auto
178180
"""Force text to be rendered horizontally/vertically/none"""
179181
uppercase: bool = False
@@ -320,6 +322,8 @@ class DetectorConfig(BaseModel):
320322
"""Confidence threshold for YOLO OBB detector"""
321323
yolo_obb_iou: float = 0.6
322324
"""IoU threshold for YOLO OBB detector NMS"""
325+
yolo_obb_overlap_threshold: float = 0.1
326+
"""Overlap ratio threshold for removing YOLO boxes (0.0-1.0). YOLO boxes with overlap >= threshold will be removed if they don't meet replacement criteria. Set to 1.0 to keep all overlapping boxes."""
323327
box_threshold: float = 0.7
324328
"""Threshold for bbox generation"""
325329
unclip_ratio: float = 2.3

0 commit comments

Comments
 (0)