From d0a19dbc222e2972aedd88686e4aef6148bb9e1e Mon Sep 17 00:00:00 2001 From: Pandede Date: Mon, 29 Jan 2024 17:57:07 +0800 Subject: [PATCH 1/3] remove job `github-release` --- .github/workflows/cd.yaml | 43 --------------------------------------- 1 file changed, 43 deletions(-) diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index c3ec76a..c531318 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -51,46 +51,3 @@ jobs: path: dist/ - name: Publish distribution to PyPI uses: pypa/gh-action-pypi-publish@release/v1 - - github-release: - name: >- - Sign the Python distribution with Sigstore - and upload them to GitHub Release - needs: - - publish-to-pypi - runs-on: ubuntu-latest - - permissions: - contents: write # IMPORTANT: mandatory for making GitHub Releases - id-token: write # IMPORTANT: mandatory for sigstore - - steps: - - name: Download all the dists - uses: actions/download-artifact@v3 - with: - name: python-package-distributions - path: dist/ - - name: Sign the dists with Sigstore - uses: sigstore/gh-action-sigstore-python@v1.2.3 - with: - inputs: >- - ./dist/*.tar.gz - ./dist/*.whl - - name: Create GitHub Release - env: - GITHUB_TOKEN: ${{ github.token }} - run: >- - gh release create - '${{ github.ref_name }}' - --repo '${{ github.repository }}' - --notes "" - - name: Upload artifact signatures to GitHub Release - env: - GITHUB_TOKEN: ${{ github.token }} - # Upload to GitHub Release using the `gh` CLI. - # `dist/` contains the built packages, and the - # sigstore-produced signatures and certificates. - run: >- - gh release upload - '${{ github.ref_name }}' dist/** - --repo '${{ github.repository }}' From 39dcb0c834bb914eb1d5ca5aa77106ea68da934e Mon Sep 17 00:00:00 2001 From: Pandede Date: Wed, 10 Apr 2024 17:06:54 +0800 Subject: [PATCH 2/3] fix giant factor if image ratio is too large --- wpodnet/backend.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpodnet/backend.py b/wpodnet/backend.py index c28479c..273614b 100644 --- a/wpodnet/backend.py +++ b/wpodnet/backend.py @@ -58,7 +58,7 @@ def _resize_to_fixed_ratio(self, image: Image.Image, dim_min: int, dim_max: int) side = int(wh_ratio * dim_min) bound_dim = min(side + side % self._stride, dim_max) - factor = bound_dim / min(h, w) + factor = bound_dim / max(h, w) reg_w, reg_h = int(w * factor), int(h * factor) # Ensure the both width and height are the multiply of `self._stride` From 359cd1e0ec7cd947836f7604a226f541ce37015c Mon Sep 17 00:00:00 2001 From: Pandede Date: Wed, 10 Apr 2024 17:11:02 +0800 Subject: [PATCH 3/3] keep `reg_w` and `reg_h` unchange if it's already multiply of strides --- wpodnet/backend.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wpodnet/backend.py b/wpodnet/backend.py index 273614b..c251944 100644 --- a/wpodnet/backend.py +++ b/wpodnet/backend.py @@ -62,8 +62,13 @@ def _resize_to_fixed_ratio(self, image: Image.Image, dim_min: int, dim_max: int) reg_w, reg_h = int(w * factor), int(h * factor) # Ensure the both width and height are the multiply of `self._stride` - reg_w += self._stride - reg_w % self._stride - reg_h += self._stride - reg_h % self._stride + reg_w_mod = reg_w % self._stride + if reg_w_mod > 0: + reg_w += self._stride - reg_w_mod + + reg_h_mod = reg_h % self._stride + if reg_h_mod > 0: + reg_h += self._stride - reg_h % self._stride return image.resize((reg_w, reg_h))