pz / docs /README_ko-KR.md
github-actions[bot]
GitHub deploy: ec524f8885a8220ac96f04d1c0f21b3e1e69500e
1bf3e6e
# Create new file
<div align="center">
[English](../README.md) | [็ฎ€ไฝ“ไธญๆ–‡](README_zh-CN.md) | [็น้ซ”ไธญๆ–‡](README_zh-TW.md) | [ๆ—ฅๆœฌ่ชž](README_ja-JP.md) | ํ•œ๊ตญ์–ด
<img src="./images/banner.png" width="320px" alt="PDF2ZH"/>
<h2 id="title">PDFMathTranslate</h2>
<p>
<!-- PyPI -->
<a href="https://pypi.org/project/pdf2zh/">
<img src="https://img.shields.io/pypi/v/pdf2zh"/></a>
<a href="https://pepy.tech/projects/pdf2zh">
<img src="https://static.pepy.tech/badge/pdf2zh"></a>
<a href="https://hub.docker.com/repository/docker/byaidu/pdf2zh">
<img src="https://img.shields.io/docker/pulls/byaidu/pdf2zh"></a>
<!-- License -->
<a href="./LICENSE">
<img src="https://img.shields.io/github/license/Byaidu/PDFMathTranslate"/></a>
<a href="https://huggingface.co./spaces/reycn/PDFMathTranslate-Docker">
<img src="https://img.shields.io/badge/%F0%9F%A4%97-Online%20Demo-FF9E0D"/></a>
<a href="https://www.modelscope.cn/studios/AI-ModelScope/PDFMathTranslate">
<img src="https://img.shields.io/badge/ModelScope-Demo-blue"></a>
<a href="https://github.com/Byaidu/PDFMathTranslate/pulls">
<img src="https://img.shields.io/badge/contributions-welcome-green"/></a>
<a href="https://gitcode.com/Byaidu/PDFMathTranslate/overview">
<img src="https://gitcode.com/Byaidu/PDFMathTranslate/star/badge.svg"></a>
<a href="https://t.me/+Z9_SgnxmsmA5NzBl">
<img src="https://img.shields.io/badge/Telegram-2CA5E0?style=flat-squeare&logo=telegram&logoColor=white"/></a>
</p>
<a href="https://trendshift.io/repositories/12424" target="_blank"><img src="https://trendshift.io/api/badge/repositories/12424" alt="Byaidu%2FPDFMathTranslate | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
</div>
๊ณผํ•™ PDF ๋ฌธ์„œ ๋ฒˆ์—ญ ๋ฐ ์ด์ค‘ ์–ธ์–ด ๋น„๊ต ๋„๊ตฌ
- ๐Ÿ“Š ์ˆ˜์‹, ์ฐจํŠธ, ๋ชฉ์ฐจ, ์ฃผ์„ ์œ ์ง€ _([๋ฏธ๋ฆฌ๋ณด๊ธฐ](#preview))_
- ๐ŸŒ [๋‹ค์–‘ํ•œ ์–ธ์–ด](#language)์™€ [๋‹ค์–‘ํ•œ ๋ฒˆ์—ญ ์„œ๋น„์Šค](#services) ์ง€์›
- ๐Ÿค– [์ปค๋งจ๋“œ๋ผ์ธ ๋„๊ตฌ](#usage), [๋Œ€ํ™”ํ˜• ์‚ฌ์šฉ์ž ์ธํ„ฐํŽ˜์ด์Šค](#gui), ๋ฐ [Docker](#docker) ์ œ๊ณต
ํ”ผ๋“œ๋ฐฑ์€ [GitHub Issues](https://github.com/Byaidu/PDFMathTranslate/issues) ๋˜๋Š” [Telegram ๊ทธ๋ฃน](https://t.me/+Z9_SgnxmsmA5NzBl)์—์„œ ํ•ด์ฃผ์„ธ์š”.
<h2 id="updates">์ตœ๊ทผ ์—…๋ฐ์ดํŠธ</h2>
- [2024๋…„ 12์›” 24์ผ] [Xinference](https://github.com/xorbitsai/inference) ์‹คํ–‰ ๋กœ์ปฌ LLM ์ง€์› ์ถ”๊ฐ€ _(by [@imClumsyPanda](https://github.com/imClumsyPanda))_
- [2024๋…„ 11์›” 26์ผ] CLI๊ฐ€ ์˜จ๋ผ์ธ ํŒŒ์ผ์„ ์ง€์›ํ•˜๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค _(by [@reycn](https://github.com/reycn))_
- [2024๋…„ 11์›” 24์ผ] ์˜์กด์„ฑ ํฌ๊ธฐ๋ฅผ ์ค„์ด๊ธฐ ์œ„ํ•ด [ONNX](https://github.com/onnx/onnx) ์ง€์› ์ถ”๊ฐ€ _(by [@Wybxc](https://github.com/Wybxc))_
- [2024๋…„ 11์›” 23์ผ] ๐ŸŒŸ [๋ฌด๋ฃŒ ๊ณต๊ณต ์„œ๋น„์Šค](#demo) ์˜จ๋ผ์ธ! _(by [@Byaidu](https://github.com/Byaidu))_
- [2024๋…„ 11์›” 23์ผ] ์›น ๋ด‡์„ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•œ ๋ฐฉํ™”๋ฒฝ ์ถ”๊ฐ€ _(by [@Byaidu](https://github.com/Byaidu))_
- [2024๋…„ 11์›” 22์ผ] GUI๊ฐ€ ์ดํƒˆ๋ฆฌ์•„์–ด๋ฅผ ์ง€์›ํ•˜๊ณ  ๊ฐœ์„ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค _(by [@Byaidu](https://github.com/Byaidu), [@reycn](https://github.com/reycn))_
- [2024๋…„ 11์›” 22์ผ] ๋ฐฐํฌ๋œ ์„œ๋น„์Šค๋ฅผ ๋‹ค๋ฅธ ์‚ฌ๋žŒ๊ณผ ๊ณต์œ ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค _(by [@Zxis233](https://github.com/Zxis233))_
- [2024๋…„ 11์›” 22์ผ] Tencent ๋ฒˆ์—ญ ์ง€์› _(by [@hellofinch](https://github.com/hellofinch))_
- [2024๋…„ 11์›” 21์ผ] GUI๊ฐ€ ์ด์ค‘ ์–ธ์–ด ๋ฌธ์„œ ๋‹ค์šด๋กœ๋“œ๋ฅผ ์ง€์›ํ•˜๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค _(by [@reycn](https://github.com/reycn))_
- [2024๋…„ 11์›” 20์ผ] ๐ŸŒŸ [๋ฐ๋ชจ](#demo)๊ฐ€ ์˜จ๋ผ์ธ์ด ๋˜์—ˆ์Šต๋‹ˆ๋‹ค! _(by [@reycn](https://github.com/reycn))_
<h2 id="preview">๋ฏธ๋ฆฌ๋ณด๊ธฐ</h2>
<div align="center">
<img src="./images/preview.gif" width="80%"/>
</div>
<h2 id="demo">๊ณต๊ณต ์„œ๋น„์Šค ๐ŸŒŸ</h2>
### ๋ฌด๋ฃŒ ์„œ๋น„์Šค (<https://pdf2zh.com/>)
์„ค์น˜ ์—†์ด [๋ฌด๋ฃŒ ๊ณต๊ณต ์„œ๋น„์Šค](https://pdf2zh.com/)๋ฅผ ์˜จ๋ผ์ธ์œผ๋กœ ์‚ฌ์šฉํ•ด ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
### ๋ฐ๋ชจ
์„ค์น˜ ์—†์ด [HuggingFace์˜ ๋ฐ๋ชจ](https://huggingface.co./spaces/reycn/PDFMathTranslate-Docker)์™€ [ModelScope์˜ ๋ฐ๋ชจ](https://www.modelscope.cn/studios/AI-ModelScope/PDFMathTranslate)๋ฅผ ์‚ฌ์šฉํ•ด ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
๋ฐ๋ชจ์˜ ์ปดํ“จํŒ… ๋ฆฌ์†Œ์Šค๊ฐ€ ์ œํ•œ๋˜์–ด ์žˆ์œผ๋ฏ€๋กœ ๋‚จ์šฉํ•˜์ง€ ๋ง์•„์ฃผ์„ธ์š”.
<h2 id="install">์„ค์น˜ ๋ฐ ์‚ฌ์šฉ๋ฒ•</h2>
์ด ํ”„๋กœ์ ํŠธ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” 4๊ฐ€์ง€ ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค: [์ปค๋งจ๋“œ๋ผ์ธ ๋„๊ตฌ](#cmd), [ํฌํ„ฐ๋ธ”](#portable), [GUI](#gui), ๋ฐ [Docker](#docker).
pdf2zh ์‹คํ–‰์—๋Š” ์ถ”๊ฐ€ ๋ชจ๋ธ(`wybxc/DocLayout-YOLO-DocStructBench-onnx`)์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ชจ๋ธ์€ ModelScope์—์„œ๋„ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์‹œ์ž‘ํ•  ๋•Œ ์ด ๋ชจ๋ธ ๋‹ค์šด๋กœ๋“œ์— ๋ฌธ์ œ๊ฐ€ ์žˆ๋‹ค๋ฉด ๋‹ค์Œ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”:
```shell
set HF_ENDPOINT=https://hf-mirror.com
```
PowerShell ์‚ฌ์šฉ์ž์˜ ๊ฒฝ์šฐ:
```shell
$env:HF_ENDPOINT = https://hf-mirror.com
```
<h3 id="cmd">๋ฐฉ๋ฒ• 1. ์ปค๋งจ๋“œ๋ผ์ธ ๋„๊ตฌ</h3>
1. Python์ด ์„ค์น˜๋˜์–ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค (๋ฒ„์ „ 3.10 <= ๋ฒ„์ „ <= 3.12)
2. ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค:
```bash
pip install pdf2zh
```
3. ๋ฒˆ์—ญ์„ ์‹คํ–‰ํ•˜๊ณ  [ํ˜„์žฌ ์ž‘์—… ๋””๋ ‰ํ† ๋ฆฌ](https://chatgpt.com/share/6745ed36-9acc-800e-8a90-59204bd13444)์— ํŒŒ์ผ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค:
```bash
pdf2zh document.pdf
```
<h3 id="portable">๋ฐฉ๋ฒ• 2. ํฌํ„ฐ๋ธ”</h3>
Python ํ™˜๊ฒฝ์„ ๋ฏธ๋ฆฌ ์„ค์น˜ํ•  ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.
[setup.bat](https://raw.githubusercontent.com/Byaidu/PDFMathTranslate/refs/heads/main/script/setup.bat)์„ ๋‹ค์šด๋กœ๋“œํ•˜๊ณ  ๋”๋ธ”ํด๋ฆญํ•˜์—ฌ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
<h3 id="gui">๋ฐฉ๋ฒ• 3. GUI</h3>
1. Python์ด ์„ค์น˜๋˜์–ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค (๋ฒ„์ „ 3.10 <= ๋ฒ„์ „ <= 3.12)
2. ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค:
```bash
pip install pdf2zh
```
3. ๋ธŒ๋ผ์šฐ์ €์—์„œ ์‚ฌ์šฉ์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค:
```bash
pdf2zh -i
```
4. ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์ž๋™์œผ๋กœ ์‹œ์ž‘๋˜์ง€ ์•Š์œผ๋ฉด ๋‹ค์Œ URL์„ ์—ฝ๋‹ˆ๋‹ค:
```bash
http://localhost:7860/
```
<img src="./images/gui.gif" width="500"/>
์ž์„ธํ•œ ๋‚ด์šฉ์€ [GUI ๋ฌธ์„œ](./README_GUI.md)๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.
<h3 id="docker">๋ฐฉ๋ฒ• 4. Docker</h3>
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">
<img src="https://www.herokucdn.com/deploy/button.svg" alt="Deploy" height="26"></a>
<a href="https://render.com/deploy">
<img src="https://render.com/images/deploy-to-render-button.svg" alt="Deploy to Koyeb" height="26"></a>
<a href="https://zeabur.com/templates/5FQIGX?referralCode=reycn">
<img src="https://zeabur.com/button.svg" alt="Deploy on Zeabur" height="26"></a>
<a href="https://app.koyeb.com/deploy?type=git&builder=buildpack&repository=github.com/Byaidu/PDFMathTranslate&branch=main&name=pdf-math-translate">
<img src="https://www.koyeb.com/static/images/deploy/button.svg" alt="Deploy to Koyeb" height="26"></a>
</div>
<h2 id="usage">๊ณ ๊ธ‰ ์˜ต์…˜</h2>
์ปค๋งจ๋“œ๋ผ์ธ์—์„œ ๋ฒˆ์—ญ ๋ช…๋ น์„ ์‹คํ–‰ํ•˜์—ฌ ํ˜„์žฌ ์ž‘์—… ๋””๋ ‰ํ† ๋ฆฌ์— ๋ฒˆ์—ญ๋œ ๋ฌธ์„œ `example-mono.pdf`์™€ ์ด์ค‘ ์–ธ์–ด ๋ฌธ์„œ `example-dual.pdf`๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ Google ๋ฒˆ์—ญ ์„œ๋น„์Šค๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋” ๋งŽ์€ ์ง€์› ๋ฒˆ์—ญ ์„œ๋น„์Šค๋Š” [์—ฌ๊ธฐ](https://github.com/Byaidu/PDFMathTranslate/blob/main/docs/ADVANCED.md#services)์—์„œ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
<img src="./images/cmd.explained.png" width="580px" alt="cmd"/>
๋‹ค์Œ ํ‘œ์— ์ฐธ๊ณ ์šฉ์œผ๋กœ ๋ชจ๋“  ๊ณ ๊ธ‰ ์˜ต์…˜์„ ๋‚˜์—ดํ–ˆ์Šต๋‹ˆ๋‹ค:
| ์˜ต์…˜ | ๊ธฐ๋Šฅ | ์˜ˆ์‹œ |
| -------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- |
| files | ๋กœ์ปฌ ํŒŒ์ผ | `pdf2zh ~/local.pdf` |
| links | ์˜จ๋ผ์ธ ํŒŒ์ผ | `pdf2zh http://arxiv.org/paper.pdf` |
| `-i` | [GUI ์ง„์ž…](#gui) | `pdf2zh -i` |
| `-p` | [๋ถ€๋ถ„ ๋ฌธ์„œ ๋ฒˆ์—ญ](#partial) | `pdf2zh example.pdf -p 1` |
| `-li` | [์†Œ์Šค ์–ธ์–ด](#languages) | `pdf2zh example.pdf -li en` |
| `-lo` | [๋Œ€์ƒ ์–ธ์–ด](#languages) | `pdf2zh example.pdf -lo zh` |
| `-s` | [๋ฒˆ์—ญ ์„œ๋น„์Šค](#services) | `pdf2zh example.pdf -s deepl` |
| `-t` | [๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ](#threads) | `pdf2zh example.pdf -t 1` |
| `-o` | ์ถœ๋ ฅ ๋””๋ ‰ํ† ๋ฆฌ | `pdf2zh example.pdf -o output` |
| `-f`, `-c` | [์˜ˆ์™ธ](#exceptions) | `pdf2zh example.pdf -f "(MS.*)"` |
| `--share` | [gradio ๊ณต๊ฐœ ๋งํฌ ์–ป๊ธฐ] | `pdf2zh -i --share` |
| `--authorized` | [[์›น ์ธ์ฆ ๋ฐ ์‚ฌ์šฉ์ž ์ •์˜ ์ธ์ฆ ํŽ˜์ด์ง€ ์ถ”๊ฐ€](https://github.com/Byaidu/PDFMathTranslate/blob/main/docs/ADVANCED.)] | `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` | [๊ตฌ์„ฑ ํŒŒ์ผ](https://github.com/Byaidu/PDFMathTranslate/blob/main/docs/ADVANCED.md#cofig) | `pdf2zh --config /path/to/config/config.json` |
<h3 id="partial">์ „์ฒด ๋˜๋Š” ๋ถ€๋ถ„ ๋ฌธ์„œ ๋ฒˆ์—ญ</h3>
- **์ „์ฒด ๋ฒˆ์—ญ**
```bash
pdf2zh example.pdf
```
- **๋ถ€๋ถ„ ๋ฒˆ์—ญ**
```bash
pdf2zh example.pdf -p 1-3,5
```
<h3 id="language">์†Œ์Šค ์–ธ์–ด์™€ ๋Œ€์ƒ ์–ธ์–ด ์ง€์ •</h3>
[Google Languages Codes](https://developers.google.com/admin-sdk/directory/v1/languages), [DeepL Languages Codes](https://developers.deepl.com/docs/resources/supported-languages) ์ฐธ์กฐ
```bash
pdf2zh example.pdf -li en -lo ko
```
<h3 id="services">๋‹ค๋ฅธ ์„œ๋น„์Šค๋กœ ๋ฒˆ์—ญ</h3>
๋‹ค์Œ ํ‘œ๋Š” ๊ฐ ๋ฒˆ์—ญ ์„œ๋น„์Šค์— ํ•„์š”ํ•œ [ํ™˜๊ฒฝ ๋ณ€์ˆ˜](https://chatgpt.com/share/6734a83d-9d48-800e-8a46-f57ca6e8bcb4)๋ฅผ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. ๊ฐ ์„œ๋น„์Šค๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์ „์— ์ด๋Ÿฌํ•œ ๋ณ€์ˆ˜๋ฅผ ์„ค์ •ํ•˜์„ธ์š”.
| **๋ฒˆ์—ญ๊ธฐ** | **์„œ๋น„์Šค** | **ํ™˜๊ฒฝ ๋ณ€์ˆ˜** | **๊ธฐ๋ณธ๊ฐ’** | **์ฐธ๊ณ ** |
| ------------------- | -------------- | --------------------------------------------------------------------- | -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Google (๊ธฐ๋ณธ)** | `google` | ์—†์Œ | N/A | ์—†์Œ |
| **Bing** | `bing` | ์—†์Œ | N/A | ์—†์Œ |
| **DeepL** | `deepl` | `DEEPL_AUTH_KEY` | `[Your Key]` | [DeepL](https://support.deepl.com/hc/en-us/articles/360020695820-API-Key-for-DeepL-s-API) ์ฐธ์กฐ |
| **DeepLX** | `deeplx` | `DEEPLX_ENDPOINT` | `https://api.deepl.com/translate` | [DeepLX](https://github.com/OwO-Network/DeepLX) ์ฐธ์กฐ |
| **Ollama** | `ollama` | `OLLAMA_HOST`, `OLLAMA_MODEL` | `http://127.0.0.1:11434`, `gemma2` | [Ollama](https://github.com/ollama/ollama) ์ฐธ์กฐ |
| **OpenAI** | `openai` | `OPENAI_BASE_URL`, `OPENAI_API_KEY`, `OPENAI_MODEL` | `https://api.openai.com/v1`, `[Your Key]`, `gpt-4o-mini` | [OpenAI](https://platform.openai.com/docs/overview) ์ฐธ์กฐ |
| **AzureOpenAI** | `azure-openai` | `AZURE_OPENAI_BASE_URL`, `AZURE_OPENAI_API_KEY`, `AZURE_OPENAI_MODEL` | `[Your Endpoint]`, `[Your Key]`, `gpt-4o-mini` | [Azure OpenAI](https://learn.microsoft.com/zh-cn/azure/ai-services/openai/chatgpt-quickstart?tabs=command-line%2Cjavascript-keyless%2Ctypescript-keyless%2Cpython&pivots=programming-language-python) ์ฐธ์กฐ |
| **Zhipu** | `zhipu` | `ZHIPU_API_KEY`, `ZHIPU_MODEL` | `[Your Key]`, `glm-4-flash` | [Zhipu](https://open.bigmodel.cn/dev/api/thirdparty-frame/openai-sdk) ์ฐธ์กฐ |
| **ModelScope** | `modelscope` | `MODELSCOPE_API_KEY`, `MODELSCOPE_MODEL` | `[Your Key]`, `Qwen/Qwen2.5-Coder-32B-Instruct` | [ModelScope](https://www.modelscope.cn/docs/model-service/API-Inference/intro) ์ฐธ์กฐ |
| **Silicon** | `silicon` | `SILICON_API_KEY`, `SILICON_MODEL` | `[Your Key]`, `Qwen/Qwen2.5-7B-Instruct` | [SiliconCloud](https://docs.siliconflow.cn/quickstart) ์ฐธ์กฐ |
| **Gemini** | `gemini` | `GEMINI_API_KEY`, `GEMINI_MODEL` | `[Your Key]`, `gemini-1.5-flash` | [Gemini](https://ai.google.dev/gemini-api/docs/openai) ์ฐธ์กฐ |
| **Azure** | `azure` | `AZURE_ENDPOINT`, `AZURE_API_KEY` | `https://api.translator.azure.cn`, `[Your Key]` | [Azure](https://docs.azure.cn/en-us/ai-services/translator/text-translation-overview) ์ฐธ์กฐ |
| **Tencent** | `tencent` | `TENCENTCLOUD_SECRET_ID`, `TENCENTCLOUD_SECRET_KEY` | `[Your ID]`, `[Your Key]` | [Tencent](https://www.tencentcloud.com/products/tmt?from_qcintl=122110104) ์ฐธ์กฐ |
| **Dify** | `dify` | `DIFY_API_URL`, `DIFY_API_KEY` | `[Your DIFY URL]`, `[Your Key]` | [Dify](https://github.com/langgenius/dify) ์ฐธ์กฐ, Dify์˜ ์›Œํฌํ”Œ๋กœ์šฐ ์ž…๋ ฅ์—์„œ lang_out, lang_in, text ์„ธ ๋ณ€์ˆ˜๋ฅผ ์ •์˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. |
| **AnythingLLM** | `anythingllm` | `AnythingLLM_URL`, `AnythingLLM_APIKEY` | `[Your AnythingLLM URL]`, `[Your Key]` | [anything-llm](https://github.com/Mintplex-Labs/anything-llm) ์ฐธ์กฐ |
| **Argos Translate** | `argos` | | | [argos-translate](https://github.com/argosopentech/argos-translate) ์ฐธ์กฐ |
| **Grok** | `grok` | `GORK_API_KEY`, `GORK_MODEL` | `[Your GORK_API_KEY]`, `grok-2-1212` | [Grok](https://docs.x.ai/docs/overview) ์ฐธ์กฐ |
| **DeepSeek** | `deepseek` | `DEEPSEEK_API_KEY`, `DEEPSEEK_MODEL` | `[Your DEEPSEEK_API_KEY]`, `deepseek-chat` | [DeepSeek](https://www.deepseek.com/) ์ฐธ์กฐ |
| **OpenAI-Liked** | `openailiked` | `OPENAILIKED_BASE_URL`, `OPENAILIKED_API_KEY`, `OPENAILIKED_MODEL` | `url`, `[Your Key]`, `model name` | ์—†์Œ |
์œ„ ํ‘œ์— ์—†๋Š” OpenAI API์™€ ํ˜ธํ™˜๋˜๋Š” ๋Œ€ํ˜• ์–ธ์–ด ๋ชจ๋ธ์˜ ๊ฒฝ์šฐ, ํ‘œ์˜ OpenAI์™€ ๋™์ผํ•œ ๋ฐฉ์‹์œผ๋กœ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
`-s service` ๋˜๋Š” `-s service:model`์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฒˆ์—ญ ์„œ๋น„์Šค๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค:
```bash
pdf2zh example.pdf -s openai:gpt-4o-mini
```
๋˜๋Š” ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋กœ ๋ชจ๋ธ์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค:
```bash
set OPENAI_MODEL=gpt-4o-mini
pdf2zh example.pdf -s openai
```
PowerShell ์‚ฌ์šฉ์ž์˜ ๊ฒฝ์šฐ:
```shell
$env:OPENAI_MODEL = gpt-4o-mini
pdf2zh example.pdf -s openai
```
<h3 id="exceptions">์˜ˆ์™ธ ์ง€์ •</h3>
์ •๊ทœ์‹์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ณด์กดํ•ด์•ผ ํ•  ์ˆ˜์‹ ํฐํŠธ์™€ ๋ฌธ์ž๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค:
```bash
pdf2zh example.pdf -f "(CM[^RT].*|MS.*|.*Ital)" -c "(\(|\||\)|\+|=|\d|[\u0080-\ufaff])"
```
๊ธฐ๋ณธ์ ์œผ๋กœ `Latex`, `Mono`, `Code`, `Italic`, `Symbol` ๋ฐ `Math` ํฐํŠธ๋ฅผ ๋ณด์กดํ•ฉ๋‹ˆ๋‹ค:
```bash
pdf2zh example.pdf -f "(CM[^R]|MS.M|XY|MT|BL|RM|EU|LA|RS|LINE|LCIRCLE|TeX-|rsfs|txsy|wasy|stmary|.*Mono|.*Code|.*Ital|.*Sym|.*Math)"
```
<h3 id="threads">์Šค๋ ˆ๋“œ ์ˆ˜ ์ง€์ •</h3>
`-t`๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฒˆ์—ญ์— ์‚ฌ์šฉํ•  ์Šค๋ ˆ๋“œ ์ˆ˜๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค:
```bash
pdf2zh example.pdf -t 1
```
<h3 id="prompt">์‚ฌ์šฉ์ž ์ •์˜ ํ”„๋กฌํ”„ํŠธ</h3>
`--prompt`๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ LLM์—์„œ ์‚ฌ์šฉํ•  ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค:
```bash
pdf2zh example.pdf -pr prompt.txt
```
`prompt.txt` ์˜ˆ์‹œ:
```txt
[
{
"role": "system",
"content": "You are a professional,authentic machine translation engine.",
},
{
"role": "user",
"content": "Translate the following markdown source text to ${lang_out}. Keep the formula notation {{v*}} unchanged. Output translation directly without any additional text.\nSource Text: ${text}\nTranslated Text:",
},
]
```
์‚ฌ์šฉ์ž ์ •์˜ ํ”„๋กฌํ”„ํŠธ ํŒŒ์ผ์—์„œ๋Š” ๋‹ค์Œ ์„ธ ๊ฐ€์ง€ ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
| **๋ณ€์ˆ˜** | **๋‚ด์šฉ** |
| ---------- | ------------- |
| `lang_in` | ์†Œ์Šค ์–ธ์–ด |
| `lang_out` | ๋Œ€์ƒ ์–ธ์–ด |
| `text` | ๋ฒˆ์—ญํ•  ํ…์ŠคํŠธ |
<h2 id="todo">API</h2>
### Python
```python
from pdf2zh import translate, translate_stream
params = {"lang_in": "en", "lang_out": "ko", "service": "google", "thread": 4}
file_mono, file_dual = translate(files=["example.pdf"], **params)[0]
with open("example.pdf", "rb") as f:
stream_mono, stream_dual = translate_stream(stream=f.read(), **params)
```
### HTTP
```bash
pip install pdf2zh[backend]
pdf2zh --flask
pdf2zh --celery worker
```
```bash
curl http://localhost:11008/v1/translate -F "[email protected]" -F "data={\"lang_in\":\"en\",\"lang_out\":\"ko\",\"service\":\"google\",\"thread\":4}"
{"id":"d9894125-2f4e-45ea-9d93-1a9068d2045a"}
curl http://localhost:11008/v1/translate/d9894125-2f4e-45ea-9d93-1a9068d2045a
{"info":{"n":13,"total":506},"state":"PROGRESS"}
curl http://localhost:11008/v1/translate/d9894125-2f4e-45ea-9d93-1a9068d2045a
{"state":"SUCCESS"}
curl http://localhost:11008/v1/translate/d9894125-2f4e-45ea-9d93-1a9068d2045a/mono --output example-mono.pdf
curl http://localhost:11008/v1/translate/d9894125-2f4e-45ea-9d93-1a9068d2045a/dual --output example-dual.pdf
curl http://localhost:11008/v1/translate/d9894125-2f4e-45ea-9d93-1a9068d2045a -X DELETE
```
<h2 id="acknowledgement">๊ฐ์‚ฌ์˜ ๋ง</h2>
- ๋ฌธ์„œ ๋ณ‘ํ•ฉ: [PyMuPDF](https://github.com/pymupdf/PyMuPDF)
- ๋ฌธ์„œ ํŒŒ์‹ฑ: [Pdfminer.six](https://github.com/pdfminer/pdfminer.six)
- ๋ฌธ์„œ ์ถ”์ถœ: [MinerU](https://github.com/opendatalab/MinerU)
- ๋ฌธ์„œ ๋ฏธ๋ฆฌ๋ณด๊ธฐ: [Gradio PDF](https://github.com/freddyaboulton/gradio-pdf)
- ๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ๋ฒˆ์—ญ: [MathTranslate](https://github.com/SUSYUSTC/MathTranslate)
- ๋ ˆ์ด์•„์›ƒ ํŒŒ์‹ฑ: [DocLayout-YOLO](https://github.com/opendatalab/DocLayout-YOLO)
- ๋ฌธ์„œ ํ‘œ์ค€: [PDF Explained](https://zxyle.github.io/PDF-Explained/), [PDF Cheat Sheets](https://pdfa.org/resource/pdf-cheat-sheets/)
- ๋‹ค๊ตญ์–ด ํฐํŠธ: [Go Noto Universal](https://github.com/satbyy/go-noto-universal)
<h2 id="contrib">๊ธฐ์—ฌ์ž</h2>
<a href="https://github.com/Byaidu/PDFMathTranslate/graphs/contributors">
<img src="https://opencollective.com/PDFMathTranslate/contributors.svg?width=890&button=false" />
</a>
![Alt](https://repobeats.axiom.co/api/embed/dfa7583da5332a11468d686fbd29b92320a6a869.svg "Repobeats analytics image")
<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" />
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Byaidu/PDFMathTranslate&type=Date"/>
</picture>
</a>