From 6d4ed5863779f0b79a9ee6d50b2fb8331a89e22c Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 22 Jan 2026 16:27:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=20PDFMathTranslate=20?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E4=B8=8B=E8=BC=89=E6=96=B9=E5=BC=8F=EF=BC=8C?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=20snapshot=5Fdownload=20=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E7=A1=AC=E7=B7=A8=E7=A2=BC=E6=AA=94=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 565f043..bda3134 100644 --- a/Dockerfile +++ b/Dockerfile @@ -274,14 +274,21 @@ ENV PATH="/root/.local/bin:${PATH}" # 模型:DocLayout-YOLO ONNX # 來源:HuggingFace - wybxc/DocLayout-YOLO-DocStructBench-onnx # 用途:PDF 頁面佈局分析(識別文字區塊、公式、圖表等) +# 注意:使用 snapshot_download + allow_patterns 避免硬編碼檔名 +# 這樣即使上游改檔名(只要是 .onnx)也不會 build 失敗 # ------------------------------------------------------------------------------ RUN mkdir -p /models/pdfmathtranslate && \ echo "📥 [1/6] 下載 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')" && \ - echo "✅ DocLayout-YOLO ONNX 模型下載完成" + python3 -c "from huggingface_hub import snapshot_download; \ + snapshot_download( \ + repo_id='wybxc/DocLayout-YOLO-DocStructBench-onnx', \ + local_dir='/models/pdfmathtranslate', \ + allow_patterns=['*.onnx'], \ + local_dir_use_symlinks=False \ + )" && \ + echo "✅ DocLayout-YOLO ONNX 模型下載完成" && \ + echo "📋 下載的模型檔案:" && \ + ls -lh /models/pdfmathtranslate/*.onnx 2>/dev/null || ls -lh /models/pdfmathtranslate/ # ------------------------------------------------------------------------------ # 階段 14-B:BabelDOC Warmup(預載入所有資源) @@ -356,11 +363,12 @@ RUN echo "📥 [6/6] 驗證模型並清理快取..." && \ echo "📋 模型檔案驗證:" && \ echo "========================================" && \ echo "🔹 PDFMathTranslate 模型:" && \ - if [ -f "/models/pdfmathtranslate/model.onnx" ]; then \ - echo " ✅ /models/pdfmathtranslate/model.onnx 存在"; \ - ls -lh /models/pdfmathtranslate/model.onnx; \ + ONNX_COUNT=$(find /models/pdfmathtranslate -name "*.onnx" 2>/dev/null | wc -l) && \ + if [ "$ONNX_COUNT" -gt 0 ]; then \ + echo " ✅ 找到 $ONNX_COUNT 個 ONNX 模型:"; \ + ls -lh /models/pdfmathtranslate/*.onnx 2>/dev/null || find /models/pdfmathtranslate -name "*.onnx" -exec ls -lh {} \;; \ else \ - echo " ❌ /models/pdfmathtranslate/model.onnx 不存在"; \ + echo " ❌ /models/pdfmathtranslate 中沒有 ONNX 模型"; \ fi && \ echo "" && \ echo "🔹 PDFMathTranslate 字型:" && \