Create new file
๊ณผํ PDF ๋ฌธ์ ๋ฒ์ญ ๋ฐ ์ด์ค ์ธ์ด ๋น๊ต ๋๊ตฌ
- ๐ ์์, ์ฐจํธ, ๋ชฉ์ฐจ, ์ฃผ์ ์ ์ง (๋ฏธ๋ฆฌ๋ณด๊ธฐ)
- ๐ ๋ค์ํ ์ธ์ด์ ๋ค์ํ ๋ฒ์ญ ์๋น์ค ์ง์
- ๐ค ์ปค๋งจ๋๋ผ์ธ ๋๊ตฌ, ๋ํํ ์ฌ์ฉ์ ์ธํฐํ์ด์ค, ๋ฐ Docker ์ ๊ณต
ํผ๋๋ฐฑ์ GitHub Issues ๋๋ Telegram ๊ทธ๋ฃน์์ ํด์ฃผ์ธ์.
์ต๊ทผ ์ ๋ฐ์ดํธ
- [2024๋ 12์ 24์ผ] Xinference ์คํ ๋ก์ปฌ LLM ์ง์ ์ถ๊ฐ (by @imClumsyPanda)
- [2024๋ 11์ 26์ผ] CLI๊ฐ ์จ๋ผ์ธ ํ์ผ์ ์ง์ํ๊ฒ ๋์์ต๋๋ค (by @reycn)
- [2024๋ 11์ 24์ผ] ์์กด์ฑ ํฌ๊ธฐ๋ฅผ ์ค์ด๊ธฐ ์ํด ONNX ์ง์ ์ถ๊ฐ (by @Wybxc)
- [2024๋ 11์ 23์ผ] ๐ ๋ฌด๋ฃ ๊ณต๊ณต ์๋น์ค ์จ๋ผ์ธ! (by @Byaidu)
- [2024๋ 11์ 23์ผ] ์น ๋ด์ ๋ฐฉ์งํ๊ธฐ ์ํ ๋ฐฉํ๋ฒฝ ์ถ๊ฐ (by @Byaidu)
- [2024๋ 11์ 22์ผ] GUI๊ฐ ์ดํ๋ฆฌ์์ด๋ฅผ ์ง์ํ๊ณ ๊ฐ์ ๋์์ต๋๋ค (by @Byaidu, @reycn)
- [2024๋ 11์ 22์ผ] ๋ฐฐํฌ๋ ์๋น์ค๋ฅผ ๋ค๋ฅธ ์ฌ๋๊ณผ ๊ณต์ ํ ์ ์๊ฒ ๋์์ต๋๋ค (by @Zxis233)
- [2024๋ 11์ 22์ผ] Tencent ๋ฒ์ญ ์ง์ (by @hellofinch)
- [2024๋ 11์ 21์ผ] GUI๊ฐ ์ด์ค ์ธ์ด ๋ฌธ์ ๋ค์ด๋ก๋๋ฅผ ์ง์ํ๊ฒ ๋์์ต๋๋ค (by @reycn)
- [2024๋ 11์ 20์ผ] ๐ ๋ฐ๋ชจ๊ฐ ์จ๋ผ์ธ์ด ๋์์ต๋๋ค! (by @reycn)
๋ฏธ๋ฆฌ๋ณด๊ธฐ

๊ณต๊ณต ์๋น์ค ๐
๋ฌด๋ฃ ์๋น์ค (https://pdf2zh.com/)
์ค์น ์์ด ๋ฌด๋ฃ ๊ณต๊ณต ์๋น์ค๋ฅผ ์จ๋ผ์ธ์ผ๋ก ์ฌ์ฉํด ๋ณผ ์ ์์ต๋๋ค.
๋ฐ๋ชจ
์ค์น ์์ด HuggingFace์ ๋ฐ๋ชจ์ ModelScope์ ๋ฐ๋ชจ๋ฅผ ์ฌ์ฉํด ๋ณผ ์ ์์ต๋๋ค. ๋ฐ๋ชจ์ ์ปดํจํ ๋ฆฌ์์ค๊ฐ ์ ํ๋์ด ์์ผ๋ฏ๋ก ๋จ์ฉํ์ง ๋ง์์ฃผ์ธ์.
์ค์น ๋ฐ ์ฌ์ฉ๋ฒ
์ด ํ๋ก์ ํธ๋ฅผ ์ฌ์ฉํ๋ 4๊ฐ์ง ๋ฐฉ๋ฒ์ ์ ๊ณตํฉ๋๋ค: ์ปค๋งจ๋๋ผ์ธ ๋๊ตฌ, ํฌํฐ๋ธ, GUI, ๋ฐ Docker.
pdf2zh ์คํ์๋ ์ถ๊ฐ ๋ชจ๋ธ(wybxc/DocLayout-YOLO-DocStructBench-onnx
)์ด ํ์ํฉ๋๋ค. ์ด ๋ชจ๋ธ์ ModelScope์์๋ ์ฐพ์ ์ ์์ต๋๋ค. ์์ํ ๋ ์ด ๋ชจ๋ธ ๋ค์ด๋ก๋์ ๋ฌธ์ ๊ฐ ์๋ค๋ฉด ๋ค์ ํ๊ฒฝ ๋ณ์๋ฅผ ์ฌ์ฉํ์ธ์:
set HF_ENDPOINT=https://hf-mirror.com
PowerShell ์ฌ์ฉ์์ ๊ฒฝ์ฐ:
$env:HF_ENDPOINT = https://hf-mirror.com
๋ฐฉ๋ฒ 1. ์ปค๋งจ๋๋ผ์ธ ๋๊ตฌ
Python์ด ์ค์น๋์ด ์์ด์ผ ํฉ๋๋ค (๋ฒ์ 3.10 <= ๋ฒ์ <= 3.12)
ํจํค์ง๋ฅผ ์ค์นํฉ๋๋ค:
pip install pdf2zh
๋ฒ์ญ์ ์คํํ๊ณ ํ์ฌ ์์ ๋๋ ํ ๋ฆฌ์ ํ์ผ์ ์์ฑํฉ๋๋ค:
pdf2zh document.pdf
๋ฐฉ๋ฒ 2. ํฌํฐ๋ธ
Python ํ๊ฒฝ์ ๋ฏธ๋ฆฌ ์ค์นํ ํ์๊ฐ ์์ต๋๋ค.
setup.bat์ ๋ค์ด๋ก๋ํ๊ณ ๋๋ธํด๋ฆญํ์ฌ ์คํํฉ๋๋ค.
๋ฐฉ๋ฒ 3. GUI
Python์ด ์ค์น๋์ด ์์ด์ผ ํฉ๋๋ค (๋ฒ์ 3.10 <= ๋ฒ์ <= 3.12)
ํจํค์ง๋ฅผ ์ค์นํฉ๋๋ค:
pip install pdf2zh
๋ธ๋ผ์ฐ์ ์์ ์ฌ์ฉ์ ์์ํฉ๋๋ค:
pdf2zh -i
๋ธ๋ผ์ฐ์ ๊ฐ ์๋์ผ๋ก ์์๋์ง ์์ผ๋ฉด ๋ค์ URL์ ์ฝ๋๋ค:
http://localhost:7860/
์์ธํ ๋ด์ฉ์ GUI ๋ฌธ์๋ฅผ ์ฐธ์กฐํ์ธ์.
๋ฐฉ๋ฒ 4. Docker
ํํ๊ณ ์คํํฉ๋๋ค:
docker pull byaidu/pdf2zh docker run -d -p 7860:7860 byaidu/pdf2zh
๋ธ๋ผ์ฐ์ ์์ ์ฝ๋๋ค:
http://localhost:7860/
ํด๋ผ์ฐ๋ ์๋น์ค์์ Docker ๋ฐฐํฌ์ฉ:
๊ณ ๊ธ ์ต์
์ปค๋งจ๋๋ผ์ธ์์ ๋ฒ์ญ ๋ช
๋ น์ ์คํํ์ฌ ํ์ฌ ์์
๋๋ ํ ๋ฆฌ์ ๋ฒ์ญ๋ ๋ฌธ์ example-mono.pdf
์ ์ด์ค ์ธ์ด ๋ฌธ์ example-dual.pdf
๋ฅผ ์์ฑํฉ๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก Google ๋ฒ์ญ ์๋น์ค๋ฅผ ์ฌ์ฉํฉ๋๋ค. ๋ ๋ง์ ์ง์ ๋ฒ์ญ ์๋น์ค๋ ์ฌ๊ธฐ์์ ์ฐพ์ ์ ์์ต๋๋ค.

๋ค์ ํ์ ์ฐธ๊ณ ์ฉ์ผ๋ก ๋ชจ๋ ๊ณ ๊ธ ์ต์ ์ ๋์ดํ์ต๋๋ค:
์ต์ | ๊ธฐ๋ฅ | ์์ |
---|---|---|
files | ๋ก์ปฌ ํ์ผ | pdf2zh ~/local.pdf |
links | ์จ๋ผ์ธ ํ์ผ | pdf2zh http://arxiv.org/paper.pdf |
-i |
GUI ์ง์ | pdf2zh -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.*)" |
--share |
[gradio ๊ณต๊ฐ ๋งํฌ ์ป๊ธฐ] | 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 |
์ ์ฒด ๋๋ ๋ถ๋ถ ๋ฌธ์ ๋ฒ์ญ
- ์ ์ฒด ๋ฒ์ญ
pdf2zh example.pdf
- ๋ถ๋ถ ๋ฒ์ญ
pdf2zh example.pdf -p 1-3,5
์์ค ์ธ์ด์ ๋์ ์ธ์ด ์ง์
Google Languages Codes, DeepL Languages Codes ์ฐธ์กฐ
pdf2zh example.pdf -li en -lo ko
๋ค๋ฅธ ์๋น์ค๋ก ๋ฒ์ญ
๋ค์ ํ๋ ๊ฐ ๋ฒ์ญ ์๋น์ค์ ํ์ํ ํ๊ฒฝ ๋ณ์๋ฅผ ๋ณด์ฌ์ค๋๋ค. ๊ฐ ์๋น์ค๋ฅผ ์ฌ์ฉํ๊ธฐ ์ ์ ์ด๋ฌํ ๋ณ์๋ฅผ ์ค์ ํ์ธ์.
๋ฒ์ญ๊ธฐ | ์๋น์ค | ํ๊ฒฝ ๋ณ์ | ๊ธฐ๋ณธ๊ฐ | ์ฐธ๊ณ |
---|---|---|---|---|
Google (๊ธฐ๋ณธ) | google |
์์ | N/A | ์์ |
Bing | bing |
์์ | N/A | ์์ |
DeepL | deepl |
DEEPL_AUTH_KEY |
[Your Key] |
DeepL ์ฐธ์กฐ |
DeepLX | deeplx |
DEEPLX_ENDPOINT |
https://api.deepl.com/translate |
DeepLX ์ฐธ์กฐ |
Ollama | ollama |
OLLAMA_HOST , OLLAMA_MODEL |
http://127.0.0.1:11434 , gemma2 |
Ollama ์ฐธ์กฐ |
OpenAI | openai |
OPENAI_BASE_URL , OPENAI_API_KEY , OPENAI_MODEL |
https://api.openai.com/v1 , [Your Key] , gpt-4o-mini |
OpenAI ์ฐธ์กฐ |
AzureOpenAI | azure-openai |
AZURE_OPENAI_BASE_URL , AZURE_OPENAI_API_KEY , AZURE_OPENAI_MODEL |
[Your Endpoint] , [Your Key] , gpt-4o-mini |
Azure OpenAI ์ฐธ์กฐ |
Zhipu | zhipu |
ZHIPU_API_KEY , ZHIPU_MODEL |
[Your Key] , glm-4-flash |
Zhipu ์ฐธ์กฐ |
ModelScope | modelscope |
MODELSCOPE_API_KEY , MODELSCOPE_MODEL |
[Your Key] , Qwen/Qwen2.5-Coder-32B-Instruct |
ModelScope ์ฐธ์กฐ |
Silicon | silicon |
SILICON_API_KEY , SILICON_MODEL |
[Your Key] , Qwen/Qwen2.5-7B-Instruct |
SiliconCloud ์ฐธ์กฐ |
Gemini | gemini |
GEMINI_API_KEY , GEMINI_MODEL |
[Your Key] , gemini-1.5-flash |
Gemini ์ฐธ์กฐ |
Azure | azure |
AZURE_ENDPOINT , AZURE_API_KEY |
https://api.translator.azure.cn , [Your Key] |
Azure ์ฐธ์กฐ |
Tencent | tencent |
TENCENTCLOUD_SECRET_ID , TENCENTCLOUD_SECRET_KEY |
[Your ID] , [Your Key] |
Tencent ์ฐธ์กฐ |
Dify | dify |
DIFY_API_URL , DIFY_API_KEY |
[Your DIFY URL] , [Your Key] |
Dify ์ฐธ์กฐ, Dify์ ์ํฌํ๋ก์ฐ ์ ๋ ฅ์์ lang_out, lang_in, text ์ธ ๋ณ์๋ฅผ ์ ์ํด์ผ ํฉ๋๋ค. |
AnythingLLM | anythingllm |
AnythingLLM_URL , AnythingLLM_APIKEY |
[Your AnythingLLM URL] , [Your Key] |
anything-llm ์ฐธ์กฐ |
Argos Translate | argos |
argos-translate ์ฐธ์กฐ | ||
Grok | grok |
GORK_API_KEY , GORK_MODEL |
[Your GORK_API_KEY] , grok-2-1212 |
Grok ์ฐธ์กฐ |
DeepSeek | deepseek |
DEEPSEEK_API_KEY , DEEPSEEK_MODEL |
[Your DEEPSEEK_API_KEY] , deepseek-chat |
DeepSeek ์ฐธ์กฐ |
OpenAI-Liked | openailiked |
OPENAILIKED_BASE_URL , OPENAILIKED_API_KEY , OPENAILIKED_MODEL |
url , [Your Key] , model name |
์์ |
์ ํ์ ์๋ OpenAI API์ ํธํ๋๋ ๋ํ ์ธ์ด ๋ชจ๋ธ์ ๊ฒฝ์ฐ, ํ์ OpenAI์ ๋์ผํ ๋ฐฉ์์ผ๋ก ํ๊ฒฝ ๋ณ์๋ฅผ ์ค์ ํ ์ ์์ต๋๋ค.
-s service
๋๋ -s service:model
์ ์ฌ์ฉํ์ฌ ๋ฒ์ญ ์๋น์ค๋ฅผ ์ง์ ํฉ๋๋ค:
pdf2zh example.pdf -s openai:gpt-4o-mini
๋๋ ํ๊ฒฝ ๋ณ์๋ก ๋ชจ๋ธ์ ์ง์ ํฉ๋๋ค:
set OPENAI_MODEL=gpt-4o-mini
pdf2zh example.pdf -s openai
PowerShell ์ฌ์ฉ์์ ๊ฒฝ์ฐ:
$env:OPENAI_MODEL = gpt-4o-mini
pdf2zh example.pdf -s openai
์์ธ ์ง์
์ ๊ท์์ ์ฌ์ฉํ์ฌ ๋ณด์กดํด์ผ ํ ์์ ํฐํธ์ ๋ฌธ์๋ฅผ ์ง์ ํฉ๋๋ค:
pdf2zh example.pdf -f "(CM[^RT].*|MS.*|.*Ital)" -c "(\(|\||\)|\+|=|\d|[\u0080-\ufaff])"
๊ธฐ๋ณธ์ ์ผ๋ก Latex
, Mono
, Code
, Italic
, Symbol
๋ฐ Math
ํฐํธ๋ฅผ ๋ณด์กดํฉ๋๋ค:
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)"
์ค๋ ๋ ์ ์ง์
-t
๋ฅผ ์ฌ์ฉํ์ฌ ๋ฒ์ญ์ ์ฌ์ฉํ ์ค๋ ๋ ์๋ฅผ ์ง์ ํฉ๋๋ค:
pdf2zh example.pdf -t 1
์ฌ์ฉ์ ์ ์ ํ๋กฌํํธ
--prompt
๋ฅผ ์ฌ์ฉํ์ฌ LLM์์ ์ฌ์ฉํ ํ๋กฌํํธ๋ฅผ ์ง์ ํฉ๋๋ค:
pdf2zh example.pdf -pr prompt.txt
prompt.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 |
๋ฒ์ญํ ํ ์คํธ |
API
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
pip install pdf2zh[backend]
pdf2zh --flask
pdf2zh --celery worker
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
๊ฐ์ฌ์ ๋ง
- ๋ฌธ์ ๋ณํฉ: PyMuPDF
- ๋ฌธ์ ํ์ฑ: Pdfminer.six
- ๋ฌธ์ ์ถ์ถ: MinerU
- ๋ฌธ์ ๋ฏธ๋ฆฌ๋ณด๊ธฐ: Gradio PDF
- ๋ฉํฐ์ค๋ ๋ ๋ฒ์ญ: MathTranslate
- ๋ ์ด์์ ํ์ฑ: DocLayout-YOLO
- ๋ฌธ์ ํ์ค: PDF Explained, PDF Cheat Sheets
- ๋ค๊ตญ์ด ํฐํธ: Go Noto Universal