feat: 更新 Dockerfile 以預先下載 PDFMathTranslate 所需模型及字型

This commit is contained in:
Your Name 2026-01-21 14:31:28 +08:00
parent d943771f36
commit 1f850dd926
2 changed files with 23 additions and 22 deletions

View file

@ -174,9 +174,9 @@ ENV PATH="/root/.local/bin:${PATH}"
RUN mkdir -p /models/pdfmathtranslate && \
# 預先下載 DocLayout-YOLO ONNX 模型
python3 -c "from huggingface_hub import hf_hub_download; \
hf_hub_download(repo_id='wybxc/DocLayout-YOLO-DocStructBench-onnx', \
filename='model.onnx', \
local_dir='/models/pdfmathtranslate')" && \
hf_hub_download(repo_id='wybxc/DocLayout-YOLO-DocStructBench-onnx', \
filename='model.onnx', \
local_dir='/models/pdfmathtranslate')" && \
# 執行 babeldoc warmup 預載入模型
babeldoc --warmup || true && \
# 清理 cache
@ -185,15 +185,15 @@ RUN mkdir -p /models/pdfmathtranslate && \
# 下載 PDFMathTranslate 所需字型
RUN mkdir -p /app && \
curl -L -o /app/GoNotoKurrent-Regular.ttf \
"https://github.com/satbyy/go-noto-universal/releases/download/v7.0/GoNotoKurrent-Regular.ttf" && \
"https://github.com/satbyy/go-noto-universal/releases/download/v7.0/GoNotoKurrent-Regular.ttf" && \
curl -L -o /app/SourceHanSerifCN-Regular.ttf \
"https://github.com/timelic/source-han-serif/releases/download/main/SourceHanSerifCN-Regular.ttf" && \
"https://github.com/timelic/source-han-serif/releases/download/main/SourceHanSerifCN-Regular.ttf" && \
curl -L -o /app/SourceHanSerifTW-Regular.ttf \
"https://github.com/timelic/source-han-serif/releases/download/main/SourceHanSerifTW-Regular.ttf" && \
"https://github.com/timelic/source-han-serif/releases/download/main/SourceHanSerifTW-Regular.ttf" && \
curl -L -o /app/SourceHanSerifJP-Regular.ttf \
"https://github.com/timelic/source-han-serif/releases/download/main/SourceHanSerifJP-Regular.ttf" && \
"https://github.com/timelic/source-han-serif/releases/download/main/SourceHanSerifJP-Regular.ttf" && \
curl -L -o /app/SourceHanSerifKR-Regular.ttf \
"https://github.com/timelic/source-han-serif/releases/download/main/SourceHanSerifKR-Regular.ttf"
"https://github.com/timelic/source-han-serif/releases/download/main/SourceHanSerifKR-Regular.ttf"
# PDFMathTranslate 環境變數
ENV PDFMATHTRANSLATE_MODELS_PATH="/models/pdfmathtranslate"

View file

@ -157,16 +157,16 @@ docker compose up -d
## 支援格式
| 轉換器 | 用途 | 格式數 |
| ---------------- | ------------ | ------ |
| FFmpeg | 影音 | 400+ |
| ImageMagick | 圖片 | 200+ |
| LibreOffice | 文件 | 60+ |
| Pandoc | 文件 | 100+ |
| Calibre | 電子書 | 40+ |
| Inkscape | 向量圖 | 20+ |
| MinerU | 文件→MD | 2 |
| PDFMathTranslate | PDF 翻譯 | 15+ |
| 轉換器 | 用途 | 格式數 |
| ---------------- | -------- | ------ |
| FFmpeg | 影音 | 400+ |
| ImageMagick | 圖片 | 200+ |
| LibreOffice | 文件 | 60+ |
| Pandoc | 文件 | 100+ |
| Calibre | 電子書 | 40+ |
| Inkscape | 向量圖 | 20+ |
| MinerU | 文件→MD | 2 |
| PDFMathTranslate | PDF 翻譯 | 15+ |
完整列表 → [docs/converters.md](docs/converters.md)
@ -196,6 +196,7 @@ PDFMathTranslate 是一個內容轉換引擎,用於翻譯 PDF 文件同時保
### 輸出格式
所有輸出一律打包為 `.tar` 檔案,包含:
- `original.pdf` — 原始 PDF 文件
- `translated-<lang>.pdf` — 翻譯後的 PDF 文件
@ -215,10 +216,10 @@ PDFMathTranslate
### 環境變數
| 變數 | 說明 | 預設值 |
| --------------------------- | -------------------------- | ------- |
| `PDFMATHTRANSLATE_SERVICE` | 翻譯服務提供商 | google |
| `PDFMATHTRANSLATE_MODELS_PATH` | 模型路徑 | /models/pdfmathtranslate |
| 變數 | 說明 | 預設值 |
| ------------------------------ | -------------- | ------------------------ |
| `PDFMATHTRANSLATE_SERVICE` | 翻譯服務提供商 | google |
| `PDFMATHTRANSLATE_MODELS_PATH` | 模型路徑 | /models/pdfmathtranslate |
### 注意事項