zyddnys / manga-image-translator

Translate manga/image 一键翻译各类图片内文字 https://cotrans.touhou.ai/
https://cotrans.touhou.ai/
GNU General Public License v3.0
5.18k stars 534 forks source link

[Bug]: ERROR: [batch] IndexError: string index out of range #513

Open My12123 opened 11 months ago

My12123 commented 11 months ago

Issue

ERROR: [batch] IndexError: string index out of range

Command Line Arguments

python -m manga_translator -v --mode batch --use-cuda --translator=m2m100_big -l RUS --font-path=fonts/anime_ace.ttf -i

Console logs

ERROR: [batch] IndexError: string index out of range
Traceback (most recent call last):
  File "F:\manga-image-translator\manga_translator\__main__.py", line 73, in <module>
    loop.run_until_complete(dispatch(args))
  File "F:\1\envs\manga-image-translator\lib\asyncio\base_events.py", line 649, in run_until_complete
    return future.result()
  File "F:\manga-image-translator\manga_translator\__main__.py", line 42, in dispatch
    await translator.translate_path(path, dest, args_dict)
  File "F:\manga-image-translator\manga_translator\manga_translator.py", line 175, in translate_path
    if await self.translate_file(file_path, output_dest, params):
  File "F:\manga-image-translator\manga_translator\manga_translator.py", line 202, in translate_file
    return await self._translate_file(path, dest, ctx)
  File "F:\manga-image-translator\manga_translator\manga_translator.py", line 245, in _translate_file
    ctx = await self.translate(img, ctx)
  File "F:\manga-image-translator\manga_translator\manga_translator.py", line 303, in translate
    return await self._translate(ctx)
  File "F:\manga-image-translator\manga_translator\manga_translator.py", line 445, in _translate
    ctx.img_rendered = await self._run_text_rendering(ctx)
  File "F:\manga-image-translator\manga_translator\manga_translator.py", line 548, in _run_text_rendering
    output = await dispatch_rendering(ctx.img_inpainted, ctx.text_regions, ctx.font_path, ctx.font_size,
  File "F:\manga-image-translator\manga_translator\rendering\__init__.py", line 117, in dispatch
    img = render(img, region, dst_points, hyphenate, line_spacing)
  File "F:\manga-image-translator\manga_translator\rendering\__init__.py", line 136, in render
    temp_box = text_render.put_text_horizontal(
  File "F:\manga-image-translator\manga_translator\rendering\text_render.py", line 681, in put_text_horizontal
    line_text_list, line_width_list = calc_horizontal(font_size, text, width, height, lang, hyphenate)
  File "F:\manga-image-translator\manga_translator\rendering\text_render.py", line 622, in calc_horizontal
    if j == 0 and i > 0 and line_text_list[-1][-1] == '-' and line_text[0] == '-':
IndexError: string index out of range
thatDudo commented 11 months ago

Not sure if this has helped. Maybe you can try again or send the image or text used.

My12123 commented 11 months ago

I can't check it now because I solved it by changing the OCR to the old one and everything worked correctly, but with the new one there is such a problem --ocr 48px_ctc