Merge branch 'dev'

This commit is contained in:
Dowon
2025-03-10 20:36:46 +09:00
10 changed files with 36 additions and 41 deletions

View File

@@ -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

View File

@@ -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]

View File

@@ -1,5 +1,10 @@
# Changelog
## 2025-03-10
- v25.3.0
- unsafe pickling 방법 변경
## 2024-11-13
- v24.11.1

View File

@@ -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"

View File

@@ -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

View File

@@ -1,4 +1,4 @@
from __future__ import annotations
from __future__ import annotations # noqa: A005
import io
import platform

View File

@@ -1 +1 @@
__version__ = "24.11.1"
__version__ = "25.3.0"

View File

@@ -39,6 +39,7 @@ 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)
if check_remote:
msg = f"[-] ADetailer: Failed to load model {file!r} from huggingface"
print(msg)
return "INVALID"

View File

@@ -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}"

View File

@@ -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)
with disable_safe_unpickle():
pred = ultralytics_predict(
ad_model,
image=pp.image,