dmMaze / BallonsTranslator

深度学习辅助漫画翻译工具, 支持一键机翻和简单的图像/文本编辑 | Yet another computer-aided comic/manga translation tool powered by deeplearning
GNU General Public License v3.0
2.49k stars 172 forks source link

[GUIDE] How to install BallonsTranslator DEV #187

Closed bropines closed 10 months ago

bropines commented 1 year ago

This guide is outdated, please read the README_EN.md and follow the installation guide there

If you came here, then you did not understand how to do it yourself. Let me help.

Two installation options. Interactive or via CMD. Shown on the example of windows 11.

[GitBash]

  1. Install GIT BASH
  2. IMPORTANT RE-OPEN CMD!! 3.1. Clone the repository

    git clone https://github.com/dmMaze/BallonsTranslator

    3.2. Go to the BT folder and change the branch to DEV

    cd BallonsTranslator
    git switch dev

To update the repository (changes):

  1. Open the console in the folder with BallonsTranslator (video example)
  2. We write
    git-pull

    video:

https://github.com/dmMaze/BallonsTranslator/assets/57861007/d6c9351b-4b00-48da-a12a-7667a1e7d16b

[Gihub Desktop]

  1. Install Gihub Desktop 4.1 Clone the repository

https://github.com/dmMaze/BallonsTranslator/assets/57861007/751ce5ef-e7f6-4c82-b62c-5a895fc37382

2.2. Click on Current Branch -> select Dev. Ready

Install models

  1. Go to This part of the instruction and download the data folder
  2. Unpack DATA folder into the BallonsTranslator folder image
  3. Run launch_win.bat
  4. If you are on Linux or MacOS, then
    python launch.py

To update the repository (changes):

  1. Open Github Desktop (video example)
  2. Click BallonsTranslator repo
  3. Click "Fetch origin" (or Upstream если будет так написано)
  4. Pull changes

Video:

https://github.com/dmMaze/BallonsTranslator/assets/57861007/5a8c47eb-78b1-4b36-90f1-a75f7f3611d4

PS. YOU MUST HAVE PYTHON 3.10.x INSTALLED (3.9 deprecated)

dmMaze commented 1 year ago

thanks, better call it DEV instead of BETA

hyrulelinks commented 1 year ago

dev是python 3.11还是3.10环境哈?

tak2hu commented 1 year ago

dev是python 3.11还是3.10环境哈?

Python 3.9 but those two also work

bropines commented 1 year ago

dev是python 3.11还是3.10环境哈?

Python 3.9 but those two also work

On the dev branch, I do not recommend using python 3.9

The switch to python 3.10 and to the dev branch was due to optimizations and easier development. Yes, and basically people are sitting at 3.10 after Stable Diffusion

hyrulelinks commented 1 year ago

@dmMaze 报告一个Apple芯片macOS运行dev分支的bug和解决方法

复现过程

pyenv install 3.11.5 # 安装Python 3.11.5
pyenv global 3.11.5 # 全局启用Python 3.11.5
git clone --branch dev https://github.com/dmMaze/BallonsTranslator.git # 克隆仓库
cd BallonsTranslator # 切到仓库
python -m venv venv3.11 # 创建Python 3.11.5虚拟环境
source venv3.11/bin/activate # 启用Python 3.11.5虚拟环境
pip install -r requirements.txt # 安装依赖
cp data BallonsTranslator/data # 将下载data文件夹复制到项目覆盖同名文件夹
python launch.py # 运行程序

报错信息

❯ python launch.py
py version:  3.11.5 (main, Aug 30 2023, 09:33:05) [Clang 14.0.3 (clang-1403.0.22.14.1)]
py executable:  /Users/hyrulelinks/Downloads/BallonsTranslator/venv3.11/bin/python
version: 1.4.0
branch: dev
Commit hash: cfde1f6834bc25339b9053cb1f5e44cfeb2ff677
[INFO   ] launch:main:136 - running on macOS, set QT_API to pyqt6
Traceback (most recent call last):
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/launch.py", line 234, in <module>
    main()
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/launch.py", line 150, in main
    from ui import config as program_config
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/ui/config.py", line 4, in <module>
    from .misc import FontFormat
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/ui/misc.py", line 10, in <module>
    from modules.textdetector.textblock import TextBlock
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/modules/__init__.py", line 3, in <module>
    from .translators import TRANSLATORS, BaseTranslator
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/modules/translators/__init__.py", line 1, in <module>
    from .base import *
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/modules/translators/base.py", line 11, in <module>
    from .hooks import chs2cht
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/modules/translators/hooks.py", line 1, in <module>
    import opencc
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/venv3.11/lib/python3.11/site-packages/opencc.py", line 24, in <module>
    libopencc = CDLL('libopencc.so.1', use_errno=True)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyrulelinks/.pyenv/versions/3.11.5/lib/python3.11/ctypes/__init__.py", line 376, in __init__
    self._handle = _dlopen(self._name, mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: dlopen(libopencc.so.1, 0x0006): tried: 'libopencc.so.1' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibopencc.so.1' (no such file), '/Users/hyrulelinks/.pyenv/versions/3.11.5/lib/libopencc.so.1' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/hyrulelinks/.pyenv/versions/3.11.5/lib/libopencc.so.1' (no such file), '/opt/homebrew/lib/libopencc.so.1' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/libopencc.so.1' (no such file), '/Users/hyrulelinks/.pyenv/versions/3.11.5/lib/libopencc.so.1' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/hyrulelinks/.pyenv/versions/3.11.5/lib/libopencc.so.1' (no such file), '/opt/homebrew/lib/libopencc.so.1' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/libopencc.so.1' (no such file), '/Users/hyrulelinks/.pyenv/versions/3.11.5/lib/libopencc.so.1' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/hyrulelinks/.pyenv/versions/3.11.5/lib/libopencc.so.1' (no such file), '/opt/homebrew/lib/libopencc.so.1' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/libopencc.so.1' (no such file), '/Users/hyrulelinks/.pyenv/versions/3.11.5/lib/libopencc.so.1' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/hyrulelinks/.pyenv/versions/3.11.5/lib/libopencc.so.1' (no such file), '/opt/homebrew/lib/libopencc.so.1' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/libopencc.so.1' (no such file), '/Users/hyrulelinks/.pyenv/versions/3.11.5/lib/libopencc.so.1' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/hyrulelinks/.pyenv/versions/3.11.5/lib/libopencc.so.1' (no such file), '/opt/homebrew/lib/libopencc.so.1' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/libopencc.so.1' (no such file), '/opt/homebrew/lib/libopencc.so.1' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/libopencc.so.1' (no such file), '/usr/lib/libopencc.so.1' (no such file, not in dyld cache), 'libopencc.so.1' (no such file), '/usr/local/lib/libopencc.so.1' (no such file), '/usr/lib/libopencc.so.1' (no such file, not in dyld cache)

报错原因

通过requirements.txt安装opencc的版本是0.2(2015年),PyPI库里opencc最新正式发行版本1.1.6(2022年),但pip install opencc==1.1.6会报错:

ERROR: Could not find a version that satisfies the requirement OpenCC==1.1.6 (from versions: 0.1, 0.2)
ERROR: No matching distribution found for OpenCC==1.1.6

这个问题似乎存在很久,至今都未解决,猜测可能与opencc版本号格式从.变成..*不连续有关。

解决方法

其他仓库有提到解决办法是先删除opencc,然后从opencc仓库用build from source方式重新安装,这个方法有一点点麻烦。 另外一个更简单的方法如下:

pip uninstall opencc
pip install opencc-python-reimplemented

运行结果

然后就可以正常运行了

❯ python launch.py
py version:  3.11.5 (main, Aug 30 2023, 09:33:05) [Clang 14.0.3 (clang-1403.0.22.14.1)]
py executable:  /Users/hyrulelinks/Downloads/BallonsTranslator/venv3.11/bin/python
version: 1.4.0
branch: dev
Commit hash: cfde1f6834bc25339b9053cb1f5e44cfeb2ff677
[INFO   ] launch:main:136 - running on macOS, set QT_API to pyqt6
[INFO   ] launch:main:185 - set display language to English
[INFO   ] module_manager:on_finish_settranslator:745 - Translator set to google
[INFO   ] module_manager:on_finish_setdetector:722 - Text detector set to ctd
[INFO   ] module_manager:on_finish_setocr:729 - OCR set to mit48px_ctc
[INFO   ] module_manager:on_finish_setinpainter:736 - Inpainter set to lama_mpe
截屏2023-09-07 13 16 12

建议

我没在Windows上尝试过运行dev分支,不确定上面的问题在Windows中是否同样存在。 建议修改requirements.txt 将opencc替换为

opencc; sys_platform == 'win32'
opencc-python-reimplemented; sys_platform == 'darwin'
hyrulelinks commented 1 year ago

@dmMaze 另外可能是兼容性或者别的什么原因,这个项目在macOS上运行,如果导入文件夹内有≥2张漫画,运行程序就会闪退,如果文件夹内只有1张漫画,则可以正常运行,但修改编辑翻译文本后,没有保存按钮,不知道怎么保存修改,退出重新打开就又恢复到编辑文本前的状态了

我的macOS是32GB内存,运行内存虽然占用16GB以上,但并未占用满,还有10GB冗余,似乎也不是爆内存闪退

dmMaze commented 1 year ago

@dmMaze 另外可能是兼容性或者别的什么原因,这个项目在macOS上运行,如果导入文件夹内有≥2张漫画,运行程序就会闪退,如果文件夹内只有1张漫画,则可以正常运行,但修改编辑翻译文本后,没有保存按钮,不知道怎么保存修改,退出重新打开就又恢复到编辑文本前的状态了

我的macOS是32GB内存,运行内存虽然占用16GB以上,但并未占用满,还有10GB冗余,似乎也不是爆内存闪退

CTRL+S就是手动保存,有没有报错信息啥的

hyrulelinks commented 1 year ago

ctrl+s按了是保存了,就是没有提示,不放心得多按几次

hyrulelinks commented 1 year ago

dev分支打包app bundle

运行源代码

# 安装Python 3.11.5
pyenv install '3.11.5'

# 全局启用Python 3.11.5
pyenv global '3.11.5'

 # 克隆仓库dev分支
git clone --branch dev https://github.com/dmMaze/BallonsTranslator.git

# 切到仓库
cd BallonsTranslator

# 创建Python 3.11.5虚拟环境
python -m venv 'venv3.11'

# 启用Python 3.11.5虚拟环境
source 'venv3.11/bin/activate'

# 安装依赖
pip install -r requirements.txt

# 将下载data文件夹复制到项目覆盖同名文件夹
cp ../data/libs ./data
cp ../data/models ./data

# 运行程序
python launch.py

Pyinstaller打包

1、编辑launch.py

# 将第209行`req_updated = False`修改成如下:
    req_updated = True

# 将第210-226行注释掉,否则打包好的app运行代码会陷入` install requirements `死循环而无法启动
    if sys.platform == 'win32':
        for req in REQ_WIN:
            try:
                pkg_resources.require(req)
            except Exception:
                run_pip(f"install {req}", req)
                req_updated = True

    torch_command = os.environ.get('TORCH_COMMAND', "pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118")
    if args.reinstall_torch or not is_installed("torch") or not is_installed("torchvision"):
        run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
        req_updated = True
    try:
        pkg_resources.require(open(args.requirements,mode='r', encoding='utf8'))
    except Exception:
        run_pip(f"install -r {args.requirements}", "requirements")
        req_updated = True

2、创建launch.spec

# 导入模块
import os
import sys
from PyInstaller.utils.hooks import collect_data_files
import subprocess

# 获取提交哈希和构造版本号
commit_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('utf-8').strip()  
version = "1.3.35.dev." + commit_hash

block_cipher = None

a = Analysis(
    ['launch.py'],
    pathex=[
        './', 
        './modules', 
        './modules/inpaint',
        './modules/ocr',
        './modules/textdetector',
        './modules/textdetector/ctd',
        './modules/textdetector/yolov5',
        './modules/translators',
        './scripts',
        './ui',
        './ui/framelesswindow',
        './ui/framelesswindow/fw_qt6',
        './ui/framelesswindow/fw_qt6/linux',
        './ui/framelesswindow/fw_qt6/mac',
        './ui/framelesswindow/fw_qt6/utils',
        './ui/framelesswindow/fw_qt6/windows',
        './ui/pagesources',
        './utils',
        ],
    binaries=[],
    datas=[
        ('config', './config'),
        ('data', './data'),
        ('icons', './icons'),
        ('translate', './translate'),
        # 必须包含modules、ui两个自制模块文件夹,否则会ModuleNotFoundError,原理暂时不明
        ('modules', './modules'),
        ('ui', './ui'),
        ],
    hiddenimports=[
        # 导入隐藏模块,理论上应该不需要,但实测不导入会发生ModuleNotFoundError,原理暂时不明
        'PyQt6-Qt6',
        'PyQt6',
        'numpy',
        'urllib3',
        'jaconv',
        'torch',
        'torchvision',
        'transformers',
        'fugashi',
        'unidic_lite',
        'tqdm',
        'opencv-python',
        'shapely',
        'pyclipper',
        'einops',
        'termcolor',
        'bs4',
        'deepl',
        'qtpy',
        'spacy-pkuseg',
        'sentencepiece',
        'ctranslate2',
        'python-docx',
        'docx2txt',
        'piexif',
        'keyboard',
        'ordered-set',
        'opencc-python-reimplemented',
        'requests',
        'Pillow',
        'beautifulsoup4',
        'colorama',
        'gallery-dl',
        'openai',
        'pyyaml',
        'httpx',
        'langdetect',
        'pyobjc-core',
        'pyobjc-framework-cocoa',
        'pyobjc-framework-coreml',
        'pyobjc-framework-quartz',
        'pyobjc-framework-vision',
        ],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=block_cipher,
    noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
    pyz,
    a.scripts,
    [],
    exclude_binaries=True,
    name='launch',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    console=False,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)
coll = COLLECT(
    exe,
    a.binaries,
    a.zipfiles,
    a.datas,
    strip=False,
    upx=True,
    upx_exclude=[],
    name='launch',
)
app = BUNDLE(
    coll,
    name='BallonsTranslator.app',
    icon='icon.icns',
    bundle_identifier=None,
    info_plist={
        # 添加应用信息
        'CFBundleDisplayName': 'BallonsTranslator',
        'CFBundleName': 'BallonsTranslator',
        'CFBundlePackageType': 'APPL',
        'CFBundleSignature': 'BATR',
        'CFBundleShortVersionString': version,
        'CFBundleVersion': version,
        'CFBundleExecutable': 'launch',
        'CFBundleIconFile': 'icon.icns',
        'CFBundleIdentifier': 'dev.dmmaze.batr',
        'CFBundleInfoDictionaryVersion': '6.0',
        'LSApplicationCategoryType': 'public.app-category.graphics-design',
        'LSEnvironment': {'LANG': 'zh_CN.UTF-8'},
      }
)

3、Pyinstaller打包

# 安装pyinstaller
pip install pyinstaller

# pyinstaller通过spec文件打包应用
sudo pyinstaller launch.spec

4、遗留问题

dmMaze commented 1 year ago

@dmMaze 这里torchvision缺了libjpeg或libpng,但实际已经通过Homebrew安装了这两个,这个报错信息在源代码运行时是没有的,目前没找到解决这个报错信息的办法

也有用mac跑上的好像没遇上这么多事啊...我对mac生态也不了解, 可以试试py310 编辑保存状态标题栏后面有saved/unsave提示, unsaved翻页或者退出就会自动保存, 另外你导入多图文件夹还是崩吗

hyrulelinks commented 1 year ago

@dmMaze 这里torchvision缺了libjpeg或libpng,但实际已经通过Homebrew安装了这两个,这个报错信息在源代码运行时是没有的,目前没找到解决这个报错信息的办法

也有用mac跑上的好像没遇上这么多事啊...我对mac生态也不了解, 可以试试py310 编辑保存状态标题栏后面有saved/unsave提示, unsaved翻页或者退出就会自动保存, 另外你导入多图文件夹还是崩吗

导入不会崩,但运行翻译和修图就会崩,现在只能一个文件夹一张图这样挨个处理 master分支打包没那么多问题,master和dev好像变动比较大,打包app时可能问题就多了些 弄了一个下午dev打包app成功,主要是不想每次都去配python环境,想要开箱即用,结果花了不少时间解决各种各样奇怪的问题 第一次碰到pyinstaller打包时需要把自制模块源代码的文件夹直接复制到app bundle文件夹的,一般是不需要这么做的,但不这么做就无法运行,也是挺奇怪的

dmMaze commented 1 year ago

@dmMaze 这里torchvision缺了libjpeg或libpng,但实际已经通过Homebrew安装了这两个,这个报错信息在源代码运行时是没有的,目前没找到解决这个报错信息的办法

也有用mac跑上的好像没遇上这么多事啊...我对mac生态也不了解, 可以试试py310 编辑保存状态标题栏后面有saved/unsave提示, unsaved翻页或者退出就会自动保存, 另外你导入多图文件夹还是崩吗

导入不会崩,但运行翻译和修图就会崩,现在只能一个文件夹一张图这样挨个处理 master分支打包没那么多问题,master和dev好像变动比较大,打包app时可能问题就多了些 弄了一个下午dev打包app成功,主要是不想每次都去配python环境,想要开箱即用,结果花了不少时间解决各种各样奇怪的问题 第一次碰到pyinstaller打包时需要把自制模块源代码的文件夹直接复制到app bundle文件夹的,一般是不需要这么做的,但不这么做就无法运行,也是挺奇怪的

写个脚本不也是开箱即用...怎么崩的命令行没点提示吗

hyrulelinks commented 1 year ago

@dmMaze 这里torchvision缺了libjpeg或libpng,但实际已经通过Homebrew安装了这两个,这个报错信息在源代码运行时是没有的,目前没找到解决这个报错信息的办法

也有用mac跑上的好像没遇上这么多事啊...我对mac生态也不了解, 可以试试py310 编辑保存状态标题栏后面有saved/unsave提示, unsaved翻页或者退出就会自动保存, 另外你导入多图文件夹还是崩吗

导入不会崩,但运行翻译和修图就会崩,现在只能一个文件夹一张图这样挨个处理 master分支打包没那么多问题,master和dev好像变动比较大,打包app时可能问题就多了些 弄了一个下午dev打包app成功,主要是不想每次都去配python环境,想要开箱即用,结果花了不少时间解决各种各样奇怪的问题 第一次碰到pyinstaller打包时需要把自制模块源代码的文件夹直接复制到app bundle文件夹的,一般是不需要这么做的,但不这么做就无法运行,也是挺奇怪的

写个脚本不也是开箱即用...怎么崩的命令行没点提示吗

想双击桌面图标能跑起来

崩的时候都是双击应用图标运行的,没开终端,等下用终端跑崩看看有没有错误提示

hyrulelinks commented 1 year ago

两张图运行翻译修图崩溃了

截屏2023-09-07 18 12 48
❯ ./launch
py version:  3.11.5 (main, Aug 30 2023, 09:33:05) [Clang 14.0.3 (clang-1403.0.22.14.1)]
py executable:  /Users/hyrulelinks/Downloads/BallonsTranslator.app/Contents/MacOS/launch
version: 1.4.0
branch: dev
Commit hash: <none>
[INFO   ] launch:main:136 - running on macOS, set QT_API to pyqt6
torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: ''If you don't plan on using image functionality from `torchvision.io`, you can ignore this warning. Otherwise, there might be something wrong with your environment. Did you have `libjpeg` or `libpng` installed before building `torchvision` from source?
torch/_jit_internal.py:853: UserWarning: Unable to retrieve source for @torch.jit._overload function: <function _DenseLayer.forward at 0x15798b380>.
  warnings.warn(
torch/_jit_internal.py:853: UserWarning: Unable to retrieve source for @torch.jit._overload function: <function _DenseLayer.forward at 0x1579ac2c0>.
  warnings.warn(
[INFO   ] launch:main:185 - set display language to zh_CN
[INFO   ] module_manager:on_finish_settranslator:745 - Translator set to ChatGPT
[INFO   ] module_manager:on_finish_setdetector:722 - Text detector set to ctd
[INFO   ] module_manager:on_finish_setocr:729 - OCR set to mit48px_ctc
[INFO   ] module_manager:on_finish_setinpainter:736 - Inpainter set to lama_mpe
2023-09-07 18:09:40.939 launch[88010:1368158] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.
[INFO   ] trans_chatgpt:_translate:253 - Used 698 tokens (Total: 698)
[INFO   ] trans_chatgpt:_translate:253 - Used 698 tokens (Total: 1396)
Traceback (most recent call last):
  File "text_processing.py", line 191, in seg_ch_pkg
ModuleNotFoundError: No module named 'pkuseg'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "mainwindow.py", line 462, in pageListCurrentItemChanged
  File "scenetext_manager.py", line 410, in updateSceneTextitems
  File "scenetext_manager.py", line 428, in addTextBlock
  File "scenetext_manager.py", line 741, in layout_textblk
  File "text_processing.py", line 229, in seg_text
  File "text_processing.py", line 193, in seg_ch_pkg
  File "PyInstaller/loader/pyimod02_importers.py", line 385, in exec_module
  File "spacy_pkuseg/__init__.py", line 15, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 385, in exec_module
  File "spacy_pkuseg/trainer.py", line 15, in <module>
  File "spacy_pkuseg/feature_extractor.pyx", line 8, in init spacy_pkuseg.feature_extractor
ModuleNotFoundError: No module named 'srsly'
[1]    88010 abort      ./launch

奇怪这两个module不在依赖pip list里面

hyrulelinks commented 1 year ago
Traceback (most recent call last):
  File "mainwindow.py", line 462, in pageListCurrentItemChanged
  File "scenetext_manager.py", line 410, in updateSceneTextitems
  File "scenetext_manager.py", line 428, in addTextBlock
  File "scenetext_manager.py", line 741, in layout_textblk
  File "text_processing.py", line 229, in seg_text
  File "text_processing.py", line 196, in seg_ch_pkg
  File "spacy_pkuseg/__init__.py", line 232, in __init__
  File "spacy_pkuseg/__init__.py", line 147, in __init__
FileNotFoundError: [Errno 2] No such file or directory: '/Users/hyrulelinks/Downloads/BallonsTranslator.app/Contents/MacOS/spacy_pkuseg/dicts/default.pkl'
[1]    91055 abort      ./launch

srsly隐藏模块导入后错误信息变了,提示spacy_pkuseg缺了dicts文件

hyrulelinks commented 1 year ago

从sites把spacy_pkuseg/dicts/default.pkl复制到缺的地方后,显示在下载什么inpaint的什么东西,然后就timeout了 好像每次都崩在修图环节

[INFO   ] module_manager:on_finish_setdetector:722 - Text detector set to ctd
2023-09-07 18:39:56.194 launch[92289:1410629] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.
[INFO   ] module_manager:on_finish_setocr:729 - OCR set to mit48px_ctc
 35%|█████████                 | 14467072/41424981 [00:02<00:04, 5829011.31it/s][INFO   ] module_manager:on_finish_setinpainter:736 - Inpainter set to lama_mpe
100%|█████████████████████████▉| 41410560/41424981 [00:12<00:00, 3444134.70it/s]
Traceback (most recent call last):
  File "urllib3/response.py", line 436, in _error_catcher
  File "urllib3/response.py", line 518, in read
  File "http/client.py", line 466, in read
  File "socket.py", line 706, in readinto
  File "ssl.py", line 1311, in recv_into
  File "ssl.py", line 1167, in read
TimeoutError: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "mainwindow.py", line 462, in pageListCurrentItemChanged
  File "scenetext_manager.py", line 410, in updateSceneTextitems
  File "scenetext_manager.py", line 428, in addTextBlock
  File "scenetext_manager.py", line 741, in layout_textblk
  File "text_processing.py", line 229, in seg_text
  File "text_processing.py", line 196, in seg_ch_pkg
  File "spacy_pkuseg/__init__.py", line 245, in __init__
  File "spacy_pkuseg/download.py", line 38, in download_model
  File "spacy_pkuseg/download.py", line 61, in _download_url_to_file
  File "urllib3/response.py", line 511, in read
  File "contextlib.py", line 155, in __exit__
  File "urllib3/response.py", line 441, in _error_catcher
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='objects.githubusercontent.com', port=443): Read timed out.
[1]    91986 abort      ./launch
dmMaze commented 1 year ago

File "spacy_pkuseg/init.py", line 245, in init File "spacy_pkuseg/download.py", line 38, in download_model File "spacy_pkuseg/download.py", line 61, in _download_url_to_file File "urllib3/response.py", line 511, in read File "contextlib.py", line 155, in exit File "urllib3/response.py", line 441, in _error_catcher urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='objects.githubusercontent.com', port=443): Read timed out. [1] 91986 abort ./launch

这还是spacy在下不知道什么东西,你可以在设置里取消自动断句(Auto Layout),或者检查一下data/models目录下有没有一个pkuseg文件夹,没有就从网盘里下载补上

hyrulelinks commented 1 year ago

运行源代码,也开始下载东西,但下载完成没报错,源代码运行翻译多张漫画没崩,打包后app翻译多张也没崩

dmMaze commented 1 year ago

运行源代码,也开始下载东西,但下载完成没报错,源代码运行翻译多张漫画没崩,打包后app翻译多张也没崩

打包的崩溃可能是某些路径问题, 请更新到 284f18b (不保证修复

hyrulelinks commented 1 year ago

运行源代码,也开始下载东西,但下载完成没报错,源代码运行翻译多张漫画没崩,打包后app翻译多张也没崩

打包的崩溃可能是某些路径问题, 请更新到 284f18b (不保证修复

[cfde1f6]打包成功且不会报错不会崩溃了,过程稍稍有点复杂,我明天用同样方法打包[284f18b]试试看,如果也一样没有问题,那这个方法应该是通用的,我整理好再发上来

hyrulelinks commented 1 year ago

dev分支打包macOS应用(经验证无报错、无崩溃)

录屏2023-09-08 15 29 44

一、准备工作

二、运行源代码

# 安装Python 3.11.5
pyenv install '3.11.5'

# 全局启用Python 3.11.5
pyenv global '3.11.5'

# 克隆仓库 dev 分支到当前工作目录
git clone --branch dev https://github.com/dmMaze/BallonsTranslator.git

# 进入仓库的工作目录
cd BallonsTranslator

# 创建Python 3.11.5的虚拟环境
python -m venv 'venv'

# 启用Python 3.11.5的虚拟环境
# 注意:后面所有命令行都要在启用虚拟环境的终端窗口内操作
source 'venv/bin/activate'

# 安装依赖
pip install -r requirements.txt

# 将 libs 和 models 复制到 data 目录下, data 目录树如下
./data
├── alphabet-all-v5.txt
├── libs
│   ├── opencv_world455.dll # MEGA里没有,但Google Drive中有,不确定是否为必须
│   └── patchmatch_inpaint.dll
├── models
│   ├── aot_inpainter.ckpt
│   ├── comictextdetector.pt
│   ├── comictextdetector.pt.onnx
│   ├── lama_mpe.ckpt
│   ├── manga-ocr-base
│   │   ├── README.md
│   │   ├── config.json
│   │   ├── preprocessor_config.json
│   │   ├── pytorch_model.bin
│   │   ├── special_tokens_map.json
│   │   ├── tokenizer_config.json
│   │   └── vocab.txt
│   ├── mit32px_ocr.ckpt
│   ├── mit48pxctc_ocr.ckpt
│   └── pkuseg
│       ├── postag
│       │   ├── features.pkl
│       │   └── weights.npz
│       ├── postag.zip
│       ├── spacy_ontonotes
│       │   ├── features.msgpack
│       │   └── weights.npz
│       └── spacy_ontonotes.zip
└── pkusegscores.json

7 directories, 23 files

# 运行源代码
python launch.py

三、打包macOS应用

📌注意:以下基于最新的提交[284f18b]验证成功,后续提交可能因代码变动而打包失败

1、编辑launch.py

将第213-229行代码注释掉,否则打包好的应用会陷入install requirements死循环而无法启动

#    if sys.platform == 'win32':
#        for req in REQ_WIN:
#            try:
#                pkg_resources.require(req)
#            except Exception:
#                run_pip(f"install {req}", req)
#                req_updated = True

#    torch_command = os.environ.get('TORCH_COMMAND', "pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118")
#    if args.reinstall_torch or not is_installed("torch") or not is_installed("torchvision"):
#        run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
#        req_updated = True
#    try:
#        pkg_resources.require(open(args.requirements,mode='r', encoding='utf8'))
#    except Exception:
#        run_pip(f"install -r {args.requirements}", "requirements")
#        req_updated = True

2、创建launch.spec

创建launch.spec空白打包配置文件

# 在 BallonsTranslator 目录下创建打包配置文件
touch launch.spec

用文本编辑器打开launch.spec,然后将下面的代码全部复制进去,保存后关闭文本编辑器

# 导入模块
import os
import sys
from PyInstaller.utils.hooks import collect_data_files
import subprocess

# 获取提交哈希值
commit_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('utf-8').strip()  

# 构造带提交哈希值的版本号
version = "1.3.35.dev." + commit_hash

block_cipher = None

a = Analysis([
    'launch.py',
    'modules/base.py',
    'modules/inpaint/aot.py',
    'modules/inpaint/ffc.py',
    'modules/inpaint/lama.py',
    'modules/inpaint/patch_match.py',
    'modules/ocr/macos_ocr.py',
    'modules/ocr/manga_ocr.py',
    'modules/ocr/mit48px_ctc.py',
    'modules/ocr/model_32px.py',
    'modules/ocr/windows_ocr.py',
    'modules/textdetector/db_utils.py',
    'modules/textdetector/textblock.py',
    'modules/textdetector/ctd/basemodel.py',
    'modules/textdetector/ctd/inference.py',
    'modules/textdetector/ctd/textmask.py',
    'modules/textdetector/yolov5/common.py',
    'modules/textdetector/yolov5/yolo.py',
    'modules/textdetector/yolov5/yolov5_utils.py',
    'modules/translators/base.py',
    'modules/translators/constants.py',
    'modules/translators/exceptions.py',
    'modules/translators/hooks.py',
    'modules/translators/trans_baidu.py',
    'modules/translators/trans_caiyun.py',
    'modules/translators/trans_chatgpt.py',
    'modules/translators/trans_deepl.py',
    'modules/translators/trans_deeplx.py',
    'modules/translators/trans_google.py',
    'modules/translators/trans_papago.py',
    'modules/translators/trans_sugoi.py',
    'modules/translators/trans_yandex.py',
    'scripts/svgscript.py',
    'scripts/update_translation.py',
    'ui/canvas.py',
    'ui/combobox.py',
    'ui/config.py',
    'ui/configpanel.py',
    'ui/constants.py',
    'ui/cursor.py',
    'ui/dlconfig_parse_widgets.py',
    'ui/drawing_commands.py',
    'ui/drawingpanel.py',
    'ui/fontformat_commands.py',
    'ui/fontformatpanel.py',
    'ui/funcmaps.py',
    'ui/global_search_widget.py',
    'ui/image_edit.py',
    'ui/imgtrans_proj.py',
    'ui/io_thread.py',
    'ui/keywordsubwidget.py',
    'ui/mainwindow.py',
    'ui/mainwindowbars.py',
    'ui/misc.py',
    'ui/module_manager.py',
    'ui/page_search_widget.py',
    'ui/preset_widget.py',
    'ui/scene_textlayout.py',
    'ui/scenetext_manager.py',
    'ui/shared_widget.py',
    'ui/stylewidgets.py',
    'ui/text_graphical_effect.py',
    'ui/textedit_area.py',
    'ui/textedit_commands.py',
    'ui/texteditshapecontrol.py',
    'ui/textitem.py',
    'ui/framelesswindow/fw_qt6/mac/window_effect.py',
    'ui/framelesswindow/fw_qt6/utils/linux_utils.py',
    'ui/framelesswindow/fw_qt6/utils/mac_utils.py',
    'ui/framelesswindow/fw_qt6/utils/win32_utils.py',
    'utils/appinfo.py',
    'utils/imgproc_utils.py',
    'utils/io_utils.py',
    'utils/logger.py',
    'utils/registry.py',
    'utils/stroke_width_calculator.py',
    'utils/structures.py',
    'utils/text_layout.py',
    'utils/text_processing.py',
    'utils/textblock_mask.py',],
    pathex=[],
    binaries=[],
    datas=[
        ('config', './config'),
        ('data', './data'),
        ('doc', './doc'),
        ('icons', './icons'),
        ('logs', './logs'),
        ('modules', './modules'),
        ('scripts', './scripts'),
        ('translate', './translate'),
        ('ui', './ui'),
        ('utils', './utils'),
        ('venv/lib/python3.11/site-packages/spacy_pkuseg', './spacy_pkuseg'),
        ('venv/lib/python3.11/site-packages/torchvision', './torchvision'),
        ],
    hiddenimports=[
        'PyQt6',
        'numpy',
        'urllib3',
        'jaconv',
        'torch',
        'torchvision',
        'transformers',
        'fugashi',
        'unidic_lite',
        'tqdm',
        'shapely',
        'pyclipper',
        'einops',
        'termcolor',
        'bs4',
        'deepl',
        'qtpy',
        'sentencepiece',
        'ctranslate2',
        'docx2txt',
        'piexif',
        'keyboard',
        'requests',
        'colorama',
        'openai',
        'httpx',
        'langdetect',
        'srsly',
        ],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=block_cipher,
    noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
    pyz,
    a.scripts,
    [],
    exclude_binaries=True,
    name='launch',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    console=False,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)
coll = COLLECT(
    exe,
    a.binaries,
    a.zipfiles,
    a.datas,
    strip=False,
    upx=True,
    upx_exclude=[],
    name='launch',
)
app = BUNDLE(
    coll,
    name='BallonsTranslator.app',
    icon='icon.icns',
    bundle_identifier=None,
    info_plist={
        'CFBundleDisplayName': 'BallonsTranslator',
        'CFBundleName': 'BallonsTranslator',
        'CFBundlePackageType': 'APPL',
        'CFBundleSignature': 'BATR',
        'CFBundleShortVersionString': version,
        'CFBundleVersion': version,
        'CFBundleExecutable': 'launch',
        'CFBundleIconFile': 'icon.icns',
        'CFBundleIdentifier': 'dev.dmmaze.batr',
        'CFBundleInfoDictionaryVersion': '6.0',
        'LSApplicationCategoryType': 'public.app-category.graphics-design',
        'LSEnvironment': {'LANG': 'zh_CN.UTF-8'},
      }
)

3、复制icon.icns

将制作或下载的icon.icns复制到BallonsTranslator目录下,这是打包后的应用图标

4、安装pyinstaller

# 安装pyinstaller
# 注意:在虚拟环境中安装pyinstaller,否则会报错
pip install pyinstaller

5、打包macOS应用

# 通过spec配置文件打包应用
# 打包好的应用程序在 dist 目录内,由于 dist 目录权限限制原因,需要将打包好的 BallonsTranslator.app 复制到 应用程序 文件夹后再启动
sudo pyinstaller launch.spec

6、其他说明

hyrulelinks commented 1 year ago

@dmMaze opencv_world455.dll这个文件是必须的嘛?

./data
├── libs
│   ├── opencv_world455.dll # MEGA里没有,但Google Drive中有,不确定是否为必须
dmMaze commented 1 year ago

@dmMaze opencv_world455.dll这个文件是必须的嘛?

./data
├── libs
│   ├── opencv_world455.dll # MEGA里没有,但Google Drive中有,不确定是否为必须

如果你不用patchmatch inpainting就不是,这个是它的依赖库不过是win上的,如果你要用需要自行编译https://github.com/dmMaze/PyPatchMatchInpaint/tree/linux_build

hyrulelinks commented 1 year ago

@dmMaze libpatchmatch_inpaint.dylib.zip 我在macOS上编译出来的动态库文件名是libpatchmatch_inpaint.dylib 这两个dll文件都是给win用的,那编译的mac动态库只有一个,要怎么替换这两个哈?

│   ├── opencv_world455.dll
│   └── patchmatch_inpaint.dll
dmMaze commented 1 year ago

@dmMaze libpatchmatch_inpaint.dylib.zip 我在macOS上编译出来的动态库文件名是libpatchmatch_inpaint.dylib 这两个dll文件都是给win用的,那编译的mac动态库只有一个,要怎么替换这两个哈?

│   ├── opencv_world455.dll
│   └── patchmatch_inpaint.dll

更新到 62f1d3e1da9a17ce1f67e8be78c76f62af3f62ca , 把libpatchmatch_inpaint.dylib放到data/libs下面 这个要和它编译依赖的opencv库一起才能用, 我不确定macOS不同系统能不能直接share这种库...

hyrulelinks commented 1 year ago

更新到 62f1d3e , 把libpatchmatch_inpaint.dylib放到data/libs下面 这个要和它编译依赖的opencv库一起才能用, 我不确定macOS不同系统能不能直接share这种库...

dll在macOS应该是不能直接用的,我在wps office的应用包里找到libopencv_world.4.4.0.dylib,应该对应的是dll,但版本号不是4.5.5的

我尝试本地编译opencv并启用build opencv world选项,但编译全部失败,现在有点没办法了,可能只能用libopencv_world.4.4.0.dylib代替,不清楚兼容性如何

hyrulelinks commented 1 year ago

@dmMaze 请问直接把libpatchmatch_inpaint.dylib和libopencv_world.4.4.0.dylib放进data/libs文件夹就可以吗,这个在前端使用时表现为什么修图效果,我想试试看是否会生效

更新:我尝试了上面的方法,在应用中选择patchmatch,该功能可以用,但修图效果不及lama_mpe,可能是我用法不对

dmMaze commented 1 year ago

更新:我尝试了上面的方法,在应用中选择patchmatch,该功能可以用,但修图效果不及lama_mpe,可能是我用法不对

这个对一些重复pattern (网点) 和材质修复效果偶尔比lama好一点

hyrulelinks commented 1 year ago

@dmMaze 请问models里面这些模型在github或者huggingface上的仓库是哪几个,我向学习下,谢谢

dmMaze commented 1 year ago

@dmMaze 请问models里面这些模型在github或者huggingface上的仓库是哪几个,我向学习下,谢谢

没有一个集中的huggingface仓库, lama是用https://github.com/advimman/lama 在我自己一个动画数据集上训练的, 有些改动不过其实没什么用所以你可以直接参考原仓库, 其它模型来源README里有写

dmMaze commented 10 months ago

@hyrulelinks 直接用你那个编译过的patchmatch报缺库了,我又自己编译了下opencv和patchmatch,你试试有没有问题 现在更新了软件内自动下载和校验,所以你只需要pull一下再启动就会下载这些库了,试我编译的库前先删掉你的

hyrulelinks commented 10 months ago

抱歉我刚看到,我明天试试

hyrulelinks commented 10 months ago

更新下,重新拉源码运行python3 launch.py会开始下载data相关文件,但hash校验通不过,试了很多次,下载速度大概平均5mb/s,中间没卡过,但下载完就提示hash不对,可能pre-calculated hash值有问题,然后就是一直重复下载,没有办法启动程序,另外我还没试过Pyinstaller打包,不知道直接源码打包是不是能启动这个程序,因为.app对下载东西到应用程序内的权限控制非常严格,可能还会报错 @dmMaze

dmMaze commented 10 months ago

但hash校验通不过,

具体哪些不通过

hyrulelinks commented 10 months ago
❯ python3 launch.py
/Users/hyrulelinks/Downloads/BallonsTranslator/launch.py:10: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  import pkg_resources
py version:  3.11.6 (main, Oct  2 2023, 13:45:54) [Clang 15.0.0 (clang-1500.0.40.1)]
py executable:  /Users/hyrulelinks/Downloads/venv/bin/python3
version: 1.4.0
branch: dev
Commit hash: fd9c108b847fc5688aeb2abb55af3f3eef32bf30
[INFO   ] launch:main:160 - /Users/hyrulelinks/Downloads/BallonsTranslator/config/config.json does not exist, new config file will be created.
[WARNING] download_util:try_download_files:247 - Mismatch between local file data/models/lama_large_512px.ckpt and pre-calculated hash: "b3baa29a684f98fc3752f3d29cc54e6368e9aa6088cb05b9db8791481f0d86a8" <-> "11d30fbb3000fb2eceae318b75d9ced9229d99ae990a7f8b3ac35c8d31f2c935", it will be redownloaded...
lama_large_512px.ckpt: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 195M/195M [02:05<00:00, 1.63MiB/s]
[ERROR  ] download_util:try_download_files:272 - Traceback (most recent call last):
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/utils/download_util.py", line 267, in try_download_files
    raise Exception(f'Mismatch between newly downloaded {savep} and pre-calculated hash: "{sha256_calculated}" <-> "{sha256_precal.lower()}"')
Exception: Mismatch between newly downloaded data/models/lama_large_512px.ckpt and pre-calculated hash: "a36bbaa2aefa9f7f9778f10b56e058ea7857e72136e443f90c10fde0977b1531" <-> "11d30fbb3000fb2eceae318b75d9ced9229d99ae990a7f8b3ac35c8d31f2c935"

[ERROR  ] download_util:try_download_files:273 - Failed downloading data/models/lama_large_512px.ckpt from https://huggingface.co/dreMaz/AnimeMangaInpainting/resolve/main/lama_large_512px.ckpt, please manually save it to data/models/lama_large_512px.ckpt
[ERROR  ] prepare_local_files:download_and_check_module_files:25 - Please save these files manually to sepcified path and restart the application, otherwise <class 'modules.inpaint.base.LamaLarge'> will be unavailable.
[WARNING] download_util:try_download_files:247 - Mismatch between local file data/models/manga-ocr-base/pytorch_model.bin and pre-calculated hash: "2e591d03f88f3847bccf9f168286c79f95599f655206d882e71cfdd6dc02aa70" <-> "c63e0bb5b3ff798c5991de18a8e0956c7ee6d1563aca6729029815eda6f5c2eb", it will be redownloaded...
pytorch_model.bin: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 424M/424M [03:19<00:00, 2.22MiB/s]
[ERROR  ] download_util:try_download_files:272 - Traceback (most recent call last):
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/utils/download_util.py", line 267, in try_download_files
    raise Exception(f'Mismatch between newly downloaded {savep} and pre-calculated hash: "{sha256_calculated}" <-> "{sha256_precal.lower()}"')
Exception: Mismatch between newly downloaded data/models/manga-ocr-base/pytorch_model.bin and pre-calculated hash: "8446615404ac429c144ece2a0be5d7331713f82a0d89fcf9aea99ecd7ead1a77" <-> "c63e0bb5b3ff798c5991de18a8e0956c7ee6d1563aca6729029815eda6f5c2eb"

[ERROR  ] download_util:try_download_files:273 - Failed downloading pytorch_model.bin from https://huggingface.co/kha-white/manga-ocr-base/resolve/main/pytorch_model.bin, please manually save it to data/models/manga-ocr-base/pytorch_model.bin
[ERROR  ] prepare_local_files:download_and_check_module_files:25 - Please save these files manually to sepcified path and restart the application, otherwise <class 'modules.ocr.MangaOCR'> will be unavailable.
[WARNING] download_util:try_download_files:247 - Mismatch between local file /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/ocr-ctc.zip and pre-calculated hash: "c3ff3977b270c626b591ca44b8b06d8df74a6b5d93317413ba6aa165ed54558e" <-> "fc61c52f7a811bc72c54f6be85df814c6b60f63585175db27cb94a08e0c30101", it will be redownloaded...
ocr-ctc.zip: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 138M/138M [02:17<00:00, 1.05MiB/s]
[ERROR  ] download_util:try_download_files:272 - Traceback (most recent call last):
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/utils/download_util.py", line 267, in try_download_files
    raise Exception(f'Mismatch between newly downloaded {savep} and pre-calculated hash: "{sha256_calculated}" <-> "{sha256_precal.lower()}"')
Exception: Mismatch between newly downloaded /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/ocr-ctc.zip and pre-calculated hash: "1bf43c503c745bb4cff153dadb434ae6f2aa031d445207b18a6cff92882d3204" <-> "fc61c52f7a811bc72c54f6be85df814c6b60f63585175db27cb94a08e0c30101"

[ERROR  ] download_util:try_download_files:273 - Failed downloading ocr-ctc.zip from https://github.com/zyddnys/manga-image-translator/releases/download/beta-0.3/ocr-ctc.zip, please manually save it to /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/ocr-ctc.zip
[ERROR  ] prepare_local_files:download_and_check_module_files:25 - Please save these files manually to sepcified path and restart the application, otherwise <class 'modules.ocr.OCRMIT48pxCTC'> will be unavailable.
[INFO   ] download_util:download_and_check_files:346 - Extracting /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/postag.zip ...
Traceback (most recent call last):
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/launch.py", line 281, in <module>
    main()
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/launch.py", line 166, in main
    prepare_local_files_forall()
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/modules/prepare_local_files.py", line 71, in prepare_local_files_forall
    prepare_pkuseg()
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/modules/prepare_local_files.py", line 50, in prepare_pkuseg
    download_and_check_files(**files_download_kwargs)
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/utils/download_util.py", line 347, in download_and_check_files
    shutil.unpack_archive(archivep, extract_dir)
  File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 1327, in unpack_archive
    func(filename, extract_dir, **kwargs)
  File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 1214, in _unpack_zipfile
    raise ReadError("%s is not a zip file" % filename)
shutil.ReadError: /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/postag.zip is not a zip file
[INFO   ] utils:dump_compile_times:247 - TorchDynamo compilation metrics:
Function, Runtimes (s)
[INFO   ] utils:dump_compile_times:247 - TorchDynamo compilation metrics:
Function, Runtimes (s)
[2023-11-13 11:29:57,373] torch._dynamo.utils: [INFO] TorchDynamo compilation metrics:
[2023-11-13 11:29:57,373] torch._dynamo.utils: [INFO] Function, Runtimes (s)

lama_large_512px.ckpt pytorch_model.bin ocr-ctc.zip这三个通不过,并且从源码层面修改pre-calculated hash为报错信息中提示的hash后,再次下载的文件的hash和之前提示的又不一样了,这样重复来了下载了三次才发现每次下载的文件hash都不一样。下载的时候速度很快,但在99%会停顿很久,不知道是不是这个原因。最后从源码层面把不通过的pre-calculated hash改成None后通过了。

[INFO   ] download_util:download_and_check_files:346 - Extracting /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/postag.zip ...
Traceback (most recent call last):
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/launch.py", line 281, in <module>
    main()
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/launch.py", line 166, in main
    prepare_local_files_forall()
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/modules/prepare_local_files.py", line 71, in prepare_local_files_forall
    prepare_pkuseg()
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/modules/prepare_local_files.py", line 50, in prepare_pkuseg
    download_and_check_files(**files_download_kwargs)
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/utils/download_util.py", line 347, in download_and_check_files
    shutil.unpack_archive(archivep, extract_dir)
  File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 1327, in unpack_archive
    func(filename, extract_dir, **kwargs)
  File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 1214, in _unpack_zipfile
    raise ReadError("%s is not a zip file" % filename)
shutil.ReadError: /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/postag.zip is not a zip file

然后是下载postag.zip和spacy_ontonotes.zip报错,说不是zip,但我看了缓存文件夹里,是zip,文件大小也对,也不知道是怎么回事,后来我自己手动下载后放.btrans_cache缓存文件夹内,再运行就通过了

然后启动运行程序,还是会报错下面这个:

❯ python3 launch.py
/Users/hyrulelinks/Downloads/BallonsTranslator/launch.py:10: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  import pkg_resources
py version:  3.11.6 (main, Oct  2 2023, 13:45:54) [Clang 15.0.0 (clang-1500.0.40.1)]
py executable:  /Users/hyrulelinks/Downloads/venv/bin/python3
version: 1.4.0
branch: dev
Commit hash: fd9c108b847fc5688aeb2abb55af3f3eef32bf30
[INFO   ] launch:main:183 - QT_API: pyqt6, QT Version: 6.4.2
[WARNING] launch:main:210 - target display language file /Users/hyrulelinks/Downloads/BallonsTranslator/translate/en_CN.qm doesnt exist.
[INFO   ] launch:main:211 - set display language to en_CN
[INFO   ] module_manager:on_finish_settranslator:801 - Translator set to google
[ERROR  ] module_manager:handleRunTimeException:876 - Failed to set lama_large_512px: PytorchStreamReader failed reading zip archive: failed finding central directory
Traceback (most recent call last):
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/ui/module_manager.py", line 53, in _set_module
    self.module = module(**params)
                  ^^^^^^^^^^^^^^^^
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/modules/inpaint/base.py", line 33, in __init__
    self.setup_inpainter()
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/modules/inpaint/base.py", line 449, in setup_inpainter
    self.model = LAMA_LARGE = load_lama_mpe(r'data/models/lama_large_512px.ckpt', device='cpu', use_mpe=False, large_arch=True)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/modules/inpaint/lama.py", line 425, in load_lama_mpe
    sd = torch.load(model_path, map_location = 'cpu')
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyrulelinks/Downloads/venv/lib/python3.11/site-packages/torch/serialization.py", line 993, in load
    with _open_zipfile_reader(opened_file) as opened_zipfile:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyrulelinks/Downloads/venv/lib/python3.11/site-packages/torch/serialization.py", line 447, in __init__
    super().__init__(torch._C.PyTorchFileReader(name_or_buffer))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

[INFO   ] module_manager:on_finish_setocr:786 - OCR set to mit48px_ctc
[INFO   ] module_manager:on_finish_setdetector:780 - Text detector set to ctd
[INFO   ] utils:dump_compile_times:247 - TorchDynamo compilation metrics:
Function, Runtimes (s)
[INFO   ] utils:dump_compile_times:247 - TorchDynamo compilation metrics:
Function, Runtimes (s)
[2023-11-13 13:42:52,696] torch._dynamo.utils: [INFO] TorchDynamo compilation metrics:
[2023-11-13 13:42:52,696] torch._dynamo.utils: [INFO] Function, Runtimes (s)

pkg_resources显示已经弃用了,可能这个模块需要更新下

en_CN.qm显示不存在,启动后界面是英文,启动几次就提示几次,这个文件我没找到,是不是应该改成zh_CN.qm?

RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory这个报错我完全没头绪,应该是torch的问题,是要读取zip文件,这里好像没有zip需要读取 @dmMaze

hyrulelinks commented 10 months ago

另外macos_libopencv_world.4.8.0.dylib这个怎么只有9.5mb,是作者自己编译的吗,我编译出来30多mb,求教编译过程,我的编译过程报错很多

dmMaze commented 10 months ago

@hyrulelinks 试试在源码目录跑下面代码:

import torch
torch.load('data/models/lama_large_512px.ckpt', map_location='cpu')

如果报错大概就是你那三个模型都下载失败了,所以torch直接读取失败,试试拉 849800a 再重新下载,我换了个下载接口,另外方便的话把你的lama_large_512px.ckpt(如果上面代码报错的话)传个网盘share给我

另外macos_libopencv_world.4.8.0.dylib这个怎么只有9.5mb,是作者自己编译的吗,我编译出来30多mb,求教编译过程,我的编译过程报错很多

你软件里试过patchmatch能正常使用吗? cmake里编译opencv的时候可以去掉不需要的模块, 留core, imgcodecs和imgproc

hyrulelinks commented 10 months ago
❯ python3 launch.py
/Users/hyrulelinks/Downloads/BallonsTranslator/launch.py:10: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  import pkg_resources
py version:  3.11.6 (main, Oct  2 2023, 13:45:54) [Clang 15.0.0 (clang-1500.0.40.1)]
py executable:  /Users/hyrulelinks/Downloads/venv/bin/python3
version: 1.4.0
branch: dev
Commit hash: 99a94ba35750d4c34d4668b54c7a72f94ddced18
[INFO   ] launch:main:160 - /Users/hyrulelinks/Downloads/BallonsTranslator/config/config.json does not exist, new config file will be created.
[INFO   ] download_util:try_download_files:260 - downloading /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/macos_patchmatch_libs.7z from https://github.com/dmMaze/PyPatchMatchInpaint/releases/download/v1.0/macos_arm64_patchmatch_libs.7z ...
  5%|██████▋                                                                                                                               | 126k/2.47M [00:00<00:09, 252kB/s]
[ERROR  ] download_util:try_download_files:273 - Traceback (most recent call last):
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/utils/download_util.py", line 268, in try_download_files
    raise Exception(f'Mismatch between newly downloaded {savep} and pre-calculated hash: "{sha256_calculated}" <-> "{sha256_precal.lower()}"')
Exception: Mismatch between newly downloaded /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/macos_patchmatch_libs.7z and pre-calculated hash: "6a4b55cc49e89b4d63f2e79ba63a7cbb9b7fc52cb975bd1bd833ccb3921bfcdd" <-> "9f332c888be0f160dbe9f6d6887eb698a302e62f4c102a0f24359c540d5858ea"

[ERROR  ] download_util:try_download_files:274 - Failed downloading macos_patchmatch_libs.7z from https://github.com/dmMaze/PyPatchMatchInpaint/releases/download/v1.0/macos_arm64_patchmatch_libs.7z, please manually save it to /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/macos_patchmatch_libs.7z
[ERROR  ] prepare_local_files:download_and_check_module_files:25 - Please save these files manually to sepcified path and restart the application, otherwise <class 'modules.inpaint.base.PatchmatchInpainter'> will be unavailable.
[INFO   ] download_util:try_download_files:260 - downloading data/models/aot_inpainter.ckpt from https://github.com/zyddnys/manga-image-translator/releases/download/beta-0.3/inpainting.ckpt ...
  5%|██████▋                                                                                                                              | 1.10M/21.7M [00:01<00:25, 842kB/s]
[ERROR  ] download_util:try_download_files:273 - Traceback (most recent call last):
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/utils/download_util.py", line 268, in try_download_files
    raise Exception(f'Mismatch between newly downloaded {savep} and pre-calculated hash: "{sha256_calculated}" <-> "{sha256_precal.lower()}"')
Exception: Mismatch between newly downloaded data/models/aot_inpainter.ckpt and pre-calculated hash: "109fd67033676b2c47763265cb128d80d0309d4184762f5061e838a099b2e7d9" <-> "878d541c68648969bc1b042a6e997f3a58e49b6c07c5636ad55130736977149f"

[ERROR  ] download_util:try_download_files:274 - Failed downloading data/models/aot_inpainter.ckpt from https://github.com/zyddnys/manga-image-translator/releases/download/beta-0.3/inpainting.ckpt, please manually save it to data/models/aot_inpainter.ckpt
[ERROR  ] prepare_local_files:download_and_check_module_files:25 - Please save these files manually to sepcified path and restart the application, otherwise <class 'modules.inpaint.base.AOTInpainter'> will be unavailable.
[INFO   ] download_util:try_download_files:260 - downloading data/models/lama_mpe.ckpt from https://github.com/zyddnys/manga-image-translator/releases/download/beta-0.3/inpainting_lama_mpe.ckpt ...
 11%|██████████████▍                                                                                                                      | 11.2M/104M [00:03<00:32, 2.96MB/s]
[ERROR  ] download_util:try_download_files:273 - Traceback (most recent call last):
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/utils/download_util.py", line 268, in try_download_files
    raise Exception(f'Mismatch between newly downloaded {savep} and pre-calculated hash: "{sha256_calculated}" <-> "{sha256_precal.lower()}"')
Exception: Mismatch between newly downloaded data/models/lama_mpe.ckpt and pre-calculated hash: "13d8591b1cb5a9375fff16a32c3bf9acfc9e5e055f1e68c33586ee5cff5d01ec" <-> "d625aa1b3e0d0408acfd6928aa84f005867aa8dbb9162480346a4e20660786cc"

[ERROR  ] download_util:try_download_files:274 - Failed downloading data/models/lama_mpe.ckpt from https://github.com/zyddnys/manga-image-translator/releases/download/beta-0.3/inpainting_lama_mpe.ckpt, please manually save it to data/models/lama_mpe.ckpt
[ERROR  ] prepare_local_files:download_and_check_module_files:25 - Please save these files manually to sepcified path and restart the application, otherwise <class 'modules.inpaint.base.LamaInpainterMPE'> will be unavailable.
[INFO   ] download_util:try_download_files:260 - downloading data/models/lama_large_512px.ckpt from https://huggingface.co/dreMaz/AnimeMangaInpainting/resolve/main/lama_large_512px.ckpt ...
 16%|████████████████████▉                                                                                                                | 30.8M/195M [00:07<00:42, 4.07MB/s]
[ERROR  ] download_util:try_download_files:273 - Traceback (most recent call last):
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/utils/download_util.py", line 268, in try_download_files
    raise Exception(f'Mismatch between newly downloaded {savep} and pre-calculated hash: "{sha256_calculated}" <-> "{sha256_precal.lower()}"')
Exception: Mismatch between newly downloaded data/models/lama_large_512px.ckpt and pre-calculated hash: "7dc5f6b00289d4281c0cdccbdd0f1b28225e62b0266b00b09ccc3bb5f49dd965" <-> "11d30fbb3000fb2eceae318b75d9ced9229d99ae990a7f8b3ac35c8d31f2c935"

[ERROR  ] download_util:try_download_files:274 - Failed downloading data/models/lama_large_512px.ckpt from https://huggingface.co/dreMaz/AnimeMangaInpainting/resolve/main/lama_large_512px.ckpt, please manually save it to data/models/lama_large_512px.ckpt
[ERROR  ] prepare_local_files:download_and_check_module_files:25 - Please save these files manually to sepcified path and restart the application, otherwise <class 'modules.inpaint.base.LamaLarge'> will be unavailable.
[INFO   ] download_util:try_download_files:260 - downloading data/models/comictextdetector.pt from https://github.com/zyddnys/manga-image-translator/releases/download/beta-0.3/comictextdetector.pt ...
 13%|████████████████▋                                                                                                                   | 9.62M/76.2M [00:03<00:24, 2.86MB/s]
[ERROR  ] download_util:try_download_files:273 - Traceback (most recent call last):
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/utils/download_util.py", line 268, in try_download_files
    raise Exception(f'Mismatch between newly downloaded {savep} and pre-calculated hash: "{sha256_calculated}" <-> "{sha256_precal.lower()}"')
Exception: Mismatch between newly downloaded data/models/comictextdetector.pt and pre-calculated hash: "9e20ec04ad5e03aa895d519a3e17cfb6079bd5a5523dd76ab776ed47806aa808" <-> "1f90fa60aeeb1eb82e2ac1167a66bf139a8a61b8780acd351ead55268540cccb"

[ERROR  ] download_util:try_download_files:274 - Failed downloading data/models/comictextdetector.pt from https://github.com/zyddnys/manga-image-translator/releases/download/beta-0.3/comictextdetector.pt, please manually save it to data/models/comictextdetector.pt
[INFO   ] download_util:try_download_files:260 - downloading data/models/comictextdetector.pt.onnx from https://github.com/zyddnys/manga-image-translator/releases/download/beta-0.3/comictextdetector.pt.onnx ...
 14%|██████████████████▎                                                                                                                 | 12.5M/90.3M [00:04<00:25, 3.24MB/s]
[ERROR  ] download_util:try_download_files:273 - Traceback (most recent call last):
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/utils/download_util.py", line 268, in try_download_files
    raise Exception(f'Mismatch between newly downloaded {savep} and pre-calculated hash: "{sha256_calculated}" <-> "{sha256_precal.lower()}"')
Exception: Mismatch between newly downloaded data/models/comictextdetector.pt.onnx and pre-calculated hash: "bbd87ea7c5345727c0a56ae915d9c5e6f5027bf4a6f500971ba3258dcc03f73e" <-> "1a86ace74961413cbd650002e7bb4dcec4980ffa21b2f19b86933372071d718f"

[ERROR  ] download_util:try_download_files:274 - Failed downloading data/models/comictextdetector.pt.onnx from https://github.com/zyddnys/manga-image-translator/releases/download/beta-0.3/comictextdetector.pt.onnx, please manually save it to data/models/comictextdetector.pt.onnx
[ERROR  ] prepare_local_files:download_and_check_module_files:25 - Please save these files manually to sepcified path and restart the application, otherwise <class 'modules.textdetector.ComicTextDetector'> will be unavailable.
[INFO   ] download_util:try_download_files:260 - downloading /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/ocr.zip from https://github.com/zyddnys/manga-image-translator/releases/download/beta-0.3/ocr.zip ...
 15%|███████████████████▋                                                                                                                 | 21.6M/146M [00:05<00:30, 4.27MB/s]
[ERROR  ] download_util:try_download_files:273 - Traceback (most recent call last):
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/utils/download_util.py", line 268, in try_download_files
    raise Exception(f'Mismatch between newly downloaded {savep} and pre-calculated hash: "{sha256_calculated}" <-> "{sha256_precal.lower()}"')
Exception: Mismatch between newly downloaded /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/ocr.zip and pre-calculated hash: "1cd20828f73ce98e98e66f2b98d7704a3fd148ea7d0fabb5a1f9c04a552a1d28" <-> "47405638b96fa2540a5ee841a4cd792f25062c09d9458a973362d40785f95d7a"

[ERROR  ] download_util:try_download_files:274 - Failed downloading ocr.zip from https://github.com/zyddnys/manga-image-translator/releases/download/beta-0.3/ocr.zip, please manually save it to /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/ocr.zip
[ERROR  ] prepare_local_files:download_and_check_module_files:25 - Please save these files manually to sepcified path and restart the application, otherwise <class 'modules.ocr.OCRMIT32px'> will be unavailable.
[INFO   ] download_util:try_download_files:260 - downloading data/models/manga-ocr-base/pytorch_model.bin from https://huggingface.co/kha-white/manga-ocr-base/resolve/main/pytorch_model.bin ...
 24%|███████████████████████████████▊                                                                                                      | 101M/424M [00:24<01:17, 4.36MB/s]
[ERROR  ] download_util:try_download_files:273 - Traceback (most recent call last):
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/utils/download_util.py", line 268, in try_download_files
    raise Exception(f'Mismatch between newly downloaded {savep} and pre-calculated hash: "{sha256_calculated}" <-> "{sha256_precal.lower()}"')
Exception: Mismatch between newly downloaded data/models/manga-ocr-base/pytorch_model.bin and pre-calculated hash: "bf1576648bb4cf2106e31808087f5084d4d5b8120160da64d5096c96351cb4a9" <-> "c63e0bb5b3ff798c5991de18a8e0956c7ee6d1563aca6729029815eda6f5c2eb"

[ERROR  ] download_util:try_download_files:274 - Failed downloading pytorch_model.bin from https://huggingface.co/kha-white/manga-ocr-base/resolve/main/pytorch_model.bin, please manually save it to data/models/manga-ocr-base/pytorch_model.bin
[INFO   ] download_util:try_download_files:260 - downloading data/models/manga-ocr-base/config.json from https://huggingface.co/kha-white/manga-ocr-base/resolve/main/config.json ...
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 75.7k/75.7k [00:00<00:00, 234kB/s]
[INFO   ] download_util:try_download_files:260 - downloading data/models/manga-ocr-base/preprocessor_config.json from https://huggingface.co/kha-white/manga-ocr-base/resolve/main/preprocessor_config.json ...
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 228/228 [00:00<00:00, 402kB/s]
[INFO   ] download_util:try_download_files:260 - downloading data/models/manga-ocr-base/README.md from https://huggingface.co/kha-white/manga-ocr-base/resolve/main/README.md ...
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 705/705 [00:00<00:00, 474kB/s]
[INFO   ] download_util:try_download_files:260 - downloading data/models/manga-ocr-base/special_tokens_map.json from https://huggingface.co/kha-white/manga-ocr-base/resolve/main/special_tokens_map.json ...
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 112/112 [00:00<00:00, 111kB/s]
[INFO   ] download_util:try_download_files:260 - downloading data/models/manga-ocr-base/tokenizer_config.json from https://huggingface.co/kha-white/manga-ocr-base/resolve/main/tokenizer_config.json ...
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 486/486 [00:00<00:00, 111kB/s]
[INFO   ] download_util:try_download_files:260 - downloading data/models/manga-ocr-base/vocab.txt from https://huggingface.co/kha-white/manga-ocr-base/resolve/main/vocab.txt ...
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 23.5k/23.5k [00:00<00:00, 823kB/s]
[ERROR  ] prepare_local_files:download_and_check_module_files:25 - Please save these files manually to sepcified path and restart the application, otherwise <class 'modules.ocr.MangaOCR'> will be unavailable.
[INFO   ] download_util:try_download_files:260 - downloading /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/ocr-ctc.zip from https://github.com/zyddnys/manga-image-translator/releases/download/beta-0.3/ocr-ctc.zip ...
 22%|█████████████████████████████▊                                                                                                       | 30.9M/138M [00:07<00:26, 4.29MB/s]
[ERROR  ] download_util:try_download_files:273 - Traceback (most recent call last):
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/utils/download_util.py", line 268, in try_download_files
    raise Exception(f'Mismatch between newly downloaded {savep} and pre-calculated hash: "{sha256_calculated}" <-> "{sha256_precal.lower()}"')
Exception: Mismatch between newly downloaded /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/ocr-ctc.zip and pre-calculated hash: "d0705f2cd0b90e2940cc970336532529a2e092598472a4e28e620bfd27c509ce" <-> "fc61c52f7a811bc72c54f6be85df814c6b60f63585175db27cb94a08e0c30101"

[ERROR  ] download_util:try_download_files:274 - Failed downloading ocr-ctc.zip from https://github.com/zyddnys/manga-image-translator/releases/download/beta-0.3/ocr-ctc.zip, please manually save it to /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/ocr-ctc.zip
[ERROR  ] prepare_local_files:download_and_check_module_files:25 - Please save these files manually to sepcified path and restart the application, otherwise <class 'modules.ocr.OCRMIT48pxCTC'> will be unavailable.
[INFO   ] download_util:try_download_files:260 - downloading data/models/ocr_ar_48px.ckpt from https://huggingface.co/zyddnys/manga-image-translator/resolve/main/ocr_ar_48px.ckpt ...
 17%|███████████████████████▏                                                                                                             | 34.0M/195M [00:08<00:38, 4.43MB/s]
[ERROR  ] download_util:try_download_files:273 - Traceback (most recent call last):
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/utils/download_util.py", line 268, in try_download_files
    raise Exception(f'Mismatch between newly downloaded {savep} and pre-calculated hash: "{sha256_calculated}" <-> "{sha256_precal.lower()}"')
Exception: Mismatch between newly downloaded data/models/ocr_ar_48px.ckpt and pre-calculated hash: "069c2bbed0f3492859c687ff03ae6ce5e92da003ca7889eb62ae08d83ebcfdb7" <-> "29daa46d080818bb4ab239a518a88338cbccff8f901bef8c9db191a7cb97671d"

[ERROR  ] download_util:try_download_files:274 - Failed downloading data/models/ocr_ar_48px.ckpt from https://huggingface.co/zyddnys/manga-image-translator/resolve/main/ocr_ar_48px.ckpt, please manually save it to data/models/ocr_ar_48px.ckpt
[INFO   ] download_util:try_download_files:260 - downloading data/alphabet-all-v7.txt from https://huggingface.co/zyddnys/manga-image-translator/resolve/main/alphabet-all-v7.txt ...
 61%|██████████████████████████████████████████████████████████████████████████████████▉                                                    | 112k/182k [00:00<00:00, 144kB/s]
[ERROR  ] prepare_local_files:download_and_check_module_files:25 - Please save these files manually to sepcified path and restart the application, otherwise <class 'modules.ocr.OCRMIT48px'> will be unavailable.
[INFO   ] download_util:try_download_files:260 - downloading /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/postag.zip from https://github.com/lancopku/pkuseg-python/releases/download/v0.0.16/postag.zip ...
 13%|█████████████████▎                                                                                                                  | 5.18M/39.5M [00:02<00:14, 2.50MB/s]
[INFO   ] download_util:download_and_check_files:347 - Extracting /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/postag.zip ...
Traceback (most recent call last):
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/launch.py", line 281, in <module>
    main()
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/launch.py", line 166, in main
    prepare_local_files_forall()
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/modules/prepare_local_files.py", line 71, in prepare_local_files_forall
    prepare_pkuseg()
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/modules/prepare_local_files.py", line 50, in prepare_pkuseg
    download_and_check_files(**files_download_kwargs)
  File "/Users/hyrulelinks/Downloads/BallonsTranslator/utils/download_util.py", line 348, in download_and_check_files
    shutil.unpack_archive(archivep, extract_dir)
  File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 1327, in unpack_archive
    func(filename, extract_dir, **kwargs)
  File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 1214, in _unpack_zipfile
    raise ReadError("%s is not a zip file" % filename)
shutil.ReadError: /Users/hyrulelinks/Downloads/BallonsTranslator/.btrans_cache/postag.zip is not a zip file
[INFO   ] utils:dump_compile_times:247 - TorchDynamo compilation metrics:
Function, Runtimes (s)
[INFO   ] utils:dump_compile_times:247 - TorchDynamo compilation metrics:
Function, Runtimes (s)
[2023-11-14 16:50:14,300] torch._dynamo.utils: [INFO] TorchDynamo compilation metrics:
[2023-11-14 16:50:14,300] torch._dynamo.utils: [INFO] Function, Runtimes (s)

下载全部失败,速度是满格的,但下了一部分就报错失败,然后下载下一个,继续报错,直到全部报错完

你软件里试过patchmatch能正常使用吗

能正常使用

@dmMaze

hyrulelinks commented 10 months ago

换了个网络环境,多试几次可以下载全,但过程确实比较煎熬,经常400多MB还差几MB就报错,试了很多次才下完整,从源码可以正常运行,首次启动会生成config,里面有个错误是界面语言文件找不到en_CN.qm,需要先把界面调成英文,再调回中文,config里面才会变成正确的zh_CN.qm @dmMaze