From b75b1aa1dd65958a152af08cddcfc788984df3c9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 7 Jun 2025 12:14:41 +0900 Subject: [PATCH 01/10] [pre-commit.ci] pre-commit autoupdate (#785) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- aaaaaa/traceback.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0413861..8a048d0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.9.9 + rev: v0.11.12 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/aaaaaa/traceback.py b/aaaaaa/traceback.py index 85631e3..4119a9b 100644 --- a/aaaaaa/traceback.py +++ b/aaaaaa/traceback.py @@ -1,4 +1,4 @@ -from __future__ import annotations # noqa: A005 +from __future__ import annotations import io import platform From e41ee473c82a2f050efc3ed37413fd0df979345c Mon Sep 17 00:00:00 2001 From: Dowon Date: Sat, 7 Jun 2025 12:20:55 +0900 Subject: [PATCH 02/10] chore(ci): update workflows --- .github/workflows/pypi.yml | 4 +++- .github/workflows/test.yml | 5 +++-- .vscode/extensions.json | 1 - 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index b98eee8..8e774b4 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -3,6 +3,7 @@ on: push: tags: - "v*" + workflow_dispatch: jobs: test: @@ -18,9 +19,10 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v6 - name: Build wheel - run: pipx run build + run: uv build - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7383ad6..4bf1644 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,6 +13,7 @@ jobs: name: Test on python ${{ matrix.python-version }} runs-on: macos-latest strategy: + fail-fast: false matrix: python-version: - "3.10" @@ -22,9 +23,9 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: astral-sh/setup-uv@v5 + - uses: astral-sh/setup-uv@v6 with: python-version: ${{ matrix.python-version }} - name: Run tests - run: uv run --all-extras pytest -v + run: uv run --all-extras --with 'git+https://github.com/ultralytics/CLIP.git' pytest -v diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 5284a0f..1a81507 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,7 +1,6 @@ { "recommendations": [ "ms-python.vscode-pylance", - "ms-python.black-formatter", "kevinrose.vsc-python-indent", "charliermarsh.ruff", "shardulm94.trailing-spaces" From fcb15331c7b0b34d116f6f4dec2827b34d110823 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 14 Dec 2025 10:13:56 +0900 Subject: [PATCH 03/10] [pre-commit.ci] pre-commit autoupdate (#799) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 6 +++--- CHANGELOG.md | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8a048d0..61208b7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ exclude: ^modules/ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: check-added-large-files args: [--maxkb=100] @@ -19,12 +19,12 @@ repos: - id: mixed-line-ending - repo: https://github.com/rbubley/mirrors-prettier - rev: v3.5.3 + rev: v3.8.1 hooks: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.12 + rev: v0.15.0 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/CHANGELOG.md b/CHANGELOG.md index a805d31..c16df6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -121,7 +121,6 @@ - YOLO World 모델 추가: 가장 큰 yolov8x-world.pt 모델만 기본적으로 선택할 수 있게 함. - lllyasviel/stable-diffusion-webui-forge에서 컨트롤넷을 사용가능하게 함 (PR #517) - 기본 스크립트 목록에 soft_inpainting 추가 (https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/14208) - - 기존에 설치한 사람에게 소급적용되지는 않음 - 감지모델에 대한 간단한 pytest 추가함 @@ -348,7 +347,6 @@ - `ad_inpaint_full_res` → `ad_inpaint_only_masked` - `ad_inpaint_full_res_padding` → `ad_inpaint_only_masked_padding` - mediapipe face mesh 모델 추가 - - mediapipe 최소 버전 `0.10.0` - rich traceback 제거함 From 902a3d6445a9389e08018e9dab3d7431204767b1 Mon Sep 17 00:00:00 2001 From: Dowon Date: Thu, 5 Feb 2026 08:23:35 +0900 Subject: [PATCH 04/10] chore: change toml formattor --- .pre-commit-config.yaml | 2 +- pyproject.toml | 79 +++++++++++++++++++++-------------------- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 61208b7..672695b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,6 +26,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.15.0 hooks: - - id: ruff + - id: ruff-check args: [--fix, --exit-non-zero-on-fix] - id: ruff-format diff --git a/pyproject.toml b/pyproject.toml index f1be122..e38dd36 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,26 +1,26 @@ [project] name = "adetailer" description = "An object detection and auto-mask extension for stable diffusion webui." -authors = [{ name = "dowon", email = "ks2515@naver.com" }] -requires-python = ">=3.9" readme = "README.md" +requires-python = ">=3.9" license = { text = "AGPL-3.0" } -dependencies = [ - "ultralytics>=8.2", - "mediapipe>=0.10.13", - "pydantic<3", - "rich>=13", - "huggingface_hub", -] +authors = [{ name = "dowon", email = "ks2515@naver.com" }] keywords = [ - "stable-diffusion", - "stable-diffusion-webui", - "adetailer", - "ultralytics", + "adetailer", + "stable-diffusion", + "stable-diffusion-webui", + "ultralytics", ] classifiers = [ - "License :: OSI Approved :: GNU Affero General Public License v3", - "Topic :: Scientific/Engineering :: Image Recognition", + "License :: OSI Approved :: GNU Affero General Public License v3", + "Topic :: Scientific/Engineering :: Image Recognition", +] +dependencies = [ + "huggingface_hub", + "mediapipe>=0.10.13", + "pydantic<3", + "rich>=13", + "ultralytics>=8.2", ] dynamic = ["version"] @@ -48,30 +48,31 @@ extend-exclude = ["modules"] [tool.ruff.lint] select = [ - "A", - "B", - "C4", - "C90", - "E", - "EM", - "F", - "FA", - "I001", - "ISC", - "N", - "PD", - "PERF", - "PL", - "PIE", - "PT", - "PTH", - "RET", - "RUF", - "SIM", - "T20", - "TRY", - "UP", - "W", + "A", + "B", + "C4", + "C90", + "E", + "EM", + "F", + "FA", + "I001", + "ISC", + "N", + "PD", + "PERF", + "PL", + "PLC", + "PIE", + "PT", + "PTH", + "RET", + "RUF", + "SIM", + "T20", + "TRY", + "UP", + "W", ] ignore = ["B905", "E501", "PLR2004", "PLW0603"] unfixable = ["F401"] From c8c487a31e8ec9b356a7187a88423869662da485 Mon Sep 17 00:00:00 2001 From: Dowon Date: Thu, 5 Feb 2026 08:24:40 +0900 Subject: [PATCH 05/10] fix: Normalize mask input to float --- adetailer/ultralytics.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/adetailer/ultralytics.py b/adetailer/ultralytics.py index 7c7a1a7..c63af40 100644 --- a/adetailer/ultralytics.py +++ b/adetailer/ultralytics.py @@ -22,7 +22,7 @@ def ultralytics_predict( device: str = "", classes: str = "", ) -> PredictOutput[float]: - from ultralytics import YOLO + from ultralytics import YOLO # noqa: PLC0415 model = YOLO(model_path) apply_classes(model, model_path, classes) @@ -61,11 +61,12 @@ def mask_to_pil(masks: torch.Tensor, shape: tuple[int, int]) -> list[Image.Image """ Parameters ---------- - masks: torch.Tensor, dtype=torch.float32, shape=(N, H, W). - The device can be CUDA, but `to_pil_image` takes care of that. + masks: torch.Tensor, dtype=torch.float32 or torch.uint8, shape=(N, H, W). + uint8 tensor is expected to have values 0 or 1 (not 0-255). shape: tuple[int, int] (W, H) of the original image """ + masks = masks.float() n = masks.shape[0] return [to_pil_image(masks[i], mode="L").resize(shape) for i in range(n)] From 18d54cfc0c799dd2a984e9aa187bb9f8b3b9e0ca Mon Sep 17 00:00:00 2001 From: Dowon Date: Thu, 5 Feb 2026 19:56:23 +0900 Subject: [PATCH 06/10] test: mask_to_pil test --- tests/test_ultralytics.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/test_ultralytics.py b/tests/test_ultralytics.py index e75171d..6d62fa0 100644 --- a/tests/test_ultralytics.py +++ b/tests/test_ultralytics.py @@ -1,8 +1,10 @@ +import numpy as np import pytest +import torch from huggingface_hub import hf_hub_download from PIL import Image -from adetailer.ultralytics import ultralytics_predict +from adetailer.ultralytics import mask_to_pil, ultralytics_predict @pytest.mark.parametrize( @@ -60,3 +62,35 @@ def test_yolo_world(sample_image2: Image.Image, klass: str): assert len(result.masks) > 0 assert len(result.confidences) > 0 assert len(result.bboxes) == len(result.masks) == len(result.confidences) + + +class TestMaskToPil: + def test_mask_to_pil_float32(self): + mask = torch.tensor([[[0.0, 1.0], [0.0, 1.0]]], dtype=torch.float32) + imgs = mask_to_pil(mask, shape=(2, 2)) + + assert len(imgs) == 1 + img = imgs[0] + assert isinstance(img, Image.Image) + + arr = np.array(img) + assert arr.shape == (2, 2) + assert arr.dtype == np.uint8 + + expected = np.array([[0, 255], [0, 255]], dtype=np.uint8) + np.testing.assert_array_equal(arr, expected) + + def test_mask_to_pil_uint8(self): + mask = torch.tensor([[[0, 1], [0, 1]]], dtype=torch.uint8) + imgs = mask_to_pil(mask, shape=(2, 2)) + + assert len(imgs) == 1 + img = imgs[0] + assert isinstance(img, Image.Image) + + arr = np.array(img) + assert arr.shape == (2, 2) + assert arr.dtype == np.uint8 + + expected = np.array([[0, 255], [0, 255]], dtype=np.uint8) + np.testing.assert_array_equal(arr, expected) From 6a49e1a856a56b3e759f3d5deeaeeb4535e8ede4 Mon Sep 17 00:00:00 2001 From: Dowon Date: Thu, 5 Feb 2026 20:05:49 +0900 Subject: [PATCH 07/10] chore: Update versions and deps --- .github/workflows/pypi.yml | 4 ++-- .github/workflows/stale.yml | 2 +- .github/workflows/test.yml | 6 ++++-- install.py | 2 +- pyproject.toml | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 8e774b4..76884a0 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -18,8 +18,8 @@ jobs: needs: [test] steps: - - uses: actions/checkout@v4 - - uses: astral-sh/setup-uv@v6 + - uses: actions/checkout@v6 + - uses: astral-sh/setup-uv@v7 - name: Build wheel run: uv build diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 0f4fd9b..1e9dcd0 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -7,7 +7,7 @@ jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@v9 + - uses: actions/stale@v10 with: days-before-stale: 17 days-before-close: 3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4bf1644..aaf8632 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,11 +19,13 @@ jobs: - "3.10" - "3.11" - "3.12" + - "3.13" + - "3.14" steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - - uses: astral-sh/setup-uv@v6 + - uses: astral-sh/setup-uv@v7 with: python-version: ${{ matrix.python-version }} diff --git a/install.py b/install.py index d9c7a8a..2b5c531 100644 --- a/install.py +++ b/install.py @@ -47,7 +47,7 @@ def install(): deps = [ # requirements ("ultralytics", "8.3.75", None), - ("mediapipe", "0.10.13", "0.10.15"), + ("mediapipe", "0.10.13", None), ("rich", "13.0.0", None), ] diff --git a/pyproject.toml b/pyproject.toml index e38dd36..4f3e90b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ dynamic = ["version"] repository = "https://github.com/Bing-su/adetailer" [project.optional-dependencies] -dev = ["ruff", "pre-commit", "devtools"] +dev = ["devtools"] test = ["pytest", "hypothesis"] [build-system] From 2bbce2a6b131e54a5bf840a6c077eb2d6d0cee5d Mon Sep 17 00:00:00 2001 From: Dowon Date: Thu, 5 Feb 2026 20:07:02 +0900 Subject: [PATCH 08/10] ci: update test action --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aaf8632..15f8d67 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,9 @@ on: pull_request: paths: - "adetailer/**.py" + - ".github/workflows/test.yml" workflow_call: + workflow_dispatch: schedule: - cron: "0 0 * * 0" From 55bb8117a60027ac183de733e508cdb617a079af Mon Sep 17 00:00:00 2001 From: Dowon Date: Thu, 5 Feb 2026 20:10:30 +0900 Subject: [PATCH 09/10] v26.2.0 --- CHANGELOG.md | 5 +++++ adetailer/__version__.py | 2 +- pyproject.toml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c16df6a..cd6fc03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 2026-02-05 + +- v26.2.0 +- segmentation 모델의 마스크 dtype이 uint8로 변경된 것에 대응 + ## 2025-03-10 - v25.3.0 diff --git a/adetailer/__version__.py b/adetailer/__version__.py index d024107..744258c 100644 --- a/adetailer/__version__.py +++ b/adetailer/__version__.py @@ -1 +1 @@ -__version__ = "25.3.0" +__version__ = "26.2.0" diff --git a/pyproject.toml b/pyproject.toml index 4f3e90b..a801b07 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ classifiers = [ "Topic :: Scientific/Engineering :: Image Recognition", ] dependencies = [ - "huggingface_hub", + "huggingface-hub", "mediapipe>=0.10.13", "pydantic<3", "rich>=13", From 702fb41a7225d900e8f7e95944dc594ed2d9866a Mon Sep 17 00:00:00 2001 From: Dowon Date: Thu, 5 Feb 2026 20:19:04 +0900 Subject: [PATCH 10/10] style: ignore PLC0415 rule --- adetailer/ultralytics.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/adetailer/ultralytics.py b/adetailer/ultralytics.py index c63af40..1bd13ff 100644 --- a/adetailer/ultralytics.py +++ b/adetailer/ultralytics.py @@ -22,7 +22,7 @@ def ultralytics_predict( device: str = "", classes: str = "", ) -> PredictOutput[float]: - from ultralytics import YOLO # noqa: PLC0415 + from ultralytics import YOLO model = YOLO(model_path) apply_classes(model, model_path, classes) diff --git a/pyproject.toml b/pyproject.toml index a801b07..87fb281 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,7 +74,7 @@ select = [ "UP", "W", ] -ignore = ["B905", "E501", "PLR2004", "PLW0603"] +ignore = ["B905", "E501", "PLC0415", "PLR2004", "PLW0603"] unfixable = ["F401"] [tool.ruff.lint.isort]