zyddnys / manga-image-translator

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

[Bug]: ERROR: [web_client] ChunkedEncodingError 在添加--ocr mocr无法获取到manga-orc #658

Closed Ctory-Nily closed 2 months ago

Ctory-Nily commented 3 months ago

Issue

无论是挂全局代理还是裸连都连接失败 2024-06-23 19:55:14 manga_image_translator_cpu | 2024-06-23 11:55:14.913 | INFO | manga_ocr.ocr:init:13 - Loading OCR model from kha-white/manga-ocr-base

同样在我使用m2m100翻译模型的时候也会发生超时的问题,挂梯子直接下载会直接失败,不挂梯子能下但是很慢,下载一段时间后就会显示超时,我尝试过将文件下载到本地后上传到国内的下载网站上,然后再替换链接,可还是会报错。

我不知道改怎么修改代码来让容器直接使用我下载好的模型。甚至我连 在选择 m2m100翻译 后开始翻译并获取到下载链接开始下载的那个启动下载的文件都不知道在哪(我知道他不是manga_translator/translators/m2m100.py)

Command Line Arguments

version: "3.8"
name: manga_image_translator
services:
  manga_image_translator:
    image: zyddnys/manga-image-translator:main
    container_name: manga_image_translator_cpu
    command: --manga2eng -v --mode web --ocr mocr --host=0.0.0.0 --port=5003 --translator=papago --inpainting-precision bf16 --inpainting-size 1024
    volumes:
      - ./result:/app/result
      - ./web_main.py:/app/manga_translator/server/web_main.py
    ports:
      - 5003:5003
    ipc: host

Console logs

Translating: "/app/result/b8f31a7834d2ce3c6ce14cef370c3196323c39e37a70c4ccc3e7874e37063316-1536-papago-CHS-default-auto/input.jpg"
Loading models
ChunkedEncodingError: ('Connection broken: IncompleteRead(7171938 bytes read, 436963537 more expected)', IncompleteRead(7171938 bytes read, 436963537 more expected))
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/urllib3/response.py", line 712, in _error_catcher
    yield
  File "/opt/conda/lib/python3.10/site-packages/urllib3/response.py", line 833, in _raw_read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
urllib3.exceptions.IncompleteRead: IncompleteRead(7171938 bytes read, 436963537 more expected)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/requests/models.py", line 816, in generate
    yield from self.raw.stream(chunk_size, decode_content=True)
  File "/opt/conda/lib/python3.10/site-packages/urllib3/response.py", line 934, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/opt/conda/lib/python3.10/site-packages/urllib3/response.py", line 905, in read
    data = self._raw_read(amt)
  File "/opt/conda/lib/python3.10/site-packages/urllib3/response.py", line 811, in _raw_read
    with self._error_catcher():
  File "/opt/conda/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/opt/conda/lib/python3.10/site-packages/urllib3/response.py", line 729, in _error_catcher
    raise ProtocolError(f"Connection broken: {e!r}", e) from e
urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(7171938 bytes read, 436963537 more expected)', IncompleteRead(7171938 bytes read, 436963537 more expected))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/manga_translator/__main__.py", line 73, in <module>
    loop.run_until_complete(dispatch(args))
  File "/opt/conda/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/app/manga_translator/__main__.py", line 50, in dispatch
    await translator.listen(args_dict)
  File "/app/manga_translator/manga_translator.py", line 750, in listen
    await self.translate_path(self._result_path('input.jpg'), self._result_path('final.jpg'),
  File "/app/manga_translator/manga_translator.py", line 154, in translate_path
    await self.translate_file(path, _dest, params)
  File "/app/manga_translator/manga_translator.py", line 205, in translate_file
    return await self._translate_file(path, dest, ctx)
  File "/app/manga_translator/manga_translator.py", line 248, in _translate_file
    ctx = await self.translate(img, ctx)
  File "/app/manga_translator/manga_translator.py", line 299, in translate
    await prepare_ocr(ctx.ocr, self.device)
  File "/app/manga_translator/ocr/__init__.py", line 31, in prepare
    await ocr.load(device)
  File "/app/manga_translator/utils/inference.py", line 327, in load
    await self._load(*args, **kwargs, device=device)
  File "/app/manga_translator/ocr/model_manga_ocr.py", line 119, in _load
    self.mocr = MangaOcr()
  File "/opt/conda/lib/python3.10/site-packages/manga_ocr/ocr.py", line 16, in __init__
    self.model = VisionEncoderDecoderModel.from_pretrained(pretrained_model_name_or_path)
  File "/opt/conda/lib/python3.10/site-packages/transformers/models/vision_encoder_decoder/modeling_vision_encoder_decoder.py", line 371, in from_pretrained
    return super().from_pretrained(pretrained_model_name_or_path, *model_args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/transformers/modeling_utils.py", line 3380, in from_pretrained
    resolved_archive_file = cached_file(
  File "/opt/conda/lib/python3.10/site-packages/transformers/utils/hub.py", line 399, in cached_file
    resolved_file = hf_hub_download(
  File "/opt/conda/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1221, in hf_hub_download
    return _hf_hub_download_to_cache_dir(
  File "/opt/conda/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1367, in _hf_hub_download_to_cache_dir
    _download_to_tmp_and_move(
  File "/opt/conda/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1884, in _download_to_tmp_and_move
    http_get(
  File "/opt/conda/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 539, in http_get
    for chunk in r.iter_content(chunk_size=DOWNLOAD_CHUNK_SIZE):
  File "/opt/conda/lib/python3.10/site-packages/requests/models.py", line 818, in generate
    raise ChunkedEncodingError(e)
requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(7171938 bytes read, 436963537 more expected)', IncompleteRead(7171938 bytes read, 436963537 more expected))
Ctory-Nily commented 3 months ago

2024-06-23 20:28:10 manga_image_translator_cpu | ERROR: [web_client] OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like kha-white/manga-ocr-base is not the path to a directory containing a file named preprocessor_config.json. 2024-06-23 20:28:10 manga_image_translator_cpu | Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.

Ctory-Nily commented 2 months ago

新版本已解决