kuzushiji-ocr / Dockerfile.ndlkotenocr
yuukicammy's picture
Refactor and enhance OCR application with new models and Docker configurations. Added support for NDL古典籍OCR and GLM-OCR, updated Dockerfile for improved environment setup, and removed PaddleOCR app. Updated documentation for deployment and usage instructions.
5e633f3
Raw
History Blame Contribute Delete
1.93 kB
# NDL古典籍OCR (ndlkotenocr_cli) — Modal 用ビルド
# 元: https://github.com/ndl-lab/ndlkotenocr_cli/blob/master/docker/Dockerfile
# COPY の代わりにリポジトリを clone し、ビルドコンテキスト不要で再現可能にする
FROM nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04
ENV PROJECT_DIR=/root/kotenocr_cli
ENV FORCE_CUDA="1"
ENV TORCH_CUDA_ARCH_LIST="7.5+PTX"
ENV TORCH_NVCC_FLAGS="-Xfatbin -compress-all"
ENV DEBIAN_FRONTEND=noninteractive
RUN set -x \
&& apt update \
&& apt upgrade -y
RUN set -x \
&& apt update \
&& apt -y install locales \
&& locale-gen ja_JP.UTF-8
ENV LANG ja_JP.UTF-8
ENV LANGUAGE ja_JP:ja
ENV LC_ALL ja_JP.UTF-8
RUN localedef -f UTF-8 -i ja_JP ja_JP.utf8
# Modal の関数ランタイムは PATH 上の `python` と `pip` を検出する(python3 / pip3 のみだと失敗する)
RUN set -x && apt -y install libgl1-mesa-dev libglib2.0-0 zip git python3-pip wget python-is-python3 \
&& ln -sf /usr/bin/pip3 /usr/bin/pip
ARG NDLKOTEN_BRANCH=master
RUN set -x && git clone --depth 1 --branch "${NDLKOTEN_BRANCH}" \
https://github.com/ndl-lab/ndlkotenocr_cli.git "${PROJECT_DIR}"
RUN set -x && pip3 install --no-cache-dir torch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 torchtext==0.16.1 --index-url https://download.pytorch.org/whl/cu121
RUN set -x \
&& pip3 install --no-cache-dir -r ${PROJECT_DIR}/requirements.txt
RUN set -x && wget -nc https://lab.ndl.go.jp/dataset/ndlkotensekiocr/trocr/model-ver2.zip -P ${PROJECT_DIR}/src/text_kotenseki_recognition/
RUN set -x && wget -nc https://lab.ndl.go.jp/dataset/ndlkotensekiocr/layoutmodel/ndl_kotenseki_layout_ver3.pth -P ${PROJECT_DIR}/src/ndl_kotenseki_layout/models/
RUN set -x && cd ${PROJECT_DIR}/src/text_kotenseki_recognition/ && unzip -o model-ver2.zip
RUN set -x && pip3 install --no-cache-dir mmcv==2.1.0 -f https://download.openmmlab.com/mmcv/dist/cu121/torch2.1/index.html
WORKDIR ${PROJECT_DIR}