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 && \ RUN mkdir -p /models/pdfmathtranslate && \
# 預先下載 DocLayout-YOLO ONNX 模型 # 預先下載 DocLayout-YOLO ONNX 模型
python3 -c "from huggingface_hub import hf_hub_download; \ python3 -c "from huggingface_hub import hf_hub_download; \
hf_hub_download(repo_id='wybxc/DocLayout-YOLO-DocStructBench-onnx', \ hf_hub_download(repo_id='wybxc/DocLayout-YOLO-DocStructBench-onnx', \
filename='model.onnx', \ filename='model.onnx', \
local_dir='/models/pdfmathtranslate')" && \ local_dir='/models/pdfmathtranslate')" && \
# 執行 babeldoc warmup 預載入模型 # 執行 babeldoc warmup 預載入模型
babeldoc --warmup || true && \ babeldoc --warmup || true && \
# 清理 cache # 清理 cache
@ -185,15 +185,15 @@ RUN mkdir -p /models/pdfmathtranslate && \
# 下載 PDFMathTranslate 所需字型 # 下載 PDFMathTranslate 所需字型
RUN mkdir -p /app && \ RUN mkdir -p /app && \
curl -L -o /app/GoNotoKurrent-Regular.ttf \ 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 \ 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 \ 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 \ 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 \ 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 環境變數 # PDFMathTranslate 環境變數
ENV PDFMATHTRANSLATE_MODELS_PATH="/models/pdfmathtranslate" ENV PDFMATHTRANSLATE_MODELS_PATH="/models/pdfmathtranslate"

View file

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