From 80285a33675e01b7e1117b1dcfc4e435cf2237ae Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Mon, 18 Sep 2023 18:22:11 +0200 Subject: [PATCH 01/26] feat: :sparkles: tf Dockerfile --- dockerfiles/tf.Dockerfile | 57 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 dockerfiles/tf.Dockerfile diff --git a/dockerfiles/tf.Dockerfile b/dockerfiles/tf.Dockerfile new file mode 100644 index 0000000000..c619783ed9 --- /dev/null +++ b/dockerfiles/tf.Dockerfile @@ -0,0 +1,57 @@ +FROM nvidia/cuda:11.8.0-base-ubuntu22.04 as base +ENV DEBIAN_FRONTEND=noninteractive +ENV LANG=C.UTF-8 + +# Configure nvidia repo +RUN apt-get update && \ +apt-get install -y gnupg ca-certificates wget && \ +# - Install Nvidia repo keys +# - See: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#network-repo-installation-for-ubuntu +wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \ +dpkg -i cuda-keyring_1.1-1_all.deb + +# Install CUDA +RUN apt-get update && apt-get install -y --no-install-recommends \ + cuda-command-line-tools-11-8 \ + cuda-cudart-dev-11-8 \ + cuda-nvcc-11-8 \ + cuda-cupti-11-8 \ + cuda-nvprune-11-8 \ + cuda-libraries-11-8 \ + cuda-nvrtc-11-8 \ + libcufft-11-8 \ + libcurand-11-8 \ + libcusolver-11-8 \ + libcusparse-11-8 \ + libcublas-11-8 \ + # - CuDNN: https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#ubuntu-network-installation + libcudnn8=8.6.0.163-1+cuda11.8 \ + libnvinfer-plugin8=8.6.1.6-1+cuda11.8 \ + libnvinfer8=8.6.1.6-1+cuda11.8 \ + # - Other packages + build-essential \ + pkg-config \ + curl \ + software-properties-common \ + unzip \ + tar \ + make gcc zlib1g-dev libffi-dev libssl-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* +################ + +# Install Python +ARG PYTHON_VERSION=3.10.13 + +RUN wget http://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz && \ + tar -zxf Python-$PYTHON_VERSION.tgz && \ + cd Python-$PYTHON_VERSION && \ + mkdir /opt/python/ && \ + ./configure --prefix=/opt/python && \ + make && \ + make install + +ENV PATH=/opt/python/bin:$PATH + +# Install docTR +RUN pip3 install --no-cache-dir "python-doctr[tf]" From 980aeb4a3177259b7a4ecf5743796bc5be5953c3 Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Mon, 25 Sep 2023 15:30:17 +0200 Subject: [PATCH 02/26] Generic Docker Image + CI --- .github/workflows/public_docker_images.yml | 48 ++++++++++++++ Dockerfile | 75 +++++++++++++++++----- dockerfiles/tf.Dockerfile | 57 ---------------- 3 files changed, 107 insertions(+), 73 deletions(-) create mode 100644 .github/workflows/public_docker_images.yml delete mode 100644 dockerfiles/tf.Dockerfile diff --git a/.github/workflows/public_docker_images.yml b/.github/workflows/public_docker_images.yml new file mode 100644 index 0000000000..25f8194dbe --- /dev/null +++ b/.github/workflows/public_docker_images.yml @@ -0,0 +1,48 @@ +# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages +# +name: Docker image on ghcr.io + +# Configures this workflow to run every time a change is pushed to the branch called `release`. +on: + push: + branches: ['release'] + +# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + # Must match version at https://www.python.org/ftp/python/ + python: ["3.8.18", "3.9.18", "3.10.13"] + framework: ["tf", "torch"] + doctr_version: ["0.7.0"] + + # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: false # TODO: CHANGE ME + tags: $framework-py$python-$doctr_version diff --git a/Dockerfile b/Dockerfile index badf6e5fda..06a364e158 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,64 @@ -# Use the TensorFlow GPU image as the base image. This image also works with CPU-only setups -FROM tensorflow/tensorflow@sha256:b4676741c491bff3d0f29c38c369281792c7d5c5bfa2b1aa93e5231a8d236323 +FROM nvidia/cuda:11.8.0-base-ubuntu22.04 as base -ENV PYTHONUNBUFFERED=1 -ENV PYTHONDONTWRITEBYTECODE=1 -ENV DOCTR_CACHE_DIR=/app/.cache +ENV DEBIAN_FRONTEND=noninteractive +ENV LANG=C.UTF-8 +ENV PYTHONUNBUFFERED=1 +ENV PYTHONDONTWRITEBYTECODE=1 +ENV DOCTR_CACHE_DIR=/app/.cache -WORKDIR /app +# Enroll NVIDIA GPG public key +RUN apt-get update && \ + apt-get install -y gnupg ca-certificates wget && \ + # - Install Nvidia repo keys + # - See: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#network-repo-installation-for-ubuntu + wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \ + dpkg -i cuda-keyring_1.1-1_all.deb -COPY . . +# Install CUDA +RUN apt-get update && apt-get install -y --no-install-recommends \ + cuda-command-line-tools-11-8 \ + cuda-cudart-dev-11-8 \ + cuda-nvcc-11-8 \ + cuda-cupti-11-8 \ + cuda-nvprune-11-8 \ + cuda-libraries-11-8 \ + cuda-nvrtc-11-8 \ + libcufft-11-8 \ + libcurand-11-8 \ + libcusolver-11-8 \ + libcusparse-11-8 \ + libcublas-11-8 \ + # - CuDNN: https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#ubuntu-network-installation + libcudnn8=8.6.0.163-1+cuda11.8 \ + libnvinfer-plugin8=8.6.1.6-1+cuda11.8 \ + libnvinfer8=8.6.1.6-1+cuda11.8 \ + # - Other packages + build-essential \ + pkg-config \ + curl \ + software-properties-common \ + unzip \ + # - Packages to build Python + tar make gcc zlib1g-dev libffi-dev libssl-dev \ + # - Packages for docTR + ffmpeg libsm6 libxext6 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* +################ -# Install necessary dependencies for video processing and GUI operations -RUN apt-get update \ - && apt-get install --no-install-recommends ffmpeg libsm6 libxext6 -y \ - && apt-get autoremove -y \ - && rm -rf /var/lib/apt/lists/* +# Install Python +ARG PYTHON_VERSION=3.10.13 -# Install the current application with TensorFlow extras and modify permissions -RUN pip install --upgrade pip setuptools wheel \ - && pip install -e .[tf] \ - && chmod -R a+w /app +RUN wget http://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz && \ + tar -zxf Python-$PYTHON_VERSION.tgz && \ + cd Python-$PYTHON_VERSION && \ + mkdir /opt/python/ && \ + ./configure --prefix=/opt/python && \ + make && \ + make install + +ENV PATH=/opt/python/bin:$PATH + +# Install docTR +RUN pip3 install -U pip setuptools wheel && \ + pip3 install --no-cache-dir "python-doctr[tf]" diff --git a/dockerfiles/tf.Dockerfile b/dockerfiles/tf.Dockerfile deleted file mode 100644 index c619783ed9..0000000000 --- a/dockerfiles/tf.Dockerfile +++ /dev/null @@ -1,57 +0,0 @@ -FROM nvidia/cuda:11.8.0-base-ubuntu22.04 as base -ENV DEBIAN_FRONTEND=noninteractive -ENV LANG=C.UTF-8 - -# Configure nvidia repo -RUN apt-get update && \ -apt-get install -y gnupg ca-certificates wget && \ -# - Install Nvidia repo keys -# - See: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#network-repo-installation-for-ubuntu -wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \ -dpkg -i cuda-keyring_1.1-1_all.deb - -# Install CUDA -RUN apt-get update && apt-get install -y --no-install-recommends \ - cuda-command-line-tools-11-8 \ - cuda-cudart-dev-11-8 \ - cuda-nvcc-11-8 \ - cuda-cupti-11-8 \ - cuda-nvprune-11-8 \ - cuda-libraries-11-8 \ - cuda-nvrtc-11-8 \ - libcufft-11-8 \ - libcurand-11-8 \ - libcusolver-11-8 \ - libcusparse-11-8 \ - libcublas-11-8 \ - # - CuDNN: https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#ubuntu-network-installation - libcudnn8=8.6.0.163-1+cuda11.8 \ - libnvinfer-plugin8=8.6.1.6-1+cuda11.8 \ - libnvinfer8=8.6.1.6-1+cuda11.8 \ - # - Other packages - build-essential \ - pkg-config \ - curl \ - software-properties-common \ - unzip \ - tar \ - make gcc zlib1g-dev libffi-dev libssl-dev \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* -################ - -# Install Python -ARG PYTHON_VERSION=3.10.13 - -RUN wget http://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz && \ - tar -zxf Python-$PYTHON_VERSION.tgz && \ - cd Python-$PYTHON_VERSION && \ - mkdir /opt/python/ && \ - ./configure --prefix=/opt/python && \ - make && \ - make install - -ENV PATH=/opt/python/bin:$PATH - -# Install docTR -RUN pip3 install --no-cache-dir "python-doctr[tf]" From f36a6267f4d048ef65fef2bab9c8cdbf8216f08c Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Mon, 25 Sep 2023 15:35:47 +0200 Subject: [PATCH 03/26] fix --- .github/workflows/public_docker_images.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/public_docker_images.yml b/.github/workflows/public_docker_images.yml index 25f8194dbe..30665fbcd0 100644 --- a/.github/workflows/public_docker_images.yml +++ b/.github/workflows/public_docker_images.yml @@ -2,12 +2,12 @@ # name: Docker image on ghcr.io -# Configures this workflow to run every time a change is pushed to the branch called `release`. on: push: - branches: ['release'] + branches: main + pull_request: + branches: main -# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} @@ -45,4 +45,4 @@ jobs: with: context: . push: false # TODO: CHANGE ME - tags: $framework-py$python-$doctr_version + tags: ${{ matrix.framework }}-py${{ matrix.python }}-${{ matrix.doctr_version }} From c8905a5f599fe1605b4b9470f31ba884e1a47215 Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Mon, 25 Sep 2023 18:14:01 +0200 Subject: [PATCH 04/26] `python3` --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 98428a4733..70507e4d05 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -14,7 +14,7 @@ jobs: - name: Build docker image run: docker build . -t doctr-tf-py3.8-slim - name: Run docker container - run: docker run doctr-tf-py3.8-slim python -c 'import doctr' + run: docker run doctr-tf-py3.8-slim python3 -c 'import doctr' pytest-api: runs-on: ${{ matrix.os }} From e97733343eb12994212b3d86e2c7abffdd22271b Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Tue, 26 Sep 2023 14:09:15 +0200 Subject: [PATCH 05/26] Parametrize framework --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 06a364e158..3aa6456593 100644 --- a/Dockerfile +++ b/Dockerfile @@ -60,5 +60,6 @@ RUN wget http://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION ENV PATH=/opt/python/bin:$PATH # Install docTR +ARG FRAMEWORK=tf RUN pip3 install -U pip setuptools wheel && \ - pip3 install --no-cache-dir "python-doctr[tf]" + pip3 install --no-cache-dir "python-doctr[$FRAMEWORK]" From 377fe8aefc0415253ec4d5ed15825d7cc7b1863c Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Tue, 26 Sep 2023 14:16:45 +0200 Subject: [PATCH 06/26] Remove DOCTR_CACHE_DIR (already set by the code) --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3aa6456593..3eb278e319 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,6 @@ ENV DEBIAN_FRONTEND=noninteractive ENV LANG=C.UTF-8 ENV PYTHONUNBUFFERED=1 ENV PYTHONDONTWRITEBYTECODE=1 -ENV DOCTR_CACHE_DIR=/app/.cache # Enroll NVIDIA GPG public key RUN apt-get update && \ From 45ac49dfb79e03261a743ae5ad47f0b1a9b19b43 Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Tue, 26 Sep 2023 14:19:36 +0200 Subject: [PATCH 07/26] `build-args` --- .github/workflows/public_docker_images.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/public_docker_images.yml b/.github/workflows/public_docker_images.yml index 30665fbcd0..4e7de2a2d4 100644 --- a/.github/workflows/public_docker_images.yml +++ b/.github/workflows/public_docker_images.yml @@ -44,5 +44,8 @@ jobs: uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: context: . + build-args: | + FRAMEWORK=${{ matrix.framework }} + PYTHON_VERSION=${{ matrix.python }} push: false # TODO: CHANGE ME tags: ${{ matrix.framework }}-py${{ matrix.python }}-${{ matrix.doctr_version }} From b2f2f6bb507bab1eef9af718a8aef6654013bd6c Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Wed, 27 Sep 2023 14:50:05 +0200 Subject: [PATCH 08/26] set tags for docker image --- .github/workflows/public_docker_images.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/public_docker_images.yml b/.github/workflows/public_docker_images.yml index 4e7de2a2d4..3cf854882e 100644 --- a/.github/workflows/public_docker_images.yml +++ b/.github/workflows/public_docker_images.yml @@ -7,6 +7,10 @@ on: branches: main pull_request: branches: main + schedule: + - cron: '0 2 * * 1' # At 02:00 on Monday + tags: + - 'v*' env: REGISTRY: ghcr.io @@ -22,7 +26,6 @@ jobs: # Must match version at https://www.python.org/ftp/python/ python: ["3.8.18", "3.9.18", "3.10.13"] framework: ["tf", "torch"] - doctr_version: ["0.7.0"] # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. permissions: @@ -40,12 +43,22 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push Docker image + - name: Build and push Docker image (latest) + if: matrix.framework == 'tf' || matrix.python == "3.8.18" uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: context: . build-args: | FRAMEWORK=${{ matrix.framework }} PYTHON_VERSION=${{ matrix.python }} + DOCTR_VERSION=${{ github.sha }} push: false # TODO: CHANGE ME - tags: ${{ matrix.framework }}-py${{ matrix.python }}-${{ matrix.doctr_version }} + tags: | + # used on schedule event + type=schedule,pattern={{date 'YYYY-MM-DD'}} + # set latest tag only if `enable` is True + type=raw,value=latest,enable=${{ matrix.framework == 'tf' && matrix.python == '3.8.18' && github.ref == format('refs/heads/{0}', 'main') }} + # used on push tag event + type=semver,pattern={{raw}},prefix=${{ matrix.framework }}-py${{ matrix.python }}- + # the rest + type=sha,prefix=${{ matrix.framework }}-py${{ matrix.python }}- From bc0e5424a4b0df3c565d23fb55250b256c2e422e Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Wed, 27 Sep 2023 14:52:20 +0200 Subject: [PATCH 09/26] Use pip+git install --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3eb278e319..7bdc3a724c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -60,5 +60,6 @@ ENV PATH=/opt/python/bin:$PATH # Install docTR ARG FRAMEWORK=tf +ARG DOCTR_VERSION=main RUN pip3 install -U pip setuptools wheel && \ - pip3 install --no-cache-dir "python-doctr[$FRAMEWORK]" + pip3 install --no-cache-dir "doctr[$FRAMEWORK]@git+https://github.com/mindee/doctr.git@main" From 2389e68248ba55ff50e8da2e429037fffd5312f5 Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Wed, 27 Sep 2023 14:54:31 +0200 Subject: [PATCH 10/26] fix --- .github/workflows/public_docker_images.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/public_docker_images.yml b/.github/workflows/public_docker_images.yml index 3cf854882e..5e3e1c9b2d 100644 --- a/.github/workflows/public_docker_images.yml +++ b/.github/workflows/public_docker_images.yml @@ -5,12 +5,12 @@ name: Docker image on ghcr.io on: push: branches: main + tags: + - 'v*' pull_request: branches: main schedule: - cron: '0 2 * * 1' # At 02:00 on Monday - tags: - - 'v*' env: REGISTRY: ghcr.io From 5f2b7ed51900b0c1faf3aae6cad3de2e7d43069a Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Wed, 27 Sep 2023 14:55:22 +0200 Subject: [PATCH 11/26] fix --- .github/workflows/public_docker_images.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/public_docker_images.yml b/.github/workflows/public_docker_images.yml index 5e3e1c9b2d..73ddc36972 100644 --- a/.github/workflows/public_docker_images.yml +++ b/.github/workflows/public_docker_images.yml @@ -44,7 +44,6 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker image (latest) - if: matrix.framework == 'tf' || matrix.python == "3.8.18" uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: context: . From 51dd73dd44dc332fc99094b7ad8b4d18f96b0d84 Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Wed, 27 Sep 2023 15:10:51 +0200 Subject: [PATCH 12/26] REVERT ME --- .github/workflows/builds.yml | 51 ---- .github/workflows/demo.yml | 71 ----- .github/workflows/docker.yml | 37 --- .github/workflows/docs.yml | 51 ---- .github/workflows/main.yml | 121 --------- .github/workflows/pr-labels.yml | 29 --- .github/workflows/pull_requests.yml | 32 --- .github/workflows/references.yml | 389 ---------------------------- .github/workflows/release.yml | 66 ----- .github/workflows/scripts.yml | 162 ------------ 10 files changed, 1009 deletions(-) delete mode 100644 .github/workflows/builds.yml delete mode 100644 .github/workflows/demo.yml delete mode 100644 .github/workflows/docker.yml delete mode 100644 .github/workflows/docs.yml delete mode 100644 .github/workflows/main.yml delete mode 100644 .github/workflows/pr-labels.yml delete mode 100644 .github/workflows/pull_requests.yml delete mode 100644 .github/workflows/references.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/scripts.yml diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml deleted file mode 100644 index 895c42cd68..0000000000 --- a/.github/workflows/builds.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: builds - -on: - push: - branches: main - pull_request: - branches: main - -jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macos-latest] - python: ["3.8", "3.9"] - framework: [tensorflow, pytorch] - steps: - - uses: actions/checkout@v3 - - if: matrix.os == 'macos-latest' - name: Install MacOS prerequisites - run: brew install cairo pango gdk-pixbuf libffi - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - if: matrix.framework == 'tensorflow' - name: Cache python modules (TF) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} - - if: matrix.framework == 'pytorch' - name: Cache python modules (PT) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} - - if: matrix.framework == 'tensorflow' - name: Install package (TF) - run: | - python -m pip install --upgrade pip - pip install -e .[tf] --upgrade - - if: matrix.framework == 'pytorch' - name: Install package (PT) - run: | - python -m pip install --upgrade pip - pip install -e .[torch] --upgrade - - name: Import package - run: python -c "import doctr; print(doctr.__version__)" diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml deleted file mode 100644 index 8f86d4f52c..0000000000 --- a/.github/workflows/demo.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: demo - -on: - push: - branches: main - pull_request: - branches: main - -jobs: - test-demo: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - python: ["3.8"] - framework: [tensorflow, pytorch] - steps: - - if: matrix.os == 'macos-latest' - name: Install MacOS prerequisites - run: brew install cairo pango gdk-pixbuf libffi - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - if: matrix.framework == 'tensorflow' - name: Cache python modules (TF) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('demo/tf-requirements.txt') }} - - if: matrix.framework == 'pytorch' - name: Cache python modules (PT) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('demo/pt-requirements.txt') }} - - - if: matrix.framework == 'tensorflow' - name: Install dependencies (TF) - run: | - python -m pip install --upgrade pip - pip install -e .[tf] --upgrade - pip install -r demo/tf-requirements.txt - - if: matrix.framework == 'pytorch' - name: Install dependencies (PT) - run: | - python -m pip install --upgrade pip - pip install -e .[torch] --upgrade - pip install -r demo/pt-requirements.txt - - - if: matrix.framework == 'tensorflow' - name: Run demo (TF) - env: - USE_TF: 1 - run: | - streamlit --version - screen -dm streamlit run demo/app.py - sleep 10 - curl http://localhost:8501/docs - - if: matrix.framework == 'pytorch' - name: Run demo (PT) - env: - USE_TORCH: 1 - run: | - streamlit --version - screen -dm streamlit run demo/app.py - sleep 10 - curl http://localhost:8501/docs diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 70507e4d05..0000000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: docker - -on: - push: - branches: main - pull_request: - branches: main - -jobs: - docker-package: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Build docker image - run: docker build . -t doctr-tf-py3.8-slim - - name: Run docker container - run: docker run doctr-tf-py3.8-slim python3 -c 'import doctr' - - pytest-api: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - python: ["3.8"] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - name: Build & run docker - run: cd api && docker-compose up -d --build - - name: Ping server - run: wget --spider --tries=12 http://localhost:8080/docs - - name: Run docker test - run: | - docker-compose -f api/docker-compose.yml exec --no-TTY web pytest tests/ diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 73000a7575..0000000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: docs -on: - push: - branches: main - -jobs: - docs-deploy: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - python: ["3.8"] - steps: - - uses: actions/checkout@v3 - with: - persist-credentials: false - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - name: Cache python modules - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-docs - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -e .[tf] - pip install -e .[docs] - - - name: Build documentation - run: cd docs && bash build.sh - - - name: Documentation sanity check - run: test -e docs/build/index.html || exit - - - name: Install SSH Client 🔑 - uses: webfactory/ssh-agent@v0.4.1 - with: - ssh-private-key: ${{ secrets.SSH_DEPLOY_KEY }} - - - name: Deploy to Github Pages - uses: JamesIves/github-pages-deploy-action@3.7.1 - with: - BRANCH: gh-pages - FOLDER: 'docs/build' - COMMIT_MESSAGE: '[skip ci] Documentation updates' - CLEAN: true - SSH: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 00a10786b9..0000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,121 +0,0 @@ -name: tests - -on: - push: - branches: main - pull_request: - branches: main - -jobs: - pytest-common: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - python: ["3.8"] - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - name: Cache python modules - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-tests - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -e .[tf] --upgrade - pip install -e .[testing] - - name: Run unittests - run: | - coverage run -m pytest tests/common/ - coverage xml -o coverage-common.xml - - uses: actions/upload-artifact@v2 - with: - name: coverage-common - path: ./coverage-common.xml - if-no-files-found: error - - pytest-tf: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - python: ["3.8"] - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - name: Cache python modules - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-tests - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -e .[tf] --upgrade - pip install -e .[testing] - - name: Run unittests - run: | - coverage run -m pytest tests/tensorflow/ - coverage xml -o coverage-tf.xml - - uses: actions/upload-artifact@v2 - with: - name: coverage-tf - path: ./coverage-tf.xml - if-no-files-found: error - - pytest-torch: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - python: ["3.8"] - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - name: Cache python modules - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-tests - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -e .[torch] --upgrade - pip install -e .[testing] - - - name: Run unittests - run: | - coverage run -m pytest tests/pytorch/ - coverage xml -o coverage-pt.xml - - - uses: actions/upload-artifact@v2 - with: - name: coverage-pytorch - path: ./coverage-pt.xml - if-no-files-found: error - - codecov-upload: - runs-on: ubuntu-latest - needs: [ pytest-common, pytest-tf, pytest-torch ] - steps: - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 - with: - flags: unittests - fail_ci_if_error: true diff --git a/.github/workflows/pr-labels.yml b/.github/workflows/pr-labels.yml deleted file mode 100644 index dc55bb1f4d..0000000000 --- a/.github/workflows/pr-labels.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: pr-labels - -on: - pull_request: - branches: main - types: closed - -jobs: - is-properly-labeled: - if: github.event.pull_request.merged == true - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - name: Set up python - uses: actions/setup-python@v4 - - name: Install requests - run: pip install requests - - name: Process commit and find merger responsible for labeling - id: commit - run: echo "::set-output name=merger::$(python .github/verify_pr_labels.py ${{ github.event.pull_request.number }})" - - name: 'Comment PR' - uses: actions/github-script@0.3.0 - if: ${{ steps.commit.outputs.merger != '' }} - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const { issue: { number: issue_number }, repo: { owner, repo } } = context; - github.issues.createComment({ issue_number, owner, repo, body: 'Hey ${{ steps.commit.outputs.merger }} 👋\nYou merged this PR, but it is not correctly labeled. The list of valid labels is available at https://github.com/mindee/doctr/blob/main/.github/verify_pr_labels.py' }); diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml deleted file mode 100644 index ade0d3a504..0000000000 --- a/.github/workflows/pull_requests.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: pull_requests - -on: - pull_request: - branches: main - -jobs: - docs-build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.8 - uses: actions/setup-python@v4 - with: - python-version: "3.8" - architecture: x64 - - name: Cache python modules - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-docs - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -e .[tf] --upgrade - pip install -e .[docs] - - - name: Build documentation - run: cd docs && bash build.sh - - - name: Documentation sanity check - run: test -e docs/build/index.html || exit diff --git a/.github/workflows/references.yml b/.github/workflows/references.yml deleted file mode 100644 index 572684fc01..0000000000 --- a/.github/workflows/references.yml +++ /dev/null @@ -1,389 +0,0 @@ -name: references - -on: - push: - branches: main - pull_request: - branches: main - -jobs: - train-char-classification: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - python: ["3.8"] - framework: [tensorflow, pytorch] - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - if: matrix.framework == 'tensorflow' - name: Cache python modules (TF) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('references/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}- - - if: matrix.framework == 'pytorch' - name: Cache python modules (PT) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }}-${{ hashFiles('references/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }}- - - if: matrix.framework == 'tensorflow' - name: Install dependencies (TF) - run: | - python -m pip install --upgrade pip - pip install -e .[tf] --upgrade - pip install -r references/requirements.txt - sudo apt-get update && sudo apt-get install fonts-freefont-ttf -y - - if: matrix.framework == 'pytorch' - name: Install dependencies (PT) - run: | - python -m pip install --upgrade pip - pip install -e .[torch] --upgrade - pip install -r references/requirements.txt - sudo apt-get update && sudo apt-get install fonts-freefont-ttf -y - - if: matrix.framework == 'tensorflow' - name: Train for a short epoch (TF) - run: python references/classification/train_tensorflow.py vit_s -b 32 --val-samples 1 --train-samples 1 --epochs 1 - - if: matrix.framework == 'pytorch' - name: Train for a short epoch (PT) - run: python references/classification/train_pytorch.py vit_s -b 32 --val-samples 1 --train-samples 1 --epochs 1 - - train-text-recognition: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - python: ["3.8"] - framework: [tensorflow, pytorch] - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - if: matrix.framework == 'tensorflow' - name: Cache python modules (TF) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('references/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}- - - if: matrix.framework == 'pytorch' - name: Cache python modules (PT) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }}-${{ hashFiles('references/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }}- - - if: matrix.framework == 'tensorflow' - name: Install dependencies (TF) - run: | - python -m pip install --upgrade pip - pip install -e .[tf] --upgrade - pip install -r references/requirements.txt - - if: matrix.framework == 'pytorch' - name: Install dependencies (PT) - run: | - python -m pip install --upgrade pip - pip install -e .[torch] --upgrade - pip install -r references/requirements.txt - - name: Download and extract toy set - run: | - wget https://github.com/mindee/doctr/releases/download/v0.3.1/toy_recogition_set-036a4d80.zip - sudo apt-get update && sudo apt-get install unzip -y - unzip toy_recogition_set-036a4d80.zip -d reco_set - - if: matrix.framework == 'tensorflow' - name: Train for a short epoch (TF) - run: python references/recognition/train_tensorflow.py crnn_vgg16_bn --train_path ./reco_set --val_path ./reco_set -b 4 --epochs 1 - - if: matrix.framework == 'pytorch' - name: Train for a short epoch (PT) - run: python references/recognition/train_pytorch.py crnn_mobilenet_v3_small --train_path ./reco_set --val_path ./reco_set -b 4 --epochs 1 - - evaluate-text-recognition: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - python: ["3.8"] - framework: [tensorflow, pytorch] - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - if: matrix.framework == 'tensorflow' - name: Cache python modules (TF) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }} - - if: matrix.framework == 'pytorch' - name: Cache python modules (PT) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }} - - if: matrix.framework == 'tensorflow' - name: Install dependencies (TF) - run: | - python -m pip install --upgrade pip - pip install -e .[tf] --upgrade - - if: matrix.framework == 'pytorch' - name: Install dependencies (PT) - run: | - python -m pip install --upgrade pip - pip install -e .[torch] --upgrade - - if: matrix.framework == 'tensorflow' - name: Evaluate text recognition (TF) - run: python references/recognition/evaluate_tensorflow.py crnn_mobilenet_v3_small --dataset IIIT5K -b 32 - - if: matrix.framework == 'pytorch' - name: Evaluate text recognition (PT) - run: python references/recognition/evaluate_pytorch.py crnn_mobilenet_v3_small --dataset IIIT5K -b 32 - - latency-text-recognition: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - python: ["3.8"] - framework: [tensorflow, pytorch] - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - if: matrix.framework == 'tensorflow' - name: Cache python modules (TF) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }} - - if: matrix.framework == 'pytorch' - name: Cache python modules (PT) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }} - - if: matrix.framework == 'tensorflow' - name: Install dependencies (TF) - run: | - python -m pip install --upgrade pip - pip install -e .[tf] --upgrade - - if: matrix.framework == 'pytorch' - name: Install dependencies (PT) - run: | - python -m pip install --upgrade pip - pip install -e .[torch] --upgrade - - if: matrix.framework == 'tensorflow' - name: Benchmark latency (TF) - run: python references/recognition/latency_tensorflow.py crnn_vgg16_bn --it 5 - - if: matrix.framework == 'pytorch' - name: Benchmark latency (PT) - run: python references/recognition/latency_pytorch.py crnn_mobilenet_v3_small --it 5 - - train-text-detection: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - python: ["3.8"] - framework: [tensorflow, pytorch] - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - if: matrix.framework == 'tensorflow' - name: Cache python modules (TF) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('references/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}- - - if: matrix.framework == 'pytorch' - name: Cache python modules (PT) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }}-${{ hashFiles('references/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }}- - - if: matrix.framework == 'tensorflow' - name: Install dependencies (TF) - run: | - python -m pip install --upgrade pip - pip install -e .[tf] --upgrade - pip install -r references/requirements.txt - - if: matrix.framework == 'pytorch' - name: Install dependencies (PT) - run: | - python -m pip install --upgrade pip - pip install -e .[torch] --upgrade - pip install -r references/requirements.txt - - name: Download and extract toy set - run: | - wget https://github.com/mindee/doctr/releases/download/v0.3.1/toy_detection_set-bbbb4243.zip - sudo apt-get update && sudo apt-get install unzip -y - unzip toy_detection_set-bbbb4243.zip -d det_set - - if: matrix.framework == 'tensorflow' - name: Train for a short epoch (TF) - run: python references/detection/train_tensorflow.py --train_path ./det_set --val_path ./det_set db_resnet50 -b 2 --epochs 1 - - if: matrix.framework == 'pytorch' - name: Train for a short epoch (PT) - run: python references/detection/train_pytorch.py ./det_set ./det_set db_mobilenet_v3_large -b 2 --epochs 1 - - evaluate-text-detection: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - python: ["3.8"] - framework: [tensorflow, pytorch] - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - if: matrix.framework == 'tensorflow' - name: Cache python modules (TF) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }} - - if: matrix.framework == 'pytorch' - name: Cache python modules (PT) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }} - - if: matrix.framework == 'tensorflow' - name: Install dependencies (TF) - run: | - python -m pip install --upgrade pip - pip install -e .[tf] --upgrade - pip install -r references/requirements.txt - - if: matrix.framework == 'pytorch' - name: Install dependencies (PT) - run: | - python -m pip install --upgrade pip - pip install -e .[torch] --upgrade - pip install -r references/requirements.txt - - if: matrix.framework == 'tensorflow' - name: Evaluate text detection (TF) - run: python references/detection/evaluate_tensorflow.py db_mobilenet_v3_large - - if: matrix.framework == 'pytorch' - name: Evaluate text detection (PT) - run: python references/detection/evaluate_pytorch.py db_mobilenet_v3_large - - latency-text-detection: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - python: ["3.8"] - framework: [tensorflow, pytorch] - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - if: matrix.framework == 'tensorflow' - name: Cache python modules (TF) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }} - - if: matrix.framework == 'pytorch' - name: Cache python modules (PT) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }} - - if: matrix.framework == 'tensorflow' - name: Install dependencies (TF) - run: | - python -m pip install --upgrade pip - pip install -e .[tf] --upgrade - - if: matrix.framework == 'pytorch' - name: Install dependencies (PT) - run: | - python -m pip install --upgrade pip - pip install -e .[torch] --upgrade - - if: matrix.framework == 'tensorflow' - name: Benchmark latency (TF) - run: python references/detection/latency_tensorflow.py linknet_resnet18 --it 5 --size 512 - - if: matrix.framework == 'pytorch' - name: Benchmark latency (PT) - run: python references/detection/latency_pytorch.py linknet_resnet18 --it 5 --size 512 - - latency-object-detection: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - python: ["3.8"] - framework: [pytorch] - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - if: matrix.framework == 'tensorflow' - name: Cache python modules (TF) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }} - - if: matrix.framework == 'pytorch' - name: Cache python modules (PT) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }} - - if: matrix.framework == 'tensorflow' - name: Install dependencies (TF) - run: | - python -m pip install --upgrade pip - pip install -e .[tf] --upgrade - - if: matrix.framework == 'pytorch' - name: Install dependencies (PT) - run: | - python -m pip install --upgrade pip - pip install -e .[torch] --upgrade - - if: matrix.framework == 'pytorch' - name: Benchmark latency (PT) - run: python references/obj_detection/latency_pytorch.py fasterrcnn_mobilenet_v3_large_fpn --it 5 --size 512 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 37446c9c46..0000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: pypi-publish - -on: - release: - types: [published] - -jobs: - - pypi-publish: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - python: ["3.8"] - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - name: Cache python modules - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine --upgrade - - name: Get release tag - id: release_tag - run: | - echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - VERSION: ${{ steps.release_tag.outputs.VERSION }} - run: | - BUILD_VERSION=$VERSION python setup.py sdist bdist_wheel - twine check dist/* - twine upload dist/* - - pypi-check: - if: "!github.event.release.prerelease" - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - python: ["3.8"] - needs: pypi-publish - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.8 - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - name: Install package - run: | - python -m pip install --upgrade pip - pip install python-doctr - python -c "import doctr; print(doctr.__version__)" diff --git a/.github/workflows/scripts.yml b/.github/workflows/scripts.yml deleted file mode 100644 index f8e8e3b11c..0000000000 --- a/.github/workflows/scripts.yml +++ /dev/null @@ -1,162 +0,0 @@ -name: scripts - -on: - push: - branches: main - pull_request: - branches: main - -jobs: - test-analyze: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - python: ["3.8", "3.9"] - framework: [tensorflow, pytorch] - steps: - - if: matrix.os == 'macos-latest' - name: Install MacOS prerequisites - run: brew install cairo pango gdk-pixbuf libffi - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - if: matrix.framework == 'tensorflow' - name: Cache python modules (TF) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} - - if: matrix.framework == 'pytorch' - name: Cache python modules (PT) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} - - if: matrix.framework == 'tensorflow' - name: Install package (TF) - run: | - python -m pip install --upgrade pip - pip install -e .[tf] --upgrade - - if: matrix.framework == 'pytorch' - name: Install package (PT) - run: | - python -m pip install --upgrade pip - pip install -e .[torch] --upgrade - - - name: Run analysis script - run: | - wget https://github.com/mindee/doctr/releases/download/v0.1.0/sample.pdf - python scripts/analyze.py sample.pdf --noblock - - test-detect-text: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - python: ["3.8", "3.9"] - framework: [tensorflow, pytorch] - steps: - - if: matrix.os == 'macos-latest' - name: Install MacOS prerequisites - run: brew install cairo pango gdk-pixbuf libffi - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - if: matrix.framework == 'tensorflow' - name: Cache python modules (TF) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} - - if: matrix.framework == 'pytorch' - name: Cache python modules (PT) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} - - if: matrix.framework == 'tensorflow' - name: Install package (TF) - run: | - python -m pip install --upgrade pip - pip install -e .[tf] --upgrade - - if: matrix.framework == 'pytorch' - name: Install package (PT) - run: | - python -m pip install --upgrade pip - pip install -e .[torch] --upgrade - - - name: Run detection script - run: | - wget https://github.com/mindee/doctr/releases/download/v0.1.0/sample.pdf - python scripts/detect_text.py sample.pdf - - test-evaluate: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - python: ["3.8", "3.9"] - framework: [tensorflow, pytorch] - steps: - - if: matrix.os == 'macos-latest' - name: Install MacOS prerequisites - run: brew install cairo pango gdk-pixbuf libffi - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - if: matrix.framework == 'tensorflow' - name: Cache python modules (TF) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} - - if: matrix.framework == 'pytorch' - name: Cache python modules (PT) - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} - - if: matrix.framework == 'tensorflow' - name: Install package (TF) - run: | - python -m pip install --upgrade pip - pip install -e .[tf] --upgrade - - if: matrix.framework == 'pytorch' - name: Install package (PT) - run: | - python -m pip install --upgrade pip - pip install -e .[torch] --upgrade - - name: Run evaluation script - run: | - python scripts/evaluate.py db_resnet50 crnn_vgg16_bn --samples 10 - python scripts/evaluate_kie.py db_resnet50 crnn_vgg16_bn --samples 10 - - test-collectenv: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python: ["3.8", "3.9"] - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - name: Run environment collection script - run: python scripts/collect_env.py From 491e34eb300ea56f914f232a970135361d3755de Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Wed, 27 Sep 2023 15:15:24 +0200 Subject: [PATCH 13/26] Revert "REVERT ME" This reverts commit 51dd73dd44dc332fc99094b7ad8b4d18f96b0d84. --- .github/workflows/builds.yml | 51 ++++ .github/workflows/demo.yml | 71 +++++ .github/workflows/docker.yml | 37 +++ .github/workflows/docs.yml | 51 ++++ .github/workflows/main.yml | 121 +++++++++ .github/workflows/pr-labels.yml | 29 +++ .github/workflows/pull_requests.yml | 32 +++ .github/workflows/references.yml | 389 ++++++++++++++++++++++++++++ .github/workflows/release.yml | 66 +++++ .github/workflows/scripts.yml | 162 ++++++++++++ 10 files changed, 1009 insertions(+) create mode 100644 .github/workflows/builds.yml create mode 100644 .github/workflows/demo.yml create mode 100644 .github/workflows/docker.yml create mode 100644 .github/workflows/docs.yml create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/pr-labels.yml create mode 100644 .github/workflows/pull_requests.yml create mode 100644 .github/workflows/references.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/scripts.yml diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml new file mode 100644 index 0000000000..895c42cd68 --- /dev/null +++ b/.github/workflows/builds.yml @@ -0,0 +1,51 @@ +name: builds + +on: + push: + branches: main + pull_request: + branches: main + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + python: ["3.8", "3.9"] + framework: [tensorflow, pytorch] + steps: + - uses: actions/checkout@v3 + - if: matrix.os == 'macos-latest' + name: Install MacOS prerequisites + run: brew install cairo pango gdk-pixbuf libffi + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - if: matrix.framework == 'tensorflow' + name: Cache python modules (TF) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} + - if: matrix.framework == 'pytorch' + name: Cache python modules (PT) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} + - if: matrix.framework == 'tensorflow' + name: Install package (TF) + run: | + python -m pip install --upgrade pip + pip install -e .[tf] --upgrade + - if: matrix.framework == 'pytorch' + name: Install package (PT) + run: | + python -m pip install --upgrade pip + pip install -e .[torch] --upgrade + - name: Import package + run: python -c "import doctr; print(doctr.__version__)" diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml new file mode 100644 index 0000000000..8f86d4f52c --- /dev/null +++ b/.github/workflows/demo.yml @@ -0,0 +1,71 @@ +name: demo + +on: + push: + branches: main + pull_request: + branches: main + +jobs: + test-demo: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python: ["3.8"] + framework: [tensorflow, pytorch] + steps: + - if: matrix.os == 'macos-latest' + name: Install MacOS prerequisites + run: brew install cairo pango gdk-pixbuf libffi + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - if: matrix.framework == 'tensorflow' + name: Cache python modules (TF) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('demo/tf-requirements.txt') }} + - if: matrix.framework == 'pytorch' + name: Cache python modules (PT) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('demo/pt-requirements.txt') }} + + - if: matrix.framework == 'tensorflow' + name: Install dependencies (TF) + run: | + python -m pip install --upgrade pip + pip install -e .[tf] --upgrade + pip install -r demo/tf-requirements.txt + - if: matrix.framework == 'pytorch' + name: Install dependencies (PT) + run: | + python -m pip install --upgrade pip + pip install -e .[torch] --upgrade + pip install -r demo/pt-requirements.txt + + - if: matrix.framework == 'tensorflow' + name: Run demo (TF) + env: + USE_TF: 1 + run: | + streamlit --version + screen -dm streamlit run demo/app.py + sleep 10 + curl http://localhost:8501/docs + - if: matrix.framework == 'pytorch' + name: Run demo (PT) + env: + USE_TORCH: 1 + run: | + streamlit --version + screen -dm streamlit run demo/app.py + sleep 10 + curl http://localhost:8501/docs diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000000..70507e4d05 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,37 @@ +name: docker + +on: + push: + branches: main + pull_request: + branches: main + +jobs: + docker-package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build docker image + run: docker build . -t doctr-tf-py3.8-slim + - name: Run docker container + run: docker run doctr-tf-py3.8-slim python3 -c 'import doctr' + + pytest-api: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + python: ["3.8"] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - name: Build & run docker + run: cd api && docker-compose up -d --build + - name: Ping server + run: wget --spider --tries=12 http://localhost:8080/docs + - name: Run docker test + run: | + docker-compose -f api/docker-compose.yml exec --no-TTY web pytest tests/ diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000000..73000a7575 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,51 @@ +name: docs +on: + push: + branches: main + +jobs: + docs-deploy: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + python: ["3.8"] + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - name: Cache python modules + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-docs + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e .[tf] + pip install -e .[docs] + + - name: Build documentation + run: cd docs && bash build.sh + + - name: Documentation sanity check + run: test -e docs/build/index.html || exit + + - name: Install SSH Client 🔑 + uses: webfactory/ssh-agent@v0.4.1 + with: + ssh-private-key: ${{ secrets.SSH_DEPLOY_KEY }} + + - name: Deploy to Github Pages + uses: JamesIves/github-pages-deploy-action@3.7.1 + with: + BRANCH: gh-pages + FOLDER: 'docs/build' + COMMIT_MESSAGE: '[skip ci] Documentation updates' + CLEAN: true + SSH: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000000..00a10786b9 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,121 @@ +name: tests + +on: + push: + branches: main + pull_request: + branches: main + +jobs: + pytest-common: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + python: ["3.8"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - name: Cache python modules + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-tests + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e .[tf] --upgrade + pip install -e .[testing] + - name: Run unittests + run: | + coverage run -m pytest tests/common/ + coverage xml -o coverage-common.xml + - uses: actions/upload-artifact@v2 + with: + name: coverage-common + path: ./coverage-common.xml + if-no-files-found: error + + pytest-tf: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + python: ["3.8"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - name: Cache python modules + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-tests + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e .[tf] --upgrade + pip install -e .[testing] + - name: Run unittests + run: | + coverage run -m pytest tests/tensorflow/ + coverage xml -o coverage-tf.xml + - uses: actions/upload-artifact@v2 + with: + name: coverage-tf + path: ./coverage-tf.xml + if-no-files-found: error + + pytest-torch: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + python: ["3.8"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - name: Cache python modules + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-tests + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e .[torch] --upgrade + pip install -e .[testing] + + - name: Run unittests + run: | + coverage run -m pytest tests/pytorch/ + coverage xml -o coverage-pt.xml + + - uses: actions/upload-artifact@v2 + with: + name: coverage-pytorch + path: ./coverage-pt.xml + if-no-files-found: error + + codecov-upload: + runs-on: ubuntu-latest + needs: [ pytest-common, pytest-tf, pytest-torch ] + steps: + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + flags: unittests + fail_ci_if_error: true diff --git a/.github/workflows/pr-labels.yml b/.github/workflows/pr-labels.yml new file mode 100644 index 0000000000..dc55bb1f4d --- /dev/null +++ b/.github/workflows/pr-labels.yml @@ -0,0 +1,29 @@ +name: pr-labels + +on: + pull_request: + branches: main + types: closed + +jobs: + is-properly-labeled: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Set up python + uses: actions/setup-python@v4 + - name: Install requests + run: pip install requests + - name: Process commit and find merger responsible for labeling + id: commit + run: echo "::set-output name=merger::$(python .github/verify_pr_labels.py ${{ github.event.pull_request.number }})" + - name: 'Comment PR' + uses: actions/github-script@0.3.0 + if: ${{ steps.commit.outputs.merger != '' }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { issue: { number: issue_number }, repo: { owner, repo } } = context; + github.issues.createComment({ issue_number, owner, repo, body: 'Hey ${{ steps.commit.outputs.merger }} 👋\nYou merged this PR, but it is not correctly labeled. The list of valid labels is available at https://github.com/mindee/doctr/blob/main/.github/verify_pr_labels.py' }); diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml new file mode 100644 index 0000000000..ade0d3a504 --- /dev/null +++ b/.github/workflows/pull_requests.yml @@ -0,0 +1,32 @@ +name: pull_requests + +on: + pull_request: + branches: main + +jobs: + docs-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.8 + uses: actions/setup-python@v4 + with: + python-version: "3.8" + architecture: x64 + - name: Cache python modules + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-docs + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e .[tf] --upgrade + pip install -e .[docs] + + - name: Build documentation + run: cd docs && bash build.sh + + - name: Documentation sanity check + run: test -e docs/build/index.html || exit diff --git a/.github/workflows/references.yml b/.github/workflows/references.yml new file mode 100644 index 0000000000..572684fc01 --- /dev/null +++ b/.github/workflows/references.yml @@ -0,0 +1,389 @@ +name: references + +on: + push: + branches: main + pull_request: + branches: main + +jobs: + train-char-classification: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python: ["3.8"] + framework: [tensorflow, pytorch] + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - if: matrix.framework == 'tensorflow' + name: Cache python modules (TF) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('references/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}- + - if: matrix.framework == 'pytorch' + name: Cache python modules (PT) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }}-${{ hashFiles('references/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }}- + - if: matrix.framework == 'tensorflow' + name: Install dependencies (TF) + run: | + python -m pip install --upgrade pip + pip install -e .[tf] --upgrade + pip install -r references/requirements.txt + sudo apt-get update && sudo apt-get install fonts-freefont-ttf -y + - if: matrix.framework == 'pytorch' + name: Install dependencies (PT) + run: | + python -m pip install --upgrade pip + pip install -e .[torch] --upgrade + pip install -r references/requirements.txt + sudo apt-get update && sudo apt-get install fonts-freefont-ttf -y + - if: matrix.framework == 'tensorflow' + name: Train for a short epoch (TF) + run: python references/classification/train_tensorflow.py vit_s -b 32 --val-samples 1 --train-samples 1 --epochs 1 + - if: matrix.framework == 'pytorch' + name: Train for a short epoch (PT) + run: python references/classification/train_pytorch.py vit_s -b 32 --val-samples 1 --train-samples 1 --epochs 1 + + train-text-recognition: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python: ["3.8"] + framework: [tensorflow, pytorch] + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - if: matrix.framework == 'tensorflow' + name: Cache python modules (TF) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('references/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}- + - if: matrix.framework == 'pytorch' + name: Cache python modules (PT) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }}-${{ hashFiles('references/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }}- + - if: matrix.framework == 'tensorflow' + name: Install dependencies (TF) + run: | + python -m pip install --upgrade pip + pip install -e .[tf] --upgrade + pip install -r references/requirements.txt + - if: matrix.framework == 'pytorch' + name: Install dependencies (PT) + run: | + python -m pip install --upgrade pip + pip install -e .[torch] --upgrade + pip install -r references/requirements.txt + - name: Download and extract toy set + run: | + wget https://github.com/mindee/doctr/releases/download/v0.3.1/toy_recogition_set-036a4d80.zip + sudo apt-get update && sudo apt-get install unzip -y + unzip toy_recogition_set-036a4d80.zip -d reco_set + - if: matrix.framework == 'tensorflow' + name: Train for a short epoch (TF) + run: python references/recognition/train_tensorflow.py crnn_vgg16_bn --train_path ./reco_set --val_path ./reco_set -b 4 --epochs 1 + - if: matrix.framework == 'pytorch' + name: Train for a short epoch (PT) + run: python references/recognition/train_pytorch.py crnn_mobilenet_v3_small --train_path ./reco_set --val_path ./reco_set -b 4 --epochs 1 + + evaluate-text-recognition: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python: ["3.8"] + framework: [tensorflow, pytorch] + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - if: matrix.framework == 'tensorflow' + name: Cache python modules (TF) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }} + - if: matrix.framework == 'pytorch' + name: Cache python modules (PT) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }} + - if: matrix.framework == 'tensorflow' + name: Install dependencies (TF) + run: | + python -m pip install --upgrade pip + pip install -e .[tf] --upgrade + - if: matrix.framework == 'pytorch' + name: Install dependencies (PT) + run: | + python -m pip install --upgrade pip + pip install -e .[torch] --upgrade + - if: matrix.framework == 'tensorflow' + name: Evaluate text recognition (TF) + run: python references/recognition/evaluate_tensorflow.py crnn_mobilenet_v3_small --dataset IIIT5K -b 32 + - if: matrix.framework == 'pytorch' + name: Evaluate text recognition (PT) + run: python references/recognition/evaluate_pytorch.py crnn_mobilenet_v3_small --dataset IIIT5K -b 32 + + latency-text-recognition: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python: ["3.8"] + framework: [tensorflow, pytorch] + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - if: matrix.framework == 'tensorflow' + name: Cache python modules (TF) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }} + - if: matrix.framework == 'pytorch' + name: Cache python modules (PT) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }} + - if: matrix.framework == 'tensorflow' + name: Install dependencies (TF) + run: | + python -m pip install --upgrade pip + pip install -e .[tf] --upgrade + - if: matrix.framework == 'pytorch' + name: Install dependencies (PT) + run: | + python -m pip install --upgrade pip + pip install -e .[torch] --upgrade + - if: matrix.framework == 'tensorflow' + name: Benchmark latency (TF) + run: python references/recognition/latency_tensorflow.py crnn_vgg16_bn --it 5 + - if: matrix.framework == 'pytorch' + name: Benchmark latency (PT) + run: python references/recognition/latency_pytorch.py crnn_mobilenet_v3_small --it 5 + + train-text-detection: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python: ["3.8"] + framework: [tensorflow, pytorch] + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - if: matrix.framework == 'tensorflow' + name: Cache python modules (TF) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('references/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}- + - if: matrix.framework == 'pytorch' + name: Cache python modules (PT) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }}-${{ hashFiles('references/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }}- + - if: matrix.framework == 'tensorflow' + name: Install dependencies (TF) + run: | + python -m pip install --upgrade pip + pip install -e .[tf] --upgrade + pip install -r references/requirements.txt + - if: matrix.framework == 'pytorch' + name: Install dependencies (PT) + run: | + python -m pip install --upgrade pip + pip install -e .[torch] --upgrade + pip install -r references/requirements.txt + - name: Download and extract toy set + run: | + wget https://github.com/mindee/doctr/releases/download/v0.3.1/toy_detection_set-bbbb4243.zip + sudo apt-get update && sudo apt-get install unzip -y + unzip toy_detection_set-bbbb4243.zip -d det_set + - if: matrix.framework == 'tensorflow' + name: Train for a short epoch (TF) + run: python references/detection/train_tensorflow.py --train_path ./det_set --val_path ./det_set db_resnet50 -b 2 --epochs 1 + - if: matrix.framework == 'pytorch' + name: Train for a short epoch (PT) + run: python references/detection/train_pytorch.py ./det_set ./det_set db_mobilenet_v3_large -b 2 --epochs 1 + + evaluate-text-detection: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python: ["3.8"] + framework: [tensorflow, pytorch] + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - if: matrix.framework == 'tensorflow' + name: Cache python modules (TF) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }} + - if: matrix.framework == 'pytorch' + name: Cache python modules (PT) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }} + - if: matrix.framework == 'tensorflow' + name: Install dependencies (TF) + run: | + python -m pip install --upgrade pip + pip install -e .[tf] --upgrade + pip install -r references/requirements.txt + - if: matrix.framework == 'pytorch' + name: Install dependencies (PT) + run: | + python -m pip install --upgrade pip + pip install -e .[torch] --upgrade + pip install -r references/requirements.txt + - if: matrix.framework == 'tensorflow' + name: Evaluate text detection (TF) + run: python references/detection/evaluate_tensorflow.py db_mobilenet_v3_large + - if: matrix.framework == 'pytorch' + name: Evaluate text detection (PT) + run: python references/detection/evaluate_pytorch.py db_mobilenet_v3_large + + latency-text-detection: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python: ["3.8"] + framework: [tensorflow, pytorch] + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - if: matrix.framework == 'tensorflow' + name: Cache python modules (TF) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }} + - if: matrix.framework == 'pytorch' + name: Cache python modules (PT) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }} + - if: matrix.framework == 'tensorflow' + name: Install dependencies (TF) + run: | + python -m pip install --upgrade pip + pip install -e .[tf] --upgrade + - if: matrix.framework == 'pytorch' + name: Install dependencies (PT) + run: | + python -m pip install --upgrade pip + pip install -e .[torch] --upgrade + - if: matrix.framework == 'tensorflow' + name: Benchmark latency (TF) + run: python references/detection/latency_tensorflow.py linknet_resnet18 --it 5 --size 512 + - if: matrix.framework == 'pytorch' + name: Benchmark latency (PT) + run: python references/detection/latency_pytorch.py linknet_resnet18 --it 5 --size 512 + + latency-object-detection: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python: ["3.8"] + framework: [pytorch] + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - if: matrix.framework == 'tensorflow' + name: Cache python modules (TF) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements.txt') }} + - if: matrix.framework == 'pytorch' + name: Cache python modules (PT) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('requirements-pt.txt') }} + - if: matrix.framework == 'tensorflow' + name: Install dependencies (TF) + run: | + python -m pip install --upgrade pip + pip install -e .[tf] --upgrade + - if: matrix.framework == 'pytorch' + name: Install dependencies (PT) + run: | + python -m pip install --upgrade pip + pip install -e .[torch] --upgrade + - if: matrix.framework == 'pytorch' + name: Benchmark latency (PT) + run: python references/obj_detection/latency_pytorch.py fasterrcnn_mobilenet_v3_large_fpn --it 5 --size 512 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..37446c9c46 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,66 @@ +name: pypi-publish + +on: + release: + types: [published] + +jobs: + + pypi-publish: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python: ["3.8"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - name: Cache python modules + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine --upgrade + - name: Get release tag + id: release_tag + run: | + echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + VERSION: ${{ steps.release_tag.outputs.VERSION }} + run: | + BUILD_VERSION=$VERSION python setup.py sdist bdist_wheel + twine check dist/* + twine upload dist/* + + pypi-check: + if: "!github.event.release.prerelease" + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python: ["3.8"] + needs: pypi-publish + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.8 + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - name: Install package + run: | + python -m pip install --upgrade pip + pip install python-doctr + python -c "import doctr; print(doctr.__version__)" diff --git a/.github/workflows/scripts.yml b/.github/workflows/scripts.yml new file mode 100644 index 0000000000..f8e8e3b11c --- /dev/null +++ b/.github/workflows/scripts.yml @@ -0,0 +1,162 @@ +name: scripts + +on: + push: + branches: main + pull_request: + branches: main + +jobs: + test-analyze: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python: ["3.8", "3.9"] + framework: [tensorflow, pytorch] + steps: + - if: matrix.os == 'macos-latest' + name: Install MacOS prerequisites + run: brew install cairo pango gdk-pixbuf libffi + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - if: matrix.framework == 'tensorflow' + name: Cache python modules (TF) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} + - if: matrix.framework == 'pytorch' + name: Cache python modules (PT) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} + - if: matrix.framework == 'tensorflow' + name: Install package (TF) + run: | + python -m pip install --upgrade pip + pip install -e .[tf] --upgrade + - if: matrix.framework == 'pytorch' + name: Install package (PT) + run: | + python -m pip install --upgrade pip + pip install -e .[torch] --upgrade + + - name: Run analysis script + run: | + wget https://github.com/mindee/doctr/releases/download/v0.1.0/sample.pdf + python scripts/analyze.py sample.pdf --noblock + + test-detect-text: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python: ["3.8", "3.9"] + framework: [tensorflow, pytorch] + steps: + - if: matrix.os == 'macos-latest' + name: Install MacOS prerequisites + run: brew install cairo pango gdk-pixbuf libffi + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - if: matrix.framework == 'tensorflow' + name: Cache python modules (TF) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} + - if: matrix.framework == 'pytorch' + name: Cache python modules (PT) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} + - if: matrix.framework == 'tensorflow' + name: Install package (TF) + run: | + python -m pip install --upgrade pip + pip install -e .[tf] --upgrade + - if: matrix.framework == 'pytorch' + name: Install package (PT) + run: | + python -m pip install --upgrade pip + pip install -e .[torch] --upgrade + + - name: Run detection script + run: | + wget https://github.com/mindee/doctr/releases/download/v0.1.0/sample.pdf + python scripts/detect_text.py sample.pdf + + test-evaluate: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python: ["3.8", "3.9"] + framework: [tensorflow, pytorch] + steps: + - if: matrix.os == 'macos-latest' + name: Install MacOS prerequisites + run: brew install cairo pango gdk-pixbuf libffi + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - if: matrix.framework == 'tensorflow' + name: Cache python modules (TF) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} + - if: matrix.framework == 'pytorch' + name: Cache python modules (PT) + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pkg-deps-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} + - if: matrix.framework == 'tensorflow' + name: Install package (TF) + run: | + python -m pip install --upgrade pip + pip install -e .[tf] --upgrade + - if: matrix.framework == 'pytorch' + name: Install package (PT) + run: | + python -m pip install --upgrade pip + pip install -e .[torch] --upgrade + - name: Run evaluation script + run: | + python scripts/evaluate.py db_resnet50 crnn_vgg16_bn --samples 10 + python scripts/evaluate_kie.py db_resnet50 crnn_vgg16_bn --samples 10 + + test-collectenv: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python: ["3.8", "3.9"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - name: Run environment collection script + run: python scripts/collect_env.py From c832a8479b54feb8b87a059b41da5d118e069a4a Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Wed, 27 Sep 2023 15:22:31 +0200 Subject: [PATCH 14/26] Fix --- .github/workflows/public_docker_images.yml | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/public_docker_images.yml b/.github/workflows/public_docker_images.yml index 73ddc36972..aec6bce5f1 100644 --- a/.github/workflows/public_docker_images.yml +++ b/.github/workflows/public_docker_images.yml @@ -43,15 +43,11 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push Docker image (latest) - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: - context: . - build-args: | - FRAMEWORK=${{ matrix.framework }} - PYTHON_VERSION=${{ matrix.python }} - DOCTR_VERSION=${{ github.sha }} - push: false # TODO: CHANGE ME + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | # used on schedule event type=schedule,pattern={{date 'YYYY-MM-DD'}} @@ -61,3 +57,14 @@ jobs: type=semver,pattern={{raw}},prefix=${{ matrix.framework }}-py${{ matrix.python }}- # the rest type=sha,prefix=${{ matrix.framework }}-py${{ matrix.python }}- + + - name: Build and push Docker image (latest) + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + build-args: | + FRAMEWORK=${{ matrix.framework }} + PYTHON_VERSION=${{ matrix.python }} + DOCTR_VERSION=${{ github.sha }} + push: false # TODO: CHANGE ME + tags: ${{ steps.meta.outputs.tags }} From ee08bbd86bbb1e14adb8716d827de0ab03345a31 Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Wed, 27 Sep 2023 15:40:31 +0200 Subject: [PATCH 15/26] Add git --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 7bdc3a724c..46392c36d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,6 +37,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ software-properties-common \ unzip \ + git \ # - Packages to build Python tar make gcc zlib1g-dev libffi-dev libssl-dev \ # - Packages for docTR From 9553d16032fdb1cadd4fb345512c6c26134d63a2 Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Wed, 27 Sep 2023 16:14:32 +0200 Subject: [PATCH 16/26] Modify frequency --- .github/workflows/public_docker_images.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/public_docker_images.yml b/.github/workflows/public_docker_images.yml index aec6bce5f1..99c208afd1 100644 --- a/.github/workflows/public_docker_images.yml +++ b/.github/workflows/public_docker_images.yml @@ -10,7 +10,7 @@ on: pull_request: branches: main schedule: - - cron: '0 2 * * 1' # At 02:00 on Monday + - cron: '0 2 1 * *' # At 02:00 on day-of-month 1 env: REGISTRY: ghcr.io @@ -50,13 +50,11 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | # used on schedule event - type=schedule,pattern={{date 'YYYY-MM-DD'}} + type=schedule,pattern={{date 'YYYY-MM-DD'}},prefix=${{ matrix.framework }}-py${{ matrix.python }}- # set latest tag only if `enable` is True type=raw,value=latest,enable=${{ matrix.framework == 'tf' && matrix.python == '3.8.18' && github.ref == format('refs/heads/{0}', 'main') }} # used on push tag event type=semver,pattern={{raw}},prefix=${{ matrix.framework }}-py${{ matrix.python }}- - # the rest - type=sha,prefix=${{ matrix.framework }}-py${{ matrix.python }}- - name: Build and push Docker image (latest) uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 From 7ab34b92d020f8d0909e04d4aa6aa3e815d2e92b Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Wed, 27 Sep 2023 16:14:41 +0200 Subject: [PATCH 17/26] Fix Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 46392c36d8..07313201c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -63,4 +63,4 @@ ENV PATH=/opt/python/bin:$PATH ARG FRAMEWORK=tf ARG DOCTR_VERSION=main RUN pip3 install -U pip setuptools wheel && \ - pip3 install --no-cache-dir "doctr[$FRAMEWORK]@git+https://github.com/mindee/doctr.git@main" + pip3 install --no-cache-dir "python-doctr[$FRAMEWORK]@git+https://github.com/mindee/doctr.git@$DOCTR_VERSION" From 85375248c08ced95a6813298482678f3bf3c6a0f Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Wed, 27 Sep 2023 16:14:49 +0200 Subject: [PATCH 18/26] Update `README.md` --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ea5ec082d7..6f4ed4c223 100644 --- a/README.md +++ b/README.md @@ -260,10 +260,48 @@ Check out our [TensorFlow.js demo](https://github.com/mindee/doctr-tfjs-demo) to ### Docker container -If you wish to deploy containerized environments, you can use the provided Dockerfile to build a docker image: +[We offers Docker container support for easy testing and deployment](https://github.com/mindee/doctr/packages). + +#### Using GPU with docTR Docker Images + +The docTR Docker images are GPU-ready and based on CUDA `11.8`. +However, to use GPU support with these Docker images, please ensure that Docker is configured to use your GPU. + +To verify and configure GPU support for Docker, please follow the instructions provided in the [NVIDIA Container Toolkit Installation Guide](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html). + +Once Docker is configured to use GPUs, you can run docTR Docker containers with GPU support: + +```shell +docker run --it --gpus all ghcr.io/mindee/doctr:tf-py3.8.18-v0.7.1 bash +``` + +#### Available Tags + +The Docker images for docTR follow a specific tag nomenclature: `-py-`. Here's a breakdown of the tag structure: + +- ``: Can be `tf` (TensorFlow) or `torch` (PyTorch). +- ``: Can be `3.8.18`, `3.9.18`, or `3.10.13`. +- ``: Can be a tag (e.g., `v0.7.1`) + +Here are examples of different image tags: + +| Tag | Description | +|----------------------------|---------------------------------------------------| +| `tf-py3.8.18-v0.7.1` | TensorFlow version `3.8.18` with docTR `v0.7.1`. | +| `torch-py3.9.18-2023-10-01`| PyTorch version `3.9.18` with a weekly build from `2023-10-01`. | + +#### Building Docker Images Locally + +You can also build docTR Docker images locally on your computer. + +```shell +docker build -t doctr . +``` + +You can specify custom Python versions and docTR versions using build arguments. For example, to build a docTR image with TensorFlow, Python version `3.9.10`, and docTR version `v0.7.0`, run the following command: ```shell -docker build . -t +docker build -t doctr --build-arg FRAMEWORK=tf --build-arg PYTHON_VERSION=3.9.10 --build-arg DOCTR_VERSION=v0.7.0 . ``` ### Example script From 437167bbfe86c4f2b6aede7ea58eed573598b4f9 Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Wed, 27 Sep 2023 16:32:15 +0200 Subject: [PATCH 19/26] Add Docker Badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f4ed4c223..7c903eaf3f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

-[![Slack Icon](https://img.shields.io/badge/Slack-Community-4A154B?style=flat-square&logo=slack&logoColor=white)](https://slack.mindee.com) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE) ![Build Status](https://github.com/mindee/doctr/workflows/builds/badge.svg) [![codecov](https://codecov.io/gh/mindee/doctr/branch/main/graph/badge.svg?token=577MO567NM)](https://codecov.io/gh/mindee/doctr) [![CodeFactor](https://www.codefactor.io/repository/github/mindee/doctr/badge?s=bae07db86bb079ce9d6542315b8c6e70fa708a7e)](https://www.codefactor.io/repository/github/mindee/doctr) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/340a76749b634586a498e1c0ab998f08)](https://app.codacy.com/gh/mindee/doctr?utm_source=github.com&utm_medium=referral&utm_content=mindee/doctr&utm_campaign=Badge_Grade) [![Doc Status](https://github.com/mindee/doctr/workflows/doc-status/badge.svg)](https://mindee.github.io/doctr) [![Pypi](https://img.shields.io/badge/pypi-v0.7.0-blue.svg)](https://pypi.org/project/python-doctr/) [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/mindee/doctr) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mindee/notebooks/blob/main/doctr/quicktour.ipynb) +[![Slack Icon](https://img.shields.io/badge/Slack-Community-4A154B?style=flat-square&logo=slack&logoColor=white)](https://slack.mindee.com) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE) ![Build Status](https://github.com/mindee/doctr/workflows/builds/badge.svg) [![Docker Images](https://img.shields.io/badge/Docker-4287f5?style=flat&logo=docker&logoColor=white)](https://github.com/mindee.doctr/packages) [![codecov](https://codecov.io/gh/mindee/doctr/branch/main/graph/badge.svg?token=577MO567NM)](https://codecov.io/gh/mindee/doctr) [![CodeFactor](https://www.codefactor.io/repository/github/mindee/doctr/badge?s=bae07db86bb079ce9d6542315b8c6e70fa708a7e)](https://www.codefactor.io/repository/github/mindee/doctr) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/340a76749b634586a498e1c0ab998f08)](https://app.codacy.com/gh/mindee/doctr?utm_source=github.com&utm_medium=referral&utm_content=mindee/doctr&utm_campaign=Badge_Grade) [![Doc Status](https://github.com/mindee/doctr/workflows/doc-status/badge.svg)](https://mindee.github.io/doctr) [![Pypi](https://img.shields.io/badge/pypi-v0.7.0-blue.svg)](https://pypi.org/project/python-doctr/) [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/mindee/doctr) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mindee/notebooks/blob/main/doctr/quicktour.ipynb) **Optical Character Recognition made seamless & accessible to anyone, powered by TensorFlow 2 & PyTorch** From 947144a17ac16a3e6947d12af1eb86e39bb951d7 Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Wed, 27 Sep 2023 18:38:01 +0200 Subject: [PATCH 20/26] Add support for cpu/gpu + check if doctr can be imported --- .github/workflows/public_docker_images.yml | 26 ++++++++++++++++++---- Dockerfile | 13 ++++++++--- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/.github/workflows/public_docker_images.yml b/.github/workflows/public_docker_images.yml index 99c208afd1..17bcda5ff0 100644 --- a/.github/workflows/public_docker_images.yml +++ b/.github/workflows/public_docker_images.yml @@ -26,6 +26,7 @@ jobs: # Must match version at https://www.python.org/ftp/python/ python: ["3.8.18", "3.9.18", "3.10.13"] framework: ["tf", "torch"] + system: ["cpu", "gpu"] # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. permissions: @@ -50,19 +51,36 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | # used on schedule event - type=schedule,pattern={{date 'YYYY-MM-DD'}},prefix=${{ matrix.framework }}-py${{ matrix.python }}- + type=schedule,pattern={{date 'YYYY-MM-DD'}},prefix=${{ matrix.framework }}-py${{ matrix.python }}-${{ matrix.system }}- # set latest tag only if `enable` is True - type=raw,value=latest,enable=${{ matrix.framework == 'tf' && matrix.python == '3.8.18' && github.ref == format('refs/heads/{0}', 'main') }} + type=raw,value=latest,enable=${{ matrix.framework == 'tf' && matrix.python == '3.8.18' && matrix.system == 'gpu' && github.ref == format('refs/heads/{0}', 'main') }} # used on push tag event - type=semver,pattern={{raw}},prefix=${{ matrix.framework }}-py${{ matrix.python }}- + type=semver,pattern={{raw}},prefix=${{ matrix.framework }}-py${{ matrix.python }}-${{ matrix.system }}- - - name: Build and push Docker image (latest) + - name: Build Docker image + id: build uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: context: . build-args: | FRAMEWORK=${{ matrix.framework }} PYTHON_VERSION=${{ matrix.python }} + SYSTEM=${{ matrix.system }} + DOCTR_VERSION=${{ github.sha }} + push: false + tags: ${{ steps.meta.outputs.tags }} + + - name: Check if `import doctr` works + run: docker run ${{ steps.meta.outputs.imageid }} python3 -c 'import doctr' + + - name: Push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + build-args: | + FRAMEWORK=${{ matrix.framework }} + PYTHON_VERSION=${{ matrix.python }} + SYSTEM=${{ matrix.system }} DOCTR_VERSION=${{ github.sha }} push: false # TODO: CHANGE ME tags: ${{ steps.meta.outputs.tags }} diff --git a/Dockerfile b/Dockerfile index 07313201c9..babccdeee7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,12 @@ -FROM nvidia/cuda:11.8.0-base-ubuntu22.04 as base +ARG SYSTEM=cpu ENV DEBIAN_FRONTEND=noninteractive ENV LANG=C.UTF-8 ENV PYTHONUNBUFFERED=1 ENV PYTHONDONTWRITEBYTECODE=1 +FROM nvidia/cuda:11.8.0-base-ubuntu22.04 as gpu + # Enroll NVIDIA GPG public key RUN apt-get update && \ apt-get install -y gnupg ca-certificates wget && \ @@ -30,8 +32,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ # - CuDNN: https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#ubuntu-network-installation libcudnn8=8.6.0.163-1+cuda11.8 \ libnvinfer-plugin8=8.6.1.6-1+cuda11.8 \ - libnvinfer8=8.6.1.6-1+cuda11.8 \ - # - Other packages + libnvinfer8=8.6.1.6-1+cuda11.8 + +FROM ubuntu:22.04 as cpu + +FROM $SYSTEM + +RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ pkg-config \ curl \ From 0ffaf7a3376b7cc001c973a2a6bf8af7168a74c7 Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Wed, 27 Sep 2023 18:40:05 +0200 Subject: [PATCH 21/26] Update Dockerfile --- Dockerfile | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index babccdeee7..2382d86da8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,21 @@ -ARG SYSTEM=cpu +FROM ubuntu:22.04 ENV DEBIAN_FRONTEND=noninteractive ENV LANG=C.UTF-8 ENV PYTHONUNBUFFERED=1 ENV PYTHONDONTWRITEBYTECODE=1 -FROM nvidia/cuda:11.8.0-base-ubuntu22.04 as gpu +ARG SYSTEM=gpu -# Enroll NVIDIA GPG public key -RUN apt-get update && \ +# Enroll NVIDIA GPG public key and install CUDA +RUN if [ "$SYSTEM" = "gpu" ]; then \ + apt-get update && \ apt-get install -y gnupg ca-certificates wget && \ # - Install Nvidia repo keys # - See: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#network-repo-installation-for-ubuntu wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \ - dpkg -i cuda-keyring_1.1-1_all.deb - -# Install CUDA -RUN apt-get update && apt-get install -y --no-install-recommends \ + dpkg -i cuda-keyring_1.1-1_all.deb && \ + apt-get update && apt-get install -y --no-install-recommends \ cuda-command-line-tools-11-8 \ cuda-cudart-dev-11-8 \ cuda-nvcc-11-8 \ @@ -32,26 +31,25 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ # - CuDNN: https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#ubuntu-network-installation libcudnn8=8.6.0.163-1+cuda11.8 \ libnvinfer-plugin8=8.6.1.6-1+cuda11.8 \ - libnvinfer8=8.6.1.6-1+cuda11.8 - -FROM ubuntu:22.04 as cpu - -FROM $SYSTEM + libnvinfer8=8.6.1.6-1+cuda11.8; \ +fi RUN apt-get update && apt-get install -y --no-install-recommends \ + # - Other packages build-essential \ pkg-config \ curl \ + wget \ software-properties-common \ unzip \ git \ # - Packages to build Python tar make gcc zlib1g-dev libffi-dev libssl-dev \ # - Packages for docTR - ffmpeg libsm6 libxext6 \ + libgl1-mesa-dev libsm6 libxext6 libxrender-dev libpangocairo-1.0-0 \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* -################ + && rm -rf /var/lib/apt/lists/* \ +fi # Install Python ARG PYTHON_VERSION=3.10.13 @@ -70,4 +68,4 @@ ENV PATH=/opt/python/bin:$PATH ARG FRAMEWORK=tf ARG DOCTR_VERSION=main RUN pip3 install -U pip setuptools wheel && \ - pip3 install --no-cache-dir "python-doctr[$FRAMEWORK]@git+https://github.com/mindee/doctr.git@$DOCTR_VERSION" + pip3 install "python-doctr[$FRAMEWORK]@git+https://github.com/mindee/doctr.git@$DOCTR_VERSION" From 12aa2ce7007b8c1af12b79bc4b0fd141bba87973 Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Thu, 28 Sep 2023 11:48:19 +0200 Subject: [PATCH 22/26] Few improvements --- .github/workflows/public_docker_images.yml | 16 ++++++++++------ Dockerfile | 3 ++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/public_docker_images.yml b/.github/workflows/public_docker_images.yml index 17bcda5ff0..8fb8e8866c 100644 --- a/.github/workflows/public_docker_images.yml +++ b/.github/workflows/public_docker_images.yml @@ -14,7 +14,6 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} jobs: build-and-push-image: @@ -48,13 +47,14 @@ jobs: id: meta uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ${{ env.REGISTRY }}/${{ github.repository }} tags: | - # used on schedule event + # used only on schedule event type=schedule,pattern={{date 'YYYY-MM-DD'}},prefix=${{ matrix.framework }}-py${{ matrix.python }}-${{ matrix.system }}- # set latest tag only if `enable` is True + # see https://github.com/docker/metadata-action#latest-tag type=raw,value=latest,enable=${{ matrix.framework == 'tf' && matrix.python == '3.8.18' && matrix.system == 'gpu' && github.ref == format('refs/heads/{0}', 'main') }} - # used on push tag event + # used only if a tag following semver is published type=semver,pattern={{raw}},prefix=${{ matrix.framework }}-py${{ matrix.python }}-${{ matrix.system }}- - name: Build Docker image @@ -66,14 +66,17 @@ jobs: FRAMEWORK=${{ matrix.framework }} PYTHON_VERSION=${{ matrix.python }} SYSTEM=${{ matrix.system }} + DOCTR_REPO=${{ github.repository }} DOCTR_VERSION=${{ github.sha }} - push: false + push: false # push only if `import doctr` works tags: ${{ steps.meta.outputs.tags }} - name: Check if `import doctr` works - run: docker run ${{ steps.meta.outputs.imageid }} python3 -c 'import doctr' + run: docker run ${{ steps.build.outputs.imageid }} python3 -c 'import doctr' - name: Push Docker image + # Push only if the CI is not triggered by "PR on main" + if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: context: . @@ -81,6 +84,7 @@ jobs: FRAMEWORK=${{ matrix.framework }} PYTHON_VERSION=${{ matrix.python }} SYSTEM=${{ matrix.system }} + DOCTR_REPO=${{ github.repository }} DOCTR_VERSION=${{ github.sha }} push: false # TODO: CHANGE ME tags: ${{ steps.meta.outputs.tags }} diff --git a/Dockerfile b/Dockerfile index 2382d86da8..d0243d2a1e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -66,6 +66,7 @@ ENV PATH=/opt/python/bin:$PATH # Install docTR ARG FRAMEWORK=tf +ARG DOCTR_REPO='mindee/doctr' ARG DOCTR_VERSION=main RUN pip3 install -U pip setuptools wheel && \ - pip3 install "python-doctr[$FRAMEWORK]@git+https://github.com/mindee/doctr.git@$DOCTR_VERSION" + pip3 install "python-doctr[$FRAMEWORK]@git+https://github.com/$DOCTR_REPO.git@$DOCTR_VERSION" From 162748cdb42cf34697b920fd9d21ec51b9c8789c Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Thu, 28 Sep 2023 12:05:22 +0200 Subject: [PATCH 23/26] Missing lib + monthly --- .github/workflows/public_docker_images.yml | 2 +- Dockerfile | 2 +- README.md | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/public_docker_images.yml b/.github/workflows/public_docker_images.yml index 8fb8e8866c..77c5b4c12b 100644 --- a/.github/workflows/public_docker_images.yml +++ b/.github/workflows/public_docker_images.yml @@ -50,7 +50,7 @@ jobs: images: ${{ env.REGISTRY }}/${{ github.repository }} tags: | # used only on schedule event - type=schedule,pattern={{date 'YYYY-MM-DD'}},prefix=${{ matrix.framework }}-py${{ matrix.python }}-${{ matrix.system }}- + type=schedule,pattern={{date 'YYYY-MM'}},prefix=${{ matrix.framework }}-py${{ matrix.python }}-${{ matrix.system }}- # set latest tag only if `enable` is True # see https://github.com/docker/metadata-action#latest-tag type=raw,value=latest,enable=${{ matrix.framework == 'tf' && matrix.python == '3.8.18' && matrix.system == 'gpu' && github.ref == format('refs/heads/{0}', 'main') }} diff --git a/Dockerfile b/Dockerfile index d0243d2a1e..ef8b615518 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,7 +46,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ # - Packages to build Python tar make gcc zlib1g-dev libffi-dev libssl-dev \ # - Packages for docTR - libgl1-mesa-dev libsm6 libxext6 libxrender-dev libpangocairo-1.0-0 \ + libgl1-mesa-dev libsm6 libxext6 libxrender-dev libpangocairo-1.0-0 libbz2-dev \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* \ fi diff --git a/README.md b/README.md index 7c903eaf3f..912c14d52a 100644 --- a/README.md +++ b/README.md @@ -277,18 +277,19 @@ docker run --it --gpus all ghcr.io/mindee/doctr:tf-py3.8.18-v0.7.1 bash #### Available Tags -The Docker images for docTR follow a specific tag nomenclature: `-py-`. Here's a breakdown of the tag structure: +The Docker images for docTR follow a specific tag nomenclature: `-py-`. Here's a breakdown of the tag structure: -- ``: Can be `tf` (TensorFlow) or `torch` (PyTorch). -- ``: Can be `3.8.18`, `3.9.18`, or `3.10.13`. -- ``: Can be a tag (e.g., `v0.7.1`) +- ``: `tf` (TensorFlow) or `torch` (PyTorch). +- ``: `3.8.18`, `3.9.18`, or `3.10.13`. +- ``: a tag >= `v0.7.1` +- ``: e.g. `2023-10` Here are examples of different image tags: | Tag | Description | |----------------------------|---------------------------------------------------| | `tf-py3.8.18-v0.7.1` | TensorFlow version `3.8.18` with docTR `v0.7.1`. | -| `torch-py3.9.18-2023-10-01`| PyTorch version `3.9.18` with a weekly build from `2023-10-01`. | +| `torch-py3.9.18-2023-10`| PyTorch version `3.9.18` with a monthly build from `2023-10`. | #### Building Docker Images Locally From 43e7cc52077c478747a284b6b4fccec5b6a6d374 Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Thu, 28 Sep 2023 12:34:37 +0200 Subject: [PATCH 24/26] Fix dep issue --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ef8b615518..dfde03233f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,9 +44,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ unzip \ git \ # - Packages to build Python - tar make gcc zlib1g-dev libffi-dev libssl-dev \ + tar make gcc zlib1g-dev libffi-dev libssl-dev liblzma-dev libbz2-dev \ # - Packages for docTR - libgl1-mesa-dev libsm6 libxext6 libxrender-dev libpangocairo-1.0-0 libbz2-dev \ + libgl1-mesa-dev libsm6 libxext6 libxrender-dev libpangocairo-1.0-0 \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* \ fi From 2849b6c545941cb005447fe7dc85667f7204510c Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Thu, 28 Sep 2023 15:26:56 +0200 Subject: [PATCH 25/26] Address last pr comments --- .github/workflows/public_docker_images.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/public_docker_images.yml b/.github/workflows/public_docker_images.yml index 77c5b4c12b..f31e5a2539 100644 --- a/.github/workflows/public_docker_images.yml +++ b/.github/workflows/public_docker_images.yml @@ -4,13 +4,12 @@ name: Docker image on ghcr.io on: push: - branches: main tags: - 'v*' pull_request: branches: main schedule: - - cron: '0 2 1 * *' # At 02:00 on day-of-month 1 + - cron: '0 2 29 * *' # At 02:00 on day-of-month 29 env: REGISTRY: ghcr.io @@ -86,5 +85,5 @@ jobs: SYSTEM=${{ matrix.system }} DOCTR_REPO=${{ github.repository }} DOCTR_VERSION=${{ github.sha }} - push: false # TODO: CHANGE ME + push: true tags: ${{ steps.meta.outputs.tags }} From 9f7c6496c63fb47331b861e94edc4525e1c8bc4d Mon Sep 17 00:00:00 2001 From: Olivier Dulcy Date: Thu, 28 Sep 2023 15:47:18 +0200 Subject: [PATCH 26/26] `cpu` flag for CI + remove `latest` tag + update README.md --- .github/workflows/docker.yml | 2 +- .github/workflows/public_docker_images.yml | 3 --- README.md | 11 ++++++----- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 70507e4d05..6ece3f59a8 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Build docker image - run: docker build . -t doctr-tf-py3.8-slim + run: docker build -t doctr-tf-py3.8-slim --build-arg SYSTEM=cpu . - name: Run docker container run: docker run doctr-tf-py3.8-slim python3 -c 'import doctr' diff --git a/.github/workflows/public_docker_images.yml b/.github/workflows/public_docker_images.yml index f31e5a2539..de77d1a265 100644 --- a/.github/workflows/public_docker_images.yml +++ b/.github/workflows/public_docker_images.yml @@ -50,9 +50,6 @@ jobs: tags: | # used only on schedule event type=schedule,pattern={{date 'YYYY-MM'}},prefix=${{ matrix.framework }}-py${{ matrix.python }}-${{ matrix.system }}- - # set latest tag only if `enable` is True - # see https://github.com/docker/metadata-action#latest-tag - type=raw,value=latest,enable=${{ matrix.framework == 'tf' && matrix.python == '3.8.18' && matrix.system == 'gpu' && github.ref == format('refs/heads/{0}', 'main') }} # used only if a tag following semver is published type=semver,pattern={{raw}},prefix=${{ matrix.framework }}-py${{ matrix.python }}-${{ matrix.system }}- diff --git a/README.md b/README.md index 912c14d52a..940c4a4a8b 100644 --- a/README.md +++ b/README.md @@ -272,24 +272,25 @@ To verify and configure GPU support for Docker, please follow the instructions p Once Docker is configured to use GPUs, you can run docTR Docker containers with GPU support: ```shell -docker run --it --gpus all ghcr.io/mindee/doctr:tf-py3.8.18-v0.7.1 bash +docker run --it --gpus all ghcr.io/mindee/doctr:tf-py3.8.18-gpu-2023-09 bash ``` #### Available Tags -The Docker images for docTR follow a specific tag nomenclature: `-py-`. Here's a breakdown of the tag structure: +The Docker images for docTR follow a specific tag nomenclature: `-py--`. Here's a breakdown of the tag structure: - ``: `tf` (TensorFlow) or `torch` (PyTorch). - ``: `3.8.18`, `3.9.18`, or `3.10.13`. +- ``: `cpu` or `gpu` - ``: a tag >= `v0.7.1` -- ``: e.g. `2023-10` +- ``: e.g. `2023-09` Here are examples of different image tags: | Tag | Description | |----------------------------|---------------------------------------------------| -| `tf-py3.8.18-v0.7.1` | TensorFlow version `3.8.18` with docTR `v0.7.1`. | -| `torch-py3.9.18-2023-10`| PyTorch version `3.9.18` with a monthly build from `2023-10`. | +| `tf-py3.8.18-cpu-v0.7.1` | TensorFlow version `3.8.18` with docTR `v0.7.1`. | +| `torch-py3.9.18-gpu-2023-09`| PyTorch version `3.9.18` with GPU support and a monthly build from `2023-09`. | #### Building Docker Images Locally