Back to Pdfmathtranslate

README Zh CN

docs/README_zh-CN.md

1.9.1115.2 KB
Original Source
<div align="center">

English | 简体中文 | 繁體中文 | 日本語

<h2 id="title">PDFMathTranslate</h2> <p> <!-- PyPI --> <a href="https://pypi.org/project/pdf2zh/"> </a> <a href="https://pepy.tech/projects/pdf2zh"> </a> <a href="https://hub.docker.com/repository/docker/byaidu/pdf2zh"> </a> <!-- License --> <a href="./LICENSE"> </a> <a href="https://huggingface.co/spaces/reycn/PDFMathTranslate-Docker"> </a> <a href="https://www.modelscope.cn/studios/AI-ModelScope/PDFMathTranslate"> </a> <a href="https://github.com/Byaidu/PDFMathTranslate/pulls"> </a> <a href="https://gitcode.com/Byaidu/PDFMathTranslate/overview"> </a> <a href="https://t.me/+Z9_SgnxmsmA5NzBl"> </a> </p>

<a href="https://trendshift.io/repositories/12424" target="_blank"></a>

</div>

科学 PDF 文档翻译及双语对照工具

欢迎在 GitHub IssuesTelegram 用户群

有关如何贡献的详细信息,请查阅 贡献指南

<h2 id="updates">更新</h2>
  • [2025 年 2 月 22 日] 更好的发布 CI 和精心打包的 windows-amd64 exe (由 @awwaawwa 提供)
  • [2024 年 12 月 24 日] 翻译器现在支持在 Xinference 上使用本地模型 (由 @imClumsyPanda 提供)
  • [2024 年 12 月 19 日] 现在支持非 PDF/A 文档,使用 -cp (由 @reycn 提供)
  • [2024 年 12 月 13 日] 额外支持后端 (由 @YadominJinta 提供)
  • [2024 年 12 月 10 日] 翻译器现在支持 Azure 上的 OpenAI 模型 (由 @yidasanqian 提供)
<h2 id="preview">预览</h2> <div align="center"> </div> <h2 id="demo">在线演示 🌟</h2> <h2 id="demo">在线服务 🌟</h2>

您可以通过以下演示尝试我们的应用程序:

请注意演示的计算资源有限,请避免滥用它们。

<h2 id="install">安装和使用</h2>

方法

针对不同的使用案例,我们提供不同的方法来使用我们的程序:

<details open> <summary>1. UV 安装</summary>
  1. 安装 Python (3.10 <= 版本 <= 3.12)

  2. 安装我们的包:

    bash
    pip install uv
    uv tool install --python 3.12 pdf2zh
    
  3. 执行翻译,文件生成在 当前工作目录

    bash
    pdf2zh document.pdf
    
</details> <details> <summary>2. Windows exe</summary>
  1. 发布页面 下载 pdf2zh-version-win64.zip

  2. 解压缩并双击 pdf2zh.exe 运行。

</details> <details> <summary id="gui">3. 图形用户界面</summary> 1. 安装 Python (3.10 <= 版本 <= 3.12) 2. 安装我们的包:
bash
pip install pdf2zh
  1. 在浏览器中开始使用:

    bash
    pdf2zh -i
    
  2. 如果您的浏览器没有自动启动,请访问

    bash
    http://localhost:7860/
    

有关更多详细信息,请参阅 GUI 文档

</details> <details> <summary id="docker">4. Docker</summary>
  1. 拉取并运行:

    bash
    docker pull byaidu/pdf2zh
    docker run -d -p 7860:7860 byaidu/pdf2zh
    
  2. 在浏览器中打开:

    http://localhost:7860/
    

对于云服务上的 docker 部署:

<div> <a href="https://www.heroku.com/deploy?template=https://github.com/Byaidu/PDFMathTranslate"> </a> <a href="https://render.com/deploy"> </a> <a href="https://zeabur.com/templates/5FQIGX?referralCode=reycn"> </a> <a href="https://template.sealos.io/deploy?templateName=pdf2zh"> </a> <a href="https://app.koyeb.com/deploy?type=git&builder=buildpack&repository=github.com/Byaidu/PDFMathTranslate&branch=main&name=pdf-math-translate"> </a> </div> </details> <details> <summary>5. Zotero 插件</summary>

有关更多细节,请参见 Zotero PDF2zh

</details> <details> <summary>6. 命令行</summary>
  1. 已安装 Python(3.10 <= 版本 <= 3.12)

  2. 安装我们的包:

    bash
    pip install pdf2zh
    
  3. 执行翻译,文件生成在 当前工作目录:

    bash
    pdf2zh document.pdf
    
</details>

[!TIP]

bash
docker pull ghcr.io/byaidu/pdfmathtranslate
docker run -d -p 7860:7860 ghcr.io/byaidu/pdfmathtranslate

无法安装?

当前程序在工作前需要一个 AI 模型 (wybxc/DocLayout-YOLO-DocStructBench-onnx),一些用户由于网络问题无法下载。如果你在下载此模型时遇到问题,我们提供以下环境变量的解决方法:

shell
set HF_ENDPOINT=https://hf-mirror.com

对于 PowerShell 用户:

shell
$env:HF_ENDPOINT = https://hf-mirror.com

如果此解决方案对您无效或您遇到其他问题,请参阅 常见问题解答

<h2 id="usage">高级选项</h2>

在命令行中执行翻译命令,在当前工作目录下生成译文文档 example-mono.pdf 和双语对照文档 example-dual.pdf,默认使用 Google 翻译服务,更多支持的服务在这里)。

在下表中,我们列出了所有高级选项供参考:

选项功能示例
files本地文件pdf2zh ~/local.pdf
links在线文件pdf2zh http://arxiv.org/paper.pdf
-i进入 GUIpdf2zh -i
-p部分文档翻译pdf2zh example.pdf -p 1
-li源语言pdf2zh example.pdf -li en
-lo目标语言pdf2zh example.pdf -lo zh
-s翻译服务pdf2zh example.pdf -s deepl
-t多线程pdf2zh example.pdf -t 1
-o输出目录pdf2zh example.pdf -o output
-f, -c异常pdf2zh example.pdf -f "(MS.*)"
-cp兼容模式pdf2zh example.pdf --compatible
--share公开链接pdf2zh -i --share
--authorized授权pdf2zh -i --authorized users.txt [auth.html]
--prompt自定义提示pdf2zh --prompt [prompt.txt]
--onnx[使用自定义 DocLayout-YOLO ONNX 模型]pdf2zh --onnx [onnx/model/path]
--serverport[使用自定义 WebUI 端口]pdf2zh --serverport 7860
--dir[批量翻译]pdf2zh --dir /path/to/translate/
--config配置文件pdf2zh --config /path/to/config/config.json
--serverport[自定义 gradio 服务器端口]pdf2zh --serverport 7860
--babeldoc使用实验性后端 BabelDOC 翻译pdf2zh --babeldoc -s openai example.pdf

有关详细说明,请参阅我们的文档 高级用法,以获取每个选项的完整列表。

<h2 id="downstream">二次开发 (API)</h2>

当前的 pdf2zh API 暂时已弃用。API 将在 pdf2zh 2.0发布后重新提供。对于需要程序化访问的用户,请使用BabelDOCbabeldoc.high_level.async_translate 函数。

API 暂时弃用意味着:相关代码暂时不会被移除,但不会提供技术支持,也不会修复 bug。

<!-- 对于下游应用程序,请参阅我们的文档 [API 详细信息](./APIS.md),以获取更多信息: - [Python API](./APIS.md#api-python),如何在其他 Python 程序中使用该程序 - [HTTP API](./APIS.md#api-http),如何与已安装该程序的服务器进行通信 --> <h2 id="todo">待办事项</h2>
  • 使用基于 DocLayNet 的模型解析布局,PaddleXPaperMageSAM2

  • 修复页面旋转、目录、列表格式

  • 修复旧论文中的像素公式

  • 异步重试,除了 KeyboardInterrupt

  • 针对西方语言的 Knuth–Plass 算法

  • 支持非 PDF/A 文件

  • ZoteroObsidian 的插件

<h2 id="acknowledgement">致谢</h2> <h2 id="contrib">贡献者</h2> <a href="https://github.com/Byaidu/PDFMathTranslate/graphs/contributors"> </a>

<h2 id="star_hist">星标历史</h2> <a href="https://star-history.com/#Byaidu/PDFMathTranslate&Date"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Byaidu/PDFMathTranslate&type=Date&theme=dark" /> <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Byaidu/PDFMathTranslate&type=Date" /> </picture> </a>