diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 56e454f..a684ed2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,11 +15,13 @@ concurrency: jobs: release: - name: Create GitHub Release & Build Image + name: Create GitHub Release runs-on: ubuntu-latest permissions: contents: write - packages: write + outputs: + tag: ${{ steps.tag.outputs.TAG }} + version: ${{ steps.tag.outputs.VERSION }} steps: - name: Free up disk space run: | @@ -60,12 +62,6 @@ jobs: uv lock rm _pyproject_orig.toml - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v4 - - name: Resolve tag name id: tag run: | @@ -131,6 +127,30 @@ jobs: prerelease: false, }); + build-gpu: + name: Build GPU image + needs: release + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Free up disk space + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + echo "Disk space freed." + + - name: Checkout + uses: actions/checkout@v6 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4 + - name: Log in to GHCR uses: docker/login-action@v4 with: @@ -145,12 +165,43 @@ jobs: file: ./Dockerfile platforms: linux/amd64,linux/arm64 push: true - build-args: VERSION=${{ steps.tag.outputs.VERSION }} + build-args: VERSION=${{ needs.release.outputs.version }} cache-from: type=gha,scope=release-gpu cache-to: type=gha,mode=max,scope=release-gpu tags: | ghcr.io/sudolulo/winnow:latest - ghcr.io/sudolulo/winnow:${{ steps.tag.outputs.TAG }} + ghcr.io/sudolulo/winnow:${{ needs.release.outputs.tag }} + + build-cpu: + name: Build CPU image + needs: release + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Free up disk space + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + echo "Disk space freed." + + - name: Checkout + uses: actions/checkout@v6 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4 + + - name: Log in to GHCR + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push CPU image uses: docker/build-push-action@v6 @@ -161,12 +212,43 @@ jobs: push: true build-args: | VARIANT=cpu - VERSION=${{ steps.tag.outputs.VERSION }} + VERSION=${{ needs.release.outputs.version }} cache-from: type=gha,scope=release-cpu cache-to: type=gha,mode=max,scope=release-cpu tags: | ghcr.io/sudolulo/winnow:cpu - ghcr.io/sudolulo/winnow:${{ steps.tag.outputs.TAG }}-cpu + ghcr.io/sudolulo/winnow:${{ needs.release.outputs.tag }}-cpu + + build-rocm: + name: Build ROCm image + needs: release + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Free up disk space + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + echo "Disk space freed." + + - name: Checkout + uses: actions/checkout@v6 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4 + + - name: Log in to GHCR + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push ROCm image uses: docker/build-push-action@v6 @@ -177,12 +259,43 @@ jobs: push: true build-args: | VARIANT=rocm - VERSION=${{ steps.tag.outputs.VERSION }} + VERSION=${{ needs.release.outputs.version }} cache-from: type=gha,scope=release-rocm cache-to: type=gha,mode=max,scope=release-rocm tags: | ghcr.io/sudolulo/winnow:rocm - ghcr.io/sudolulo/winnow:${{ steps.tag.outputs.TAG }}-rocm + ghcr.io/sudolulo/winnow:${{ needs.release.outputs.tag }}-rocm + + build-intel: + name: Build Intel image + needs: release + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Free up disk space + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + echo "Disk space freed." + + - name: Checkout + uses: actions/checkout@v6 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4 + + - name: Log in to GHCR + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Intel image uses: docker/build-push-action@v6 @@ -193,9 +306,9 @@ jobs: push: true build-args: | VARIANT=intel - VERSION=${{ steps.tag.outputs.VERSION }} + VERSION=${{ needs.release.outputs.version }} cache-from: type=gha,scope=release-intel cache-to: type=gha,mode=max,scope=release-intel tags: | ghcr.io/sudolulo/winnow:intel - ghcr.io/sudolulo/winnow:${{ steps.tag.outputs.TAG }}-intel + ghcr.io/sudolulo/winnow:${{ needs.release.outputs.tag }}-intel diff --git a/.github/workflows/update-lockfile.yml b/.github/workflows/update-lockfile.yml index b557522..b677152 100644 --- a/.github/workflows/update-lockfile.yml +++ b/.github/workflows/update-lockfile.yml @@ -3,6 +3,8 @@ name: Update lockfiles on: push: + branches: + - '**' paths: - 'pyproject.toml' - 'pyproject-cpu.toml' diff --git a/winnow/quality.py b/winnow/quality.py index 4ccc2d4..8db3ac7 100644 --- a/winnow/quality.py +++ b/winnow/quality.py @@ -119,7 +119,10 @@ def assess_quality( blur_score = float(cv2.Laplacian(gray, cv2.CV_64F).var()) checks = [ - (blur_score >= blur_threshold, f"Blurry (laplacian={blur_score:.1f}, threshold={blur_threshold})" if blur_score < blur_threshold else ""), + ( + blur_score >= blur_threshold, + f"Blurry (laplacian={blur_score:.1f}, threshold={blur_threshold})" if blur_score < blur_threshold else "", + ), check_grayscale(img_np), check_exposure(img_np), check_confidence(confidence, min_confidence),