diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b8be5e4..7383ad6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,16 +22,9 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v5 with: python-version: ${{ matrix.python-version }} - - uses: astral-sh/setup-uv@v3 - - - name: Install dependencies - run: | - uv pip install --system ".[test]" - - name: Run tests - run: pytest -v + run: uv run --all-extras pytest -v diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9979309..0413861 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,12 +19,12 @@ repos: - id: mixed-line-ending - repo: https://github.com/rbubley/mirrors-prettier - rev: v3.4.1 + rev: v3.5.3 hooks: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.1 + rev: v0.9.9 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/CHANGELOG.md b/CHANGELOG.md index 07d0f66..a805d31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 2025-03-10 + +- v25.3.0 +- unsafe pickling 방법 변경 + ## 2024-11-13 - v24.11.1 diff --git a/Taskfile.yml b/Taskfile.yml index bd3c8f1..494885f 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -10,13 +10,12 @@ tasks: cmds: - echo "$PYTHON" - echo "$WEBUI" - - echo "$UV_PYTHON" silent: true launch: dir: "{{.WEBUI}}" cmds: - - "{{.PYTHON}} launch.py --xformers --api" + - "{{.PYTHON}} launch.py --xformers --api {{ .CLI_ARGS }}" silent: true lint: @@ -29,4 +28,4 @@ tasks: update-torch: cmds: - - "{{.PYTHON}} -m uv pip install -U torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu124" + - "{{.PYTHON}} -m uv pip install -U torch torchvision torchaudio xformers --extra-index-url https://download.pytorch.org/whl/cu126" diff --git a/aaaaaa/helper.py b/aaaaaa/helper.py index ae19003..a296cd1 100644 --- a/aaaaaa/helper.py +++ b/aaaaaa/helper.py @@ -1,15 +1,17 @@ from __future__ import annotations +import os from contextlib import contextmanager from copy import copy from typing import TYPE_CHECKING, Any, Union +from unittest.mock import patch import torch from PIL import Image from typing_extensions import Protocol from modules import safe -from modules.shared import opts +from modules.shared import cmd_opts, opts if TYPE_CHECKING: # 타입 체커가 빨간 줄을 긋지 않게 하는 편법 @@ -37,13 +39,18 @@ def change_torch_load(): @contextmanager -def pause_total_tqdm(): - orig = opts.data.get("multiple_tqdm", True) - try: - opts.data["multiple_tqdm"] = False +def disable_safe_unpickle(): + with ( + patch.dict(os.environ, {"TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD": "1"}, clear=False), + patch.object(cmd_opts, "disable_safe_unpickle", True), + ): + yield + + +@contextmanager +def pause_total_tqdm(): + with patch.dict(opts.data, {"multiple_tqdm": False}, clear=False): yield - finally: - opts.data["multiple_tqdm"] = orig @contextmanager diff --git a/aaaaaa/traceback.py b/aaaaaa/traceback.py index 4119a9b..85631e3 100644 --- a/aaaaaa/traceback.py +++ b/aaaaaa/traceback.py @@ -1,4 +1,4 @@ -from __future__ import annotations +from __future__ import annotations # noqa: A005 import io import platform diff --git a/adetailer/__version__.py b/adetailer/__version__.py index 891aa8c..d024107 100644 --- a/adetailer/__version__.py +++ b/adetailer/__version__.py @@ -1 +1 @@ -__version__ = "24.11.1" +__version__ = "25.3.0" diff --git a/adetailer/common.py b/adetailer/common.py index 4d1fdcc..9fb5e45 100644 --- a/adetailer/common.py +++ b/adetailer/common.py @@ -39,8 +39,9 @@ def hf_download(file: str, repo_id: str = REPO_ID, check_remote: bool = True) -> with suppress(Exception): return hf_hub_download(repo_id, file, local_files_only=True) - msg = f"[-] ADetailer: Failed to load model {file!r} from huggingface" - print(msg) + if check_remote: + msg = f"[-] ADetailer: Failed to load model {file!r} from huggingface" + print(msg) return "INVALID" diff --git a/install.py b/install.py index 1868c07..d9c7a8a 100644 --- a/install.py +++ b/install.py @@ -8,10 +8,6 @@ from importlib.metadata import version # python >= 3.8 from packaging.version import parse import_name = {"py-cpuinfo": "cpuinfo", "protobuf": "google.protobuf"} -custom_requirements = { - "ultralytics": "ultralytics>=8.3.0,!=8.3.41,!=8.3.42,!=8.3.45,!=8.3.46" -} -excluded_versions = {"ultralytics": ("8.3.41", "8.3.42", "8.3.45", "8.3.46")} def is_installed( @@ -20,7 +16,6 @@ def is_installed( max_version: str | None = None, ): name = import_name.get(package, package) - excluded = excluded_versions.get(package, ()) try: spec = importlib.util.find_spec(name) except ModuleNotFoundError: @@ -39,10 +34,7 @@ def is_installed( try: pkg_version = version(package) - return ( - parse(min_version) <= parse(pkg_version) <= parse(max_version) - and pkg_version not in excluded - ) + return parse(min_version) <= parse(pkg_version) <= parse(max_version) except Exception: return False @@ -54,7 +46,7 @@ def run_pip(*args): def install(): deps = [ # requirements - ("ultralytics", "8.3.0", None), + ("ultralytics", "8.3.75", None), ("mediapipe", "0.10.13", "0.10.15"), ("rich", "13.0.0", None), ] @@ -62,9 +54,7 @@ def install(): pkgs = [] for pkg, low, high in deps: if not is_installed(pkg, low, high): - if pkg in custom_requirements: - cmd = custom_requirements[pkg] - elif low and high: + if low and high: cmd = f"{pkg}>={low},<={high}" elif low: cmd = f"{pkg}>={low}" diff --git a/scripts/!adetailer.py b/scripts/!adetailer.py index 406e1b5..1c032cb 100644 --- a/scripts/!adetailer.py +++ b/scripts/!adetailer.py @@ -18,8 +18,8 @@ import modules from aaaaaa.conditional import create_binary_mask, schedulers from aaaaaa.helper import ( PPImage, - change_torch_load, copy_extra_params, + disable_safe_unpickle, pause_total_tqdm, preserve_prompts, ) @@ -825,8 +825,8 @@ class AfterDetailerScript(scripts.Script): pred = mediapipe_predict(args.ad_model, pp.image, args.ad_confidence) else: - with change_torch_load(): - ad_model = self.get_ad_model(args.ad_model) + ad_model = self.get_ad_model(args.ad_model) + with disable_safe_unpickle(): pred = ultralytics_predict( ad_model, image=pp.image,