Loading modules/ocr/mit48px_ctc.py +4 −6 Original line number Diff line number Diff line Loading @@ -472,12 +472,10 @@ class OCR48pxCTC: if prob < 0.3 : continue textblk.text.append(''.join(cur_texts)) textblk.fg_b += int(total_fr()) textblk.fg_g += int(total_fg()) textblk.fg_r += int(total_fb()) textblk.bg_b += int(total_br()) textblk.bg_g += int(total_bg()) textblk.bg_r += int(total_bb()) textblk.update_font_colors( [int(total_fb()), int(total_fg()), int(total_fr())], [int(total_bb()), int(total_bg()), int(total_br())] ) chunck_idx += N Loading modules/ocr/model_32px.py +6 −9 Original line number Diff line number Diff line Loading @@ -611,16 +611,13 @@ class OCR32pxModel: if ch == '<SP>' : ch = ' ' seq.append(ch) txt = ''.join(seq) # textblk = textblk[indices[i]] textblk.text.append(txt) textblk.text.append(''.join(seq)) # manga-image-translator ocr extract bgr instead of rgb textblk.fg_r += fb textblk.fg_g += fg textblk.fg_b += fr textblk.bg_r += bb textblk.bg_g += bg textblk.bg_b += br textblk.update_font_colors( [fb, fg, fr], [bb, bg, br] ) chunck_idx += N @torch.no_grad() Loading tests/ui/text_rendering.py +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ if __name__ == '__main__': gen_dict = { 'current_img': None, 'pages': { "chs_horizontal.png": [{"xyxy": [254, 141, 470, 284], "lines": [[[254, 141], [470, 141], [470, 284], [254, 284]]], "language": "unknown", "vertical": False, "font_size": 90, "distance": None, "angle": 0, "vec": None, "norm": -1, "merged": False, "sort_weight": -1, "text": [""], "translation": "测试测试", "fg_r": 0, "fg_g": 0, "fg_b": 0, "bg_r": 236, "bg_g": 228, "bg_b": 255, "line_spacing": 1.2, "letter_spacing": 1.0, "font_family": "microsoft Himalaya", "bold": False, "underline": False, "italic": False, "_alignment": 0, "rich_text": "", "_bounding_rect": [303, 227, 318, 172], "accumulate_color": False, "default_stroke_width": 0, "stroke_decide_by_colordiff": True, "font_weight": 50, "opacity": 1.0, "shadow_radius": 0.0, "shadow_strength": 1.0, "shadow_color": [0, 0, 0], "shadow_offset": [0.0, 0.0], "src_is_vertical": True, "_detected_font_size": -1, "region_mask": None, "region_inpaint_dict": None}, {"xyxy": [223, 408, 439, 551], "lines": [[[254, 141], [470, 141], [470, 284], [254, 284]]], "language": "unknown", "vertical": False, "font_size": 90, "distance": None, "angle": 0, "vec": None, "norm": -1, "merged": False, "sort_weight": -1, "text": [""], "translation": "测试测试", "fg_r": 0, "fg_g": 0, "fg_b": 0, "bg_r": 236, "bg_g": 228, "bg_b": 255, "line_spacing": 1.2, "letter_spacing": 1.0, "font_family": "microsoft Himalaya", "bold": False, "underline": False, "italic": False, "_alignment": 1, "rich_text": "", "_bounding_rect": [272, 494, 318, 172], "accumulate_color": False, "default_stroke_width": 0, "stroke_decide_by_colordiff": True, "font_weight": 50, "opacity": 1.0, "shadow_radius": 0.0, "shadow_strength": 1.0, "shadow_color": [0, 0, 0], "shadow_offset": [0.0, 0.0], "src_is_vertical": True, "_detected_font_size": -1, "region_mask": None, "region_inpaint_dict": None}] "chs_horizontal.png": [{"xyxy": [254, 141, 470, 284], "lines": [[[254, 141], [470, 141], [470, 284], [254, 284]]], "language": "unknown", "vertical": False, "font_size": 90, "distance": None, "angle": 0, "vec": None, "norm": -1, "merged": False, "sort_weight": -1, "text": [""], "translation": "测试测试", "fg_r": 0, "fg_g": 0, "fg_b": 0, "bg_r": 236, "bg_g": 228, "bg_b": 255, "line_spacing": 1.2, "letter_spacing": 1.0, "font_family": "microsoft Himalaya", "bold": False, "underline": False, "italic": False, "_alignment": 0, "rich_text": "", "_bounding_rect": [303, 227, 318, 172], "default_stroke_width": 0, "stroke_decide_by_colordiff": True, "font_weight": 50, "opacity": 1.0, "shadow_radius": 0.0, "shadow_strength": 1.0, "shadow_color": [0, 0, 0], "shadow_offset": [0.0, 0.0], "src_is_vertical": True, "_detected_font_size": -1, "region_mask": None, "region_inpaint_dict": None}, {"xyxy": [223, 408, 439, 551], "lines": [[[254, 141], [470, 141], [470, 284], [254, 284]]], "language": "unknown", "vertical": False, "font_size": 90, "distance": None, "angle": 0, "vec": None, "norm": -1, "merged": False, "sort_weight": -1, "text": [""], "translation": "测试测试", "fg_r": 0, "fg_g": 0, "fg_b": 0, "bg_r": 236, "bg_g": 228, "bg_b": 255, "line_spacing": 1.2, "letter_spacing": 1.0, "font_family": "microsoft Himalaya", "bold": False, "underline": False, "italic": False, "_alignment": 1, "rich_text": "", "_bounding_rect": [272, 494, 318, 172], "default_stroke_width": 0, "stroke_decide_by_colordiff": True, "font_weight": 50, "opacity": 1.0, "shadow_radius": 0.0, "shadow_strength": 1.0, "shadow_color": [0, 0, 0], "shadow_offset": [0.0, 0.0], "src_is_vertical": True, "_detected_font_size": -1, "region_mask": None, "region_inpaint_dict": None}] } } Loading ui/mainwindow.py +3 −3 Original line number Diff line number Diff line Loading @@ -897,9 +897,9 @@ class MainWindow(FramelessWindow): blk.default_stroke_width = gf.stroke_width blk.stroke_decide_by_colordiff = False if override_fnt_color: blk.set_font_colors(frgb=gf.frgb, accumulate=False) blk.set_font_colors(fg_colors=gf.frgb) if override_fnt_scolor: blk.set_font_colors(srgb=gf.srgb, accumulate=False) blk.set_font_colors(bg_colors=gf.srgb) if override_alignment: blk._alignment = gf.alignment if override_effect: Loading Loading @@ -1005,7 +1005,7 @@ class MainWindow(FramelessWindow): textblk.stroke_decide_by_colordiff = True textblk.default_stroke_width = 0.2 textblk.text = [] textblk.set_font_colors((0, 0, 0), (0, 0, 0), True) textblk.set_font_colors((0, 0, 0), (0, 0, 0)) if pcfg.module.enable_translate or all_disabled or pcfg.module.enable_ocr: textblk.rich_text = '' # textblk.font_size = textblk.detected_font_size ??? Loading ui/textitem.py +1 −1 Original line number Diff line number Diff line Loading @@ -721,7 +721,7 @@ class TextBlkItem(QGraphicsTextItem): self.blk.shadow_offset = self.shadow_offset self.blk.opacity = self.opacity() self.blk.vertical = fmt.vertical self.blk.set_font_colors(fmt.frgb, fmt.srgb, accumulate=False) self.blk.set_font_colors(fmt.frgb, fmt.srgb) def set_cursor_cfmt(self, cursor: QTextCursor, cfmt, merge_char: bool = False): if merge_char: Loading Loading
modules/ocr/mit48px_ctc.py +4 −6 Original line number Diff line number Diff line Loading @@ -472,12 +472,10 @@ class OCR48pxCTC: if prob < 0.3 : continue textblk.text.append(''.join(cur_texts)) textblk.fg_b += int(total_fr()) textblk.fg_g += int(total_fg()) textblk.fg_r += int(total_fb()) textblk.bg_b += int(total_br()) textblk.bg_g += int(total_bg()) textblk.bg_r += int(total_bb()) textblk.update_font_colors( [int(total_fb()), int(total_fg()), int(total_fr())], [int(total_bb()), int(total_bg()), int(total_br())] ) chunck_idx += N Loading
modules/ocr/model_32px.py +6 −9 Original line number Diff line number Diff line Loading @@ -611,16 +611,13 @@ class OCR32pxModel: if ch == '<SP>' : ch = ' ' seq.append(ch) txt = ''.join(seq) # textblk = textblk[indices[i]] textblk.text.append(txt) textblk.text.append(''.join(seq)) # manga-image-translator ocr extract bgr instead of rgb textblk.fg_r += fb textblk.fg_g += fg textblk.fg_b += fr textblk.bg_r += bb textblk.bg_g += bg textblk.bg_b += br textblk.update_font_colors( [fb, fg, fr], [bb, bg, br] ) chunck_idx += N @torch.no_grad() Loading
tests/ui/text_rendering.py +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ if __name__ == '__main__': gen_dict = { 'current_img': None, 'pages': { "chs_horizontal.png": [{"xyxy": [254, 141, 470, 284], "lines": [[[254, 141], [470, 141], [470, 284], [254, 284]]], "language": "unknown", "vertical": False, "font_size": 90, "distance": None, "angle": 0, "vec": None, "norm": -1, "merged": False, "sort_weight": -1, "text": [""], "translation": "测试测试", "fg_r": 0, "fg_g": 0, "fg_b": 0, "bg_r": 236, "bg_g": 228, "bg_b": 255, "line_spacing": 1.2, "letter_spacing": 1.0, "font_family": "microsoft Himalaya", "bold": False, "underline": False, "italic": False, "_alignment": 0, "rich_text": "", "_bounding_rect": [303, 227, 318, 172], "accumulate_color": False, "default_stroke_width": 0, "stroke_decide_by_colordiff": True, "font_weight": 50, "opacity": 1.0, "shadow_radius": 0.0, "shadow_strength": 1.0, "shadow_color": [0, 0, 0], "shadow_offset": [0.0, 0.0], "src_is_vertical": True, "_detected_font_size": -1, "region_mask": None, "region_inpaint_dict": None}, {"xyxy": [223, 408, 439, 551], "lines": [[[254, 141], [470, 141], [470, 284], [254, 284]]], "language": "unknown", "vertical": False, "font_size": 90, "distance": None, "angle": 0, "vec": None, "norm": -1, "merged": False, "sort_weight": -1, "text": [""], "translation": "测试测试", "fg_r": 0, "fg_g": 0, "fg_b": 0, "bg_r": 236, "bg_g": 228, "bg_b": 255, "line_spacing": 1.2, "letter_spacing": 1.0, "font_family": "microsoft Himalaya", "bold": False, "underline": False, "italic": False, "_alignment": 1, "rich_text": "", "_bounding_rect": [272, 494, 318, 172], "accumulate_color": False, "default_stroke_width": 0, "stroke_decide_by_colordiff": True, "font_weight": 50, "opacity": 1.0, "shadow_radius": 0.0, "shadow_strength": 1.0, "shadow_color": [0, 0, 0], "shadow_offset": [0.0, 0.0], "src_is_vertical": True, "_detected_font_size": -1, "region_mask": None, "region_inpaint_dict": None}] "chs_horizontal.png": [{"xyxy": [254, 141, 470, 284], "lines": [[[254, 141], [470, 141], [470, 284], [254, 284]]], "language": "unknown", "vertical": False, "font_size": 90, "distance": None, "angle": 0, "vec": None, "norm": -1, "merged": False, "sort_weight": -1, "text": [""], "translation": "测试测试", "fg_r": 0, "fg_g": 0, "fg_b": 0, "bg_r": 236, "bg_g": 228, "bg_b": 255, "line_spacing": 1.2, "letter_spacing": 1.0, "font_family": "microsoft Himalaya", "bold": False, "underline": False, "italic": False, "_alignment": 0, "rich_text": "", "_bounding_rect": [303, 227, 318, 172], "default_stroke_width": 0, "stroke_decide_by_colordiff": True, "font_weight": 50, "opacity": 1.0, "shadow_radius": 0.0, "shadow_strength": 1.0, "shadow_color": [0, 0, 0], "shadow_offset": [0.0, 0.0], "src_is_vertical": True, "_detected_font_size": -1, "region_mask": None, "region_inpaint_dict": None}, {"xyxy": [223, 408, 439, 551], "lines": [[[254, 141], [470, 141], [470, 284], [254, 284]]], "language": "unknown", "vertical": False, "font_size": 90, "distance": None, "angle": 0, "vec": None, "norm": -1, "merged": False, "sort_weight": -1, "text": [""], "translation": "测试测试", "fg_r": 0, "fg_g": 0, "fg_b": 0, "bg_r": 236, "bg_g": 228, "bg_b": 255, "line_spacing": 1.2, "letter_spacing": 1.0, "font_family": "microsoft Himalaya", "bold": False, "underline": False, "italic": False, "_alignment": 1, "rich_text": "", "_bounding_rect": [272, 494, 318, 172], "default_stroke_width": 0, "stroke_decide_by_colordiff": True, "font_weight": 50, "opacity": 1.0, "shadow_radius": 0.0, "shadow_strength": 1.0, "shadow_color": [0, 0, 0], "shadow_offset": [0.0, 0.0], "src_is_vertical": True, "_detected_font_size": -1, "region_mask": None, "region_inpaint_dict": None}] } } Loading
ui/mainwindow.py +3 −3 Original line number Diff line number Diff line Loading @@ -897,9 +897,9 @@ class MainWindow(FramelessWindow): blk.default_stroke_width = gf.stroke_width blk.stroke_decide_by_colordiff = False if override_fnt_color: blk.set_font_colors(frgb=gf.frgb, accumulate=False) blk.set_font_colors(fg_colors=gf.frgb) if override_fnt_scolor: blk.set_font_colors(srgb=gf.srgb, accumulate=False) blk.set_font_colors(bg_colors=gf.srgb) if override_alignment: blk._alignment = gf.alignment if override_effect: Loading Loading @@ -1005,7 +1005,7 @@ class MainWindow(FramelessWindow): textblk.stroke_decide_by_colordiff = True textblk.default_stroke_width = 0.2 textblk.text = [] textblk.set_font_colors((0, 0, 0), (0, 0, 0), True) textblk.set_font_colors((0, 0, 0), (0, 0, 0)) if pcfg.module.enable_translate or all_disabled or pcfg.module.enable_ocr: textblk.rich_text = '' # textblk.font_size = textblk.detected_font_size ??? Loading
ui/textitem.py +1 −1 Original line number Diff line number Diff line Loading @@ -721,7 +721,7 @@ class TextBlkItem(QGraphicsTextItem): self.blk.shadow_offset = self.shadow_offset self.blk.opacity = self.opacity() self.blk.vertical = fmt.vertical self.blk.set_font_colors(fmt.frgb, fmt.srgb, accumulate=False) self.blk.set_font_colors(fmt.frgb, fmt.srgb) def set_cursor_cfmt(self, cursor: QTextCursor, cfmt, merge_char: bool = False): if merge_char: Loading