Unverified Commit 36d9f3ca authored by Sergey Pinus's avatar Sergey Pinus Committed by GitHub
Browse files

Merge branch 'dmMaze:dev' into dev

parents 989b553f ef640b62
Loading
Loading
Loading
Loading
+18 −25
Original line number Diff line number Diff line
@@ -166,6 +166,7 @@ Sugoi 翻译器作者: [mingshiba](https://www.patreon.com/mingshiba)
 * 支持两个版本的 OpenAI 兼容翻译器,支持兼容 OpenAI API 的官方或第三方LLM提供商,需要在设置面板里配置。
   * 无后缀版本token消耗更小,但分句稳定性稍差,长文本翻译可能有问题。
   * exp后缀版本token消耗更大,但稳定性更好,且在Prompt中进行了“越狱”,适合长文本翻译。
 * [m2m100](https://huggingface.co/facebook/m2m100_1.2B): 下载并将 m2m100-1.2B-ctranslate2 移到 data/models 目录下

其它优秀的离线英文翻译模型请参考[这条讨论](https://github.com/dmMaze/BallonsTranslator/discussions/515)  
如需添加新的翻译器请参考[加别的翻译器](doc/加别的翻译器.md),本程序添加新翻译器只需要继承基类实现两个接口即可不需要理会代码其他部分,欢迎大佬提 pr
@@ -175,23 +176,14 @@ Sugoi 翻译器作者: [mingshiba](https://www.patreon.com/mingshiba)
* 感谢 [bropines](https://github.com/bropines) 提供俄语翻译
* 第三方输入法可能会造成右侧编辑框显示 bug,见[#76](https://github.com/dmMaze/BallonsTranslator/issues/76),暂时不打算修
* 选中文本迷你菜单支持*聚合词典专业划词翻译*[沙拉查词](https://saladict.crimx.com): [安装说明](doc/saladict_chs.md)
* 启用 AMD(ROCm6)显卡加速步骤
   * 更新显卡驱动至最新版(建议 24.12.1 及以上)
   * 下载并安装 [AMD HIP SDK 6.2](https://www.amd.com/en/developer/resources/rocm-hub/hip-sdk.html)
   * 下载 [ZLUDA](https://github.com/lshqqytiger/ZLUDA/releases)(ROCm6版本)并解压到 zluda 文件夹内
   * 复制 zluda 文件夹到系统盘下:比如c盘(C:\zluda)
   * 配置系统环境变量
  
      这里以 windows 10 系统为例:设置 - 系统属性 - 高级系统设置 - 环境变量 - 系统变量 - 找到 path 变量
  
      点击编辑 在最后添加 `C:\zluda``%HIP_PATH_62%bin` 两项
  
   * 替换 CUDA 库的动态链接文件
  
`C:\zluda` 文件夹内的 `cublas64_11.dll` `cusparse64_11.dll``nvrtc64_112_0.dll` 复制出一份到桌面

      按如下规则重命名复制出来的文件
<details>
  <summary><i>启用 AMD(ROCm6)显卡加速步骤</i></summary>

1. 更新显卡驱动至最新版(建议 24.12.1 及以上,下载并安装 [AMD HIP SDK 6.2](https://www.amd.com/en/developer/resources/rocm-hub/hip-sdk.html)  
2. 下载 [ZLUDA](https://github.com/lshqqytiger/ZLUDA/releases)(ROCm6版本)并解压到 zluda 文件夹内,复制 zluda 文件夹到系统盘下:比如c盘(C:\zluda)  
3. 配置系统环境变量,以 windows 10 系统为例:设置 - 系统属性 - 高级系统设置 - 环境变量 - 系统变量 - 找到 path 变量,点击编辑,在最后添加 `C:\zluda``%HIP_PATH_62%bin` 两项  
4. 替换 CUDA 库的动态链接文件:将 `C:\zluda` 文件夹内的 `cublas64_11.dll` `cusparse64_11.dll``nvrtc64_112_0.dll` 复制出一份到桌面,按如下规则重命名复制出来的文件  
```
  `原文件名` → `新文件名`

  `cublas.dll` → `cublas64_11.dll`
@@ -199,9 +191,10 @@ Sugoi 翻译器作者: [mingshiba](https://www.patreon.com/mingshiba)
  `cusparse.dll` → `cusparse64_11.dll`

  `nvrtc.dll` → `nvrtc64_112_0.dll`
    
```
  将已经重命名的文件替换掉 `BallonsTranslator\ballontrans_pylibs_win\Lib\site-packages\torch\lib\` 目录中的同名文件

    * 启动程序并设置 OCR 和文本检测 为 Cuda **(图像修复请继续使用 CPU)**
    * 运行 OCR 并等待 ZLUDA 编译 PTX 文件 **(首次编译大概需要 5-10 分钟,取决于 CPU 性能)**
    * **下次运行无需编译**
5. 启动程序并设置 OCR 和文本检测 为 Cuda **(图像修复请继续使用 CPU)**
6. 运行 OCR 并等待 ZLUDA 编译 PTX 文件 **(首次编译大概需要 5-10 分钟,取决于 CPU 性能)**,**下次运行无需编译**
  
</details>
+0 −1
Original line number Diff line number Diff line
@@ -280,7 +280,6 @@ def main():
    if not args.headless:
        if shared.SCREEN_W > 1707 and sys.platform == 'win32':   # higher than 2560 (1440p) / 1.5
            # https://github.com/dmMaze/BallonsTranslator/issues/220
            print(BT.comicTransSplitter.handleWidth())
            BT.comicTransSplitter.setHandleWidth(7)

        ballontrans.setWindowIcon(QIcon(shared.ICON_PATH))
+5 −2
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ class StrokeItemUndoCommand(QUndoCommand):


class InpaintUndoCommand(QUndoCommand):
    def __init__(self, canvas: Canvas, inpainted: np.ndarray, mask: np.ndarray, inpaint_rect: List[int]):
    def __init__(self, canvas: Canvas, inpainted: np.ndarray, mask: np.ndarray, inpaint_rect: List[int], merge_existing_mask=False):
        super().__init__()
        self.canvas = canvas
        img_array = self.canvas.imgtrans_proj.inpainted_array
@@ -49,6 +49,9 @@ class InpaintUndoCommand(QUndoCommand):
        self.undo_img = np.copy(img_view)
        self.undo_mask = np.copy(mask_view)
        self.redo_img = inpainted
        if merge_existing_mask:
            self.redo_mask = np.bitwise_or(mask, mask_view)
        else:
            self.redo_mask = mask
        self.inpaint_rect = inpaint_rect

+1 −1
Original line number Diff line number Diff line
@@ -800,7 +800,7 @@ class DrawingPanel(Widget):
        ballon_mask = inpaint_dict['ballon_mask']
        if not need_inpaint and pcfg.module.check_need_inpaint:
            img[np.where(ballon_mask > 0)] = bground_bgr
            self.canvas.push_undo_command(InpaintUndoCommand(self.canvas, img, mask, inpaint_dict['inpaint_rect']))
            self.canvas.push_undo_command(InpaintUndoCommand(self.canvas, img, mask, inpaint_dict['inpaint_rect'], merge_existing_mask=True))
            self.clearInpaintItems()
        else:
            self.runInpaint(inpaint_dict=inpaint_dict)
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ if sys.platform == "win32":
    from .windows import WindowsFramelessWindow as FramelessWindow
    from .windows import WindowsWindowEffect as WindowEffect
elif sys.platform == "darwin":
    from .mac import AcrylicWindow
    # from .mac import AcrylicWindow
    from .mac import MacFramelessWindow as FramelessWindow
    from .mac import MacWindowEffect as WindowEffect
else:
Loading