Skip to content

Commit

Permalink
调整docker构建顺序,先下模型后装包,并将预热更改为dockerfile RUN指令
Browse files Browse the repository at this point in the history
  • Loading branch information
awwaawwa committed Dec 18, 2024
1 parent d6c37bc commit c616832
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim

WORKDIR /app

COPY . .

EXPOSE 7860

ENV PYTHONUNBUFFERED=1
ADD "https://github.com/satbyy/go-noto-universal/releases/download/v7.0/GoNotoKurrent-Regular.ttf" /app
RUN apt-get update && \
apt-get install --no-install-recommends -y libgl1 && \
rm -rf /var/lib/apt/lists/*
rm -rf /var/lib/apt/lists/* && uv pip install --system --no-cache huggingface-hub && \
python3 -c "from huggingface_hub import hf_hub_download; hf_hub_download('wybxc/DocLayout-YOLO-DocStructBench-onnx','doclayout_yolo_docstructbench_imgsz1024.onnx');"

COPY . .

RUN uv pip install --system --no-cache . && uv run pdf2zh/warmup.py
RUN uv pip install --system --no-cache .

CMD ["pdf2zh", "-i"]
7 changes: 1 addition & 6 deletions pdf2zh/doclayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,7 @@ def from_pretrained(repo_id: str, filename: str):
model_dir = snapshot_download(repo_mapping[repo_id])
pth = os.path.join(model_dir, filename)
else:
try:
pth = hf_hub_download(repo_id=repo_id, filename=filename, etag_timeout=1, local_files_only=True)
print("Using local DocLayout-YOLO-DocStructBench-onnx file", pth)
except huggingface_hub.utils.LocalEntryNotFoundError:
print("Downloading DocLayout-YOLO-DocStructBench-onnx from Huggingface Hub...")
pth = hf_hub_download(repo_id=repo_id, filename=filename, etag_timeout=1)
pth = hf_hub_download(repo_id=repo_id, filename=filename, etag_timeout=1)
return OnnxModel(pth)

@property
Expand Down
10 changes: 0 additions & 10 deletions pdf2zh/warmup.py

This file was deleted.

0 comments on commit c616832

Please sign in to comment.